Re: [PATCH] f2fs: fix to reject inline_data inode which has blocks

From: Chao Yu

Date: Tue Dec 01 2026 - 03:15:07 EST


On 11/22/26 23:36, Hengyu Liang wrote:
> Commit c240c87bcd44 ("f2fs: fix to do sanity check on blocks for
> inline_data inode") made f2fs_sanity_check_inline_data() return false,
> i.e. "sane", as soon as an inline_data inode has blocks or node ids.
>
> However, the function returns true for a corrupted inode, and that
> commit meant to detect exactly this state. The early return also skips
> the older checks that reject inline_data on a directory and on a
> compressed, encrypted or verity file. As of now, such an inode on a
> corrupted image is loaded, and setting this one bit in i_inline of an
> inode is enough for the following:
>
> - unlink() of a small compressed file that owns one data block hits
> BUG_ON() in clear_inode(). With panic_on_oops=1 the machine panics.
> Otherwise the task is killed, and the file system can no longer be
> unmounted (EBUSY).
> - unlink() of a larger compressed file succeeds, but the orphan inode
> cannot be evicted, and the next mount fails with EIO until fsck.f2fs
> repairs the image.
> - A directory lists only 70 of its 300 entries, yet rmdir removes it
> once those 70 are deleted, and fsck.f2fs then finds the other 230
> inodes unreachable.
>
> The issue can be reproduced with:
>
> mkfs.f2fs -q -f -O extra_attr,compression /dev/vda
> mount -t f2fs -o compress_algorithm=lz4 /dev/vda /mnt
> touch /mnt/f; chattr +c /mnt/f; echo hello > /mnt/f; sync
> ino=$(ls -i /mnt/f | awk '{print $1}'); umount /mnt
> blk=$(dump.f2fs -d 1 -i $ino /dev/vda |
> sed -n 's/.*nat_entry.block_addr *\[0x\(.*\)\]/\1/p')
> # i_inline 0x21 -> 0x23 (F2FS_INLINE_DATA)
> printf '\043' | dd of=/dev/vda bs=1 seek=$((0x$blk * 4096 + 3)) \
> conv=notrunc
> mount -t f2fs /dev/vda /mnt; rm /mnt/f
>
> Before that commit, the result is:
>
> rm: can't stat '/mnt/f': Structure needs cleaning
>
> After it, the result is:
>
> kernel BUG at fs/inode.c:776!
>
> With this patch, the result is the same as before that commit.
>
> This patch will make the check return true for an inline_data inode
> which has blocks, as the message of that commit describes.
>
> Fixes: c240c87bcd44 ("f2fs: fix to do sanity check on blocks for inline_data inode")
> Cc: stable@xxxxxxxxxxxxxxx
> Signed-off-by: Hengyu Liang <hengyul@xxxxxxxxxx>
Reviewed-by: Chao Yu <chao@xxxxxxxxxx>

Thanks,