android_kernel_xiaomi_sm7250/fs/nilfs2
Ryusuke Konishi bfc82a2654 nilfs2: fix use-after-free bug of struct nilfs_root
commit d325dc6eb763c10f591c239550b8c7e5466a5d09 upstream.

If the beginning of the inode bitmap area is corrupted on disk, an inode
with the same inode number as the root inode can be allocated and fail
soon after.  In this case, the subsequent call to nilfs_clear_inode() on
that bogus root inode will wrongly decrement the reference counter of
struct nilfs_root, and this will erroneously free struct nilfs_root,
causing kernel oopses.

This fixes the problem by changing nilfs_new_inode() to skip reserved
inode numbers while repairing the inode bitmap.

Link: https://lkml.kernel.org/r/20221003150519.39789-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+b8c672b0e22615c80fe0@syzkaller.appspotmail.com
Reported-by: Khalid Masum <khalid.masum.92@gmail.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-10-26 13:19:22 +02:00
..
alloc.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
alloc.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
bmap.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
bmap.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
btnode.c nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
btnode.h nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
btree.c nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
btree.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
cpfile.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
cpfile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
dat.c nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:10:37 +02:00
dat.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
dir.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
direct.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
direct.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
export.h License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
file.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
gcinode.c nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
ifile.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
ifile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
inode.c nilfs2: fix use-after-free bug of struct nilfs_root 2022-10-26 13:19:22 +02:00
ioctl.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
Kconfig fs/nilfs2: remove depends on CONFIG_EXPERIMENTAL 2013-01-11 11:39:04 -08:00
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
mdt.c nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:10:37 +02:00
mdt.h nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:10:37 +02:00
namei.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
nilfs.h nilfs2: fix incorrect masking of permission flags for symlinks 2022-07-21 21:09:26 +02:00
page.c nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
page.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
recovery.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
segbuf.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
segbuf.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
segment.c nilfs2: replace WARN_ONs by nilfs_error for checkpoint acquisition failure 2022-10-26 13:19:18 +02:00
segment.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
sufile.c nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
sufile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
super.c nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:10:37 +02:00
sysfs.c nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group 2021-09-26 13:39:49 +02:00
sysfs.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
the_nilfs.c nilfs2: use refcount_dec_and_lock() to fix potential UAF 2021-09-26 13:39:47 +02:00
the_nilfs.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00