linux/fs/nilfs2
Deepanshu Kartikey 9472d37799 nilfs2: reject zero bd_oblocknr in nilfs_ioctl_mark_blocks_dirty()
[ Upstream commit be3e5d1064 ]

nilfs_ioctl_mark_blocks_dirty() uses bd_oblocknr to detect dead blocks
by comparing it with the current block number bd_blocknr. If they differ,
the block is considered dead and skipped.

However, bd_oblocknr should never be 0 since block 0 typically stores the
primary superblock and is never a valid GC target block. A corrupted ioctl
request with bd_oblocknr set to 0 causes the comparison to incorrectly
match when the lookup returns -ENOENT and sets bd_blocknr to 0, bypassing
the dead block check and calling nilfs_bmap_mark() on a non-existent
block. This causes nilfs_btree_do_lookup() to return -ENOENT, triggering
the WARN_ON(ret == -ENOENT).

Fix this by rejecting ioctl requests with bd_oblocknr set to 0 at the
beginning of each iteration.

[ryusuke: slightly modified the commit message and comments for accuracy]

Fixes: 7942b919f7 ("nilfs2: ioctl operations")
Reported-by: syzbot+98a040252119df0506f8@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=98a040252119df0506f8
Suggested-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Deepanshu Kartikey <Kartikey406@gmail.com>
Reported-by: syzbot+466a45fcfb0562f5b9a0@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=466a45fcfb0562f5b9a0
Cc: Junjie Cao <junjie.cao@linux.dev>
Signed-off-by: Ryusuke Konishi <konishi.ryusuke@gmail.com>
Signed-off-by: Viacheslav Dubeyko <slava@dubeyko.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
History 2026-06-01 17:35:27 +02:00
..
alloc.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
alloc.h nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
bmap.c nilfs2: fix infinite loop in nilfs_mdt_get_block() 2023-05-11 23:00:39 +09:00
bmap.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
btnode.c nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint 2024-12-14 19:50:36 +01:00
btnode.h nilfs2: fix lockdep warnings in page operations for btree nodes 2022-05-25 09:57:26 +02:00
btree.c nilfs2: do not propagate ENOENT error from nilfs_btree_propagate() 2025-06-27 11:05:15 +01:00
btree.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
cpfile.c nilfs2: fix typos in comments 2021-05-06 19:24:13 -07:00
cpfile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
dat.c nilfs2: fix NULL i_assoc_inode dereference in nilfs_mdt_save_to_shadow_map 2026-06-01 17:35:06 +02:00
dat.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
dir.c nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:51:12 +01:00
direct.c nilfs2: add pointer check for nilfs_direct_propagate() 2025-06-27 11:05:14 +01: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: fix hang in nilfs_lookup_dirty_data_buffers() 2024-02-23 08:55:08 +01:00
gcinode.c nilfs2: fix null-ptr-deref in block_dirty_buffer tracepoint 2024-12-14 19:50:36 +01:00
ifile.c nilfs2: fix incorrect inode allocation from reserved inodes 2024-07-18 13:07:36 +02:00
ifile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
inode.c nilfs2: reject invalid file types when reading inodes 2025-08-28 16:24:05 +02:00
ioctl.c nilfs2: reject zero bd_oblocknr in nilfs_ioctl_mark_blocks_dirty() 2026-06-01 17:35:27 +02:00
Kconfig treewide: Add SPDX license identifier - Makefile/Kconfig 2019-05-21 10:50:46 +02: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: do not output warnings when clearing dirty buffers 2025-03-13 12:50:45 +01:00
mdt.h nilfs2: fix lockdep warnings during disk space reclamation 2022-05-25 09:57:26 +02:00
namei.c nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:51:12 +01:00
nilfs.h nilfs2: handle errors that nilfs_prepare_chunk() may return 2025-03-13 12:51:12 +01:00
page.c nilfs2: do not force clear folio if buffer is referenced 2025-03-13 12:50:45 +01:00
page.h nilfs2: do not output warnings when clearing dirty buffers 2025-03-13 12:50:45 +01:00
recovery.c nilfs2: fix missing cleanup on rollforward recovery error 2024-09-12 11:07:44 +02:00
segbuf.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:29:42 +02:00
segbuf.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
segment.c nilfs2: protect access to buffers with no active references 2025-03-13 12:50:45 +01:00
segment.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
sufile.c nilfs2: Fix potential block overflow that cause system hang 2026-02-19 16:21:43 +01:00
sufile.h nilfs2: convert to SPDX license tags 2018-09-04 16:45:02 -07:00
super.c nilfs2: fix buffer corruption due to concurrent device reads 2023-06-28 10:29:42 +02:00
sysfs.c nilfs2: fix CFI failure when accessing /sys/fs/nilfs2/features/* 2025-10-02 13:39:07 +02:00
sysfs.h nilfs2: fix CFI failure when accessing /sys/fs/nilfs2/features/* 2025-10-02 13:39:07 +02:00
the_nilfs.c nilfs2: fix inode number range checks 2024-07-18 13:07:32 +02:00
the_nilfs.h nilfs2: fix inode number range checks 2024-07-18 13:07:32 +02:00