Skip to content

Commit f272982

Browse files
committed
Merge tag 'nilfs2-v7.1-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/nilfs2
Pull nilfs2 updates from Viacheslav Dubeyko: "This contains fixes of syzbot reported issues in NILFS2 functionality: - The DAT inode's btree node cache (i_assoc_inode) is initialized lazily during btree operations. However, nilfs_mdt_save_to_shadow_map() assumes i_assoc_inode is already initialized when copying dirty pages to the shadow map during GC. If NILFS_IOCTL_CLEAN_SEGMENTS is called immediately after mount before any btree operation has occurred on the DAT inode, i_assoc_inode is NULL leading to a general protection fault. Fix this by calling nilfs_attach_btree_node_cache() on the DAT inode in nilfs_dat_read() at mount time, ensuring i_assoc_inode is always initialized before any GC operation can use it (Deepanshu Kartikey) - 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. 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 (Deepanshu Kartikey)" * tag 'nilfs2-v7.1-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/vdubeyko/nilfs2: nilfs2: reject zero bd_oblocknr in nilfs_ioctl_mark_blocks_dirty() nilfs2: fix NULL i_assoc_inode dereference in nilfs_mdt_save_to_shadow_map
2 parents 4d99814 + be3e5d1 commit f272982

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

fs/nilfs2/dat.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -524,6 +524,9 @@ int nilfs_dat_read(struct super_block *sb, size_t entry_size,
524524
if (err)
525525
goto failed;
526526

527+
err = nilfs_attach_btree_node_cache(dat);
528+
if (err)
529+
goto failed;
527530
err = nilfs_read_inode_common(dat, raw_inode);
528531
if (err)
529532
goto failed;

fs/nilfs2/ioctl.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,6 +736,12 @@ static int nilfs_ioctl_mark_blocks_dirty(struct the_nilfs *nilfs,
736736
int ret, i;
737737

738738
for (i = 0; i < nmembs; i++) {
739+
/*
740+
* bd_oblocknr must never be 0 as block 0
741+
* is never a valid GC target block
742+
*/
743+
if (unlikely(!bdescs[i].bd_oblocknr))
744+
return -EINVAL;
739745
/* XXX: use macro or inline func to check liveness */
740746
ret = nilfs_bmap_lookup_at_level(bmap,
741747
bdescs[i].bd_offset,

0 commit comments

Comments
 (0)