linux/fs/nilfs2
Ryusuke Konishi 25457d07c8 nilfs2: fix infinite loop in nilfs_mdt_get_block()
commit a6a491c048 upstream.

If the disk image that nilfs2 mounts is corrupted and a virtual block
address obtained by block lookup for a metadata file is invalid,
nilfs_bmap_lookup_at_level() may return the same internal return code as
-ENOENT, meaning the block does not exist in the metadata file.

This duplication of return codes confuses nilfs_mdt_get_block(), causing
it to read and create a metadata block indefinitely.

In particular, if this happens to the inode metadata file, ifile,
semaphore i_rwsem can be left held, causing task hangs in lock_mount.

Fix this issue by making nilfs_bmap_lookup_at_level() treat virtual block
address translation failures with -ENOENT as metadata corruption instead
of returning the error code.

Link: https://lkml.kernel.org/r/20230430193046.6769-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Tested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Reported-by: syzbot+221d75710bde87fa0e97@syzkaller.appspotmail.com
  Link: https://syzkaller.appspot.com/bug?extid=221d75710bde87fa0e97
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-05-11 23:03:39 +09:00
..
alloc.c
alloc.h
bmap.c nilfs2: fix infinite loop in nilfs_mdt_get_block() 2023-05-11 23:03:39 +09:00
bmap.h
btnode.c
btnode.h
btree.c nilfs2: fix general protection fault in nilfs_btree_insert() 2023-01-24 07:24:33 +01:00
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() 2022-11-30 14:49:40 -08:00
dat.h
dir.c
direct.c
direct.h
export.h
file.c
gcinode.c
ifile.c
ifile.h
inode.c nilfs2: fix NULL pointer dereference at nilfs_bmap_lookup_at_level() 2022-10-11 19:05:45 -07:00
ioctl.c nilfs2: fix kernel-infoleak in nilfs_ioctl_wrap_copy() 2023-03-30 12:49:27 +02:00
Kconfig
Makefile
mdt.c
mdt.h
namei.c
nilfs.h
page.c nilfs2: convert nilfs_find_uncommited_extent() to use filemap_get_folios_contig() 2022-09-11 20:26:03 -07:00
page.h
recovery.c
segbuf.c
segbuf.h
segment.c nilfs2: do not write dirty data after degenerating to read-only 2023-05-11 23:03:39 +09:00
segment.h
sufile.c nilfs2: fix nilfs_sufile_mark_dirty() not set segment usage as dirty 2022-11-22 18:50:45 -08:00
sufile.h
super.c nilfs2: fix sysfs interface lifetime 2023-04-13 16:55:28 +02:00
sysfs.c
sysfs.h
the_nilfs.c nilfs2: fix sysfs interface lifetime 2023-04-13 16:55:28 +02:00
the_nilfs.h