public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] f2fs: avoid trying to get invalid block address
@ 2025-01-17 22:09 Jaegeuk Kim
  2025-01-20  5:27 ` [f2fs-dev] " Chao Yu
  2025-01-21 17:00 ` patchwork-bot+f2fs
  0 siblings, 2 replies; 3+ messages in thread
From: Jaegeuk Kim @ 2025-01-17 22:09 UTC (permalink / raw)
  To: linux-kernel, linux-f2fs-devel; +Cc: Jaegeuk Kim

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.

Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
---
 fs/f2fs/namei.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
index 57d46e1439de..a278c7da8177 100644
--- a/fs/f2fs/namei.c
+++ b/fs/f2fs/namei.c
@@ -341,6 +341,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
 	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);
-- 
2.48.0.rc2.279.g1de40edade-goog


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: avoid trying to get invalid block address
  2025-01-17 22:09 [PATCH] f2fs: avoid trying to get invalid block address Jaegeuk Kim
@ 2025-01-20  5:27 ` Chao Yu
  2025-01-21 17:00 ` patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: Chao Yu @ 2025-01-20  5:27 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-f2fs-devel; +Cc: chao

On 1/18/25 06:09, Jaegeuk Kim via Linux-f2fs-devel wrote:
> 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.
> 

Needs a fixes line?

Fixes: 0abd675e97e6 ("f2fs: support plain user/group quota")

Otherwise, it looks good to me.

Reviewed-by: Chao Yu <chao@kernel.org>

Thanks,

> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>   fs/f2fs/namei.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/fs/f2fs/namei.c b/fs/f2fs/namei.c
> index 57d46e1439de..a278c7da8177 100644
> --- a/fs/f2fs/namei.c
> +++ b/fs/f2fs/namei.c
> @@ -341,6 +341,7 @@ static struct inode *f2fs_new_inode(struct mnt_idmap *idmap,
>   	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);


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [f2fs-dev] [PATCH] f2fs: avoid trying to get invalid block address
  2025-01-17 22:09 [PATCH] f2fs: avoid trying to get invalid block address Jaegeuk Kim
  2025-01-20  5:27 ` [f2fs-dev] " Chao Yu
@ 2025-01-21 17:00 ` patchwork-bot+f2fs
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+f2fs @ 2025-01-21 17:00 UTC (permalink / raw)
  To: Jaegeuk Kim; +Cc: linux-kernel, linux-f2fs-devel

Hello:

This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:

On Fri, 17 Jan 2025 22:09:55 +0000 you wrote:
> 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.
> 
> [...]

Here is the summary with links:
  - [f2fs-dev] f2fs: avoid trying to get invalid block address
    https://git.kernel.org/jaegeuk/f2fs/c/e02938613eb2

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2025-01-21 17:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-17 22:09 [PATCH] f2fs: avoid trying to get invalid block address Jaegeuk Kim
2025-01-20  5:27 ` [f2fs-dev] " Chao Yu
2025-01-21 17:00 ` patchwork-bot+f2fs

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox