From 2055772eada08d49b00e82e7f2825294fad47eaf Mon Sep 17 00:00:00 2001 From: Jaegeuk Kim Date: Fri, 17 Jan 2025 21:38:22 +0000 Subject: [PATCH] UPSTREAM: f2fs: avoid trying to get invalid block address In f2fs_new_inode(), if we fail to get a new inode, we go iput(), followed by f2fs_evict_inode(). If the inode is not marked as bad, it'll try to call f2fs_remove_inode_page() which tries to read the inode block given node id. But, there's no block address allocated yet, which gives a chance to access a wrong block address, if the block device has some garbage data in NAT table. We need to make sure NAT table should have zero data for all the unallocated node ids, but also would be better to take this unnecessary path as well. Let's mark the faild inode as bad. Bug: 383968963 Fixes: 0abd675e97e6 ("f2fs: support plain user/group quota") Reviewed-by: Chao Yu Change-Id: I37bfd94f0612e1521ae43fe529fd186954f3dece Signed-off-by: Jaegeuk Kim (cherry picked from commit e02938613eb206ebf788e2d3d4fccf534e4ea12e) (cherry picked from commit 444939d3b27bb3857a7cc3e37595e794eef07db4) --- fs/f2fs/namei.c | 1 + 1 file changed, 1 insertion(+) diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c index 19449320687c..92419d2726a0 100644 --- a/fs/f2fs/namei.c +++ b/fs/f2fs/namei.c @@ -325,6 +325,7 @@ fail_drop: trace_f2fs_new_inode(inode, err); dquot_drop(inode); inode->i_flags |= S_NOQUOTA; + make_bad_inode(inode); if (nid_free) set_inode_flag(inode, FI_FREE_NID); clear_nlink(inode);