linux-stable/fs/nilfs2
Ryusuke Konishi 5c18041b65 nilfs2: fix missing error check for sb_set_blocksize call
commit d61d0ab573 upstream.

When mounting a filesystem image with a block size larger than the page
size, nilfs2 repeatedly outputs long error messages with stack traces to
the kernel log, such as the following:

 getblk(): invalid block size 8192 requested
 logical block size: 512
 ...
 Call Trace:
  dump_stack_lvl+0x92/0xd4
  dump_stack+0xd/0x10
  bdev_getblk+0x33a/0x354
  __breadahead+0x11/0x80
  nilfs_search_super_root+0xe2/0x704 [nilfs2]
  load_nilfs+0x72/0x504 [nilfs2]
  nilfs_mount+0x30f/0x518 [nilfs2]
  legacy_get_tree+0x1b/0x40
  vfs_get_tree+0x18/0xc4
  path_mount+0x786/0xa88
  __ia32_sys_mount+0x147/0x1a8
  __do_fast_syscall_32+0x56/0xc8
  do_fast_syscall_32+0x29/0x58
  do_SYSENTER_32+0x15/0x18
  entry_SYSENTER_32+0x98/0xf1
 ...

This overloads the system logger.  And to make matters worse, it sometimes
crashes the kernel with a memory access violation.

This is because the return value of the sb_set_blocksize() call, which
should be checked for errors, is not checked.

The latter issue is due to out-of-buffer memory being accessed based on a
large block size that caused sb_set_blocksize() to fail for buffers read
with the initial minimum block size that remained unupdated in the
super_block structure.

Since nilfs2 mkfs tool does not accept block sizes larger than the system
page size, this has been overlooked.  However, it is possible to create
this situation by intentionally modifying the tool or by passing a
filesystem image created on a system with a large page size to a system
with a smaller page size and mounting it.

Fix this issue by inserting the expected error handling for the call to
sb_set_blocksize().

Link: https://lkml.kernel.org/r/20231129141547.4726-1-konishi.ryusuke@gmail.com
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@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>
2023-12-13 16:46:17 +01:00
..
Kconfig
Makefile License cleanup: add SPDX GPL-2.0 license identifier to files with no license 2017-11-02 11:10:55 +01:00
alloc.c nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse 2023-09-23 10:46:52 +02:00
alloc.h
bmap.c nilfs2: fix infinite loop in nilfs_mdt_get_block() 2023-05-17 11:11:46 +02:00
bmap.h
btnode.c nilfs2: fix incomplete buffer cleanup in nilfs_btnode_abort_change_key() 2023-06-21 15:38:58 +02:00
btnode.h nilfs2: fix lockdep warnings in page operations for btree nodes 2022-10-26 13:16:56 +02:00
btree.c nilfs2: fix general protection fault in nilfs_btree_insert() 2023-01-24 07:05:18 +01:00
btree.h
cpfile.c
cpfile.h
dat.c nilfs2: fix NULL pointer dereference in nilfs_palloc_commit_free_entry() 2022-12-08 11:16:32 +01:00
dat.h
dir.c
direct.c
direct.h
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 mm, fs: reduce fault, page_mkwrite, and pfn_mkwrite to take only vmf 2017-02-24 17:46:54 -08:00
gcinode.c nilfs2: fix potential use after free in nilfs_gccache_submit_read_data() 2023-10-10 21:43:40 +02:00
ifile.c
ifile.h
inode.c nilfs2: fix WARNING in mark_buffer_dirty due to discarded buffer reuse 2023-09-23 10:46:52 +02:00
ioctl.c nilfs2: fix kernel-infoleak in nilfs_ioctl_wrap_copy() 2023-04-05 11:14:18 +02:00
mdt.c nilfs2: fix lockdep warnings during disk space reclamation 2022-10-26 13:16:57 +02:00
mdt.h nilfs2: fix lockdep warnings during disk space reclamation 2022-10-26 13:16:57 +02:00
namei.c do d_instantiate/unlock_new_inode combinations safely 2018-05-30 07:51:47 +02:00
nilfs.h nilfs2: fix lockdep warnings during disk space reclamation 2022-10-26 13:16:57 +02:00
page.c nilfs2: prevent general protection fault in nilfs_clear_dirty_page() 2023-06-28 10:14:19 +02:00
page.h
recovery.c
segbuf.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:14:19 +02:00
segbuf.h
segment.c nilfs2: fix general protection fault in nilfs_lookup_dirty_data_buffers() 2023-09-23 10:46:52 +02:00
segment.h
sufile.c nilfs2: prevent WARNING in nilfs_sufile_set_segment_usage() 2023-12-13 16:46:16 +01:00
sufile.h
super.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:14:19 +02:00
sysfs.c nilfs2: fix memory leak in nilfs_sysfs_delete_snapshot_group 2021-09-26 13:37:30 +02:00
sysfs.h
the_nilfs.c nilfs2: fix missing error check for sb_set_blocksize call 2023-12-13 16:46:17 +01:00
the_nilfs.h nilfs2: fix use-after-free of nilfs_root in dirtying inodes via iput 2023-08-16 18:10:53 +02:00