* [PATCH] f2fs: ensure that node info flags are always initialized
@ 2024-12-04 6:09 Dmitry Antipov
2024-12-12 14:59 ` Chao Yu
0 siblings, 1 reply; 5+ messages in thread
From: Dmitry Antipov @ 2024-12-04 6:09 UTC (permalink / raw)
To: Jaegeuk Kim, Chao Yu
Cc: linux-f2fs-devel, linux-fsdevel, lvc-project, Dmitry Antipov,
syzbot+5141f6db57a2f7614352
Syzbot has reported the following KMSAN splat:
BUG: KMSAN: uninit-value in f2fs_new_node_page+0x1494/0x1630
f2fs_new_node_page+0x1494/0x1630
f2fs_new_inode_page+0xb9/0x100
f2fs_init_inode_metadata+0x176/0x1e90
f2fs_add_inline_entry+0x723/0xc90
f2fs_do_add_link+0x48f/0xa70
f2fs_symlink+0x6af/0xfc0
vfs_symlink+0x1f1/0x470
do_symlinkat+0x471/0xbc0
__x64_sys_symlink+0xcf/0x140
x64_sys_call+0x2fcc/0x3d90
do_syscall_64+0xd9/0x1b0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable new_ni created at:
f2fs_new_node_page+0x9d/0x1630
f2fs_new_inode_page+0xb9/0x100
So adjust 'f2fs_new_node_page()' to ensure that 'flag' field of on-stack
'struct node_info' is always zeroed just like if it was allocated within
'struct nat_entry' via 'f2fs_kmem_cache_alloc(..., GFP_F2FS_ZERO, ...)'
in '__alloc_nat_entry()'.
Reported-by: syzbot+5141f6db57a2f7614352@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5141f6db57a2f7614352
Fixes: e05df3b115e7 ("f2fs: add node operations")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
fs/f2fs/node.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 0b900a7a48e5..5103cc0d95c4 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -1314,7 +1314,7 @@ struct page *f2fs_new_inode_page(struct inode *inode)
struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
{
struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
- struct node_info new_ni;
+ struct node_info new_ni = { .flag = 0 };
struct page *page;
int err;
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] f2fs: ensure that node info flags are always initialized
2024-12-04 6:09 [PATCH] f2fs: ensure that node info flags are always initialized Dmitry Antipov
@ 2024-12-12 14:59 ` Chao Yu
2024-12-12 17:57 ` [PATCH v2] " Dmitry Antipov
0 siblings, 1 reply; 5+ messages in thread
From: Chao Yu @ 2024-12-12 14:59 UTC (permalink / raw)
To: Dmitry Antipov, Jaegeuk Kim
Cc: Chao Yu, linux-f2fs-devel, linux-fsdevel, lvc-project,
syzbot+5141f6db57a2f7614352
On 2024/12/4 14:09, Dmitry Antipov wrote:
> Syzbot has reported the following KMSAN splat:
>
> BUG: KMSAN: uninit-value in f2fs_new_node_page+0x1494/0x1630
> f2fs_new_node_page+0x1494/0x1630
> f2fs_new_inode_page+0xb9/0x100
> f2fs_init_inode_metadata+0x176/0x1e90
> f2fs_add_inline_entry+0x723/0xc90
> f2fs_do_add_link+0x48f/0xa70
> f2fs_symlink+0x6af/0xfc0
> vfs_symlink+0x1f1/0x470
> do_symlinkat+0x471/0xbc0
> __x64_sys_symlink+0xcf/0x140
> x64_sys_call+0x2fcc/0x3d90
> do_syscall_64+0xd9/0x1b0
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Local variable new_ni created at:
> f2fs_new_node_page+0x9d/0x1630
> f2fs_new_inode_page+0xb9/0x100
>
> So adjust 'f2fs_new_node_page()' to ensure that 'flag' field of on-stack
> 'struct node_info' is always zeroed just like if it was allocated within
> 'struct nat_entry' via 'f2fs_kmem_cache_alloc(..., GFP_F2FS_ZERO, ...)'
> in '__alloc_nat_entry()'.
>
> Reported-by: syzbot+5141f6db57a2f7614352@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=5141f6db57a2f7614352
> Fixes: e05df3b115e7 ("f2fs: add node operations")
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
> ---
> fs/f2fs/node.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
> index 0b900a7a48e5..5103cc0d95c4 100644
> --- a/fs/f2fs/node.c
> +++ b/fs/f2fs/node.c
> @@ -1314,7 +1314,7 @@ struct page *f2fs_new_inode_page(struct inode *inode)
> struct page *f2fs_new_node_page(struct dnode_of_data *dn, unsigned int ofs)
> {
> struct f2fs_sb_info *sbi = F2FS_I_SB(dn->inode);
> - struct node_info new_ni;
> + struct node_info new_ni = { .flag = 0 };
We can initialize new_ni.flag in f2fs_get_node_info() to cover
all similar cases?
Thanks,
> struct page *page;
> int err;
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH v2] f2fs: ensure that node info flags are always initialized
2024-12-12 14:59 ` Chao Yu
@ 2024-12-12 17:57 ` Dmitry Antipov
2024-12-16 13:47 ` Chao Yu
2024-12-16 16:40 ` [f2fs-dev] " patchwork-bot+f2fs
0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Antipov @ 2024-12-12 17:57 UTC (permalink / raw)
To: Chao Yu
Cc: Jaegeuk Kim, linux-f2fs-devel, linux-fsdevel, lvc-project,
Dmitry Antipov, syzbot+5141f6db57a2f7614352
Syzbot has reported the following KMSAN splat:
BUG: KMSAN: uninit-value in f2fs_new_node_page+0x1494/0x1630
f2fs_new_node_page+0x1494/0x1630
f2fs_new_inode_page+0xb9/0x100
f2fs_init_inode_metadata+0x176/0x1e90
f2fs_add_inline_entry+0x723/0xc90
f2fs_do_add_link+0x48f/0xa70
f2fs_symlink+0x6af/0xfc0
vfs_symlink+0x1f1/0x470
do_symlinkat+0x471/0xbc0
__x64_sys_symlink+0xcf/0x140
x64_sys_call+0x2fcc/0x3d90
do_syscall_64+0xd9/0x1b0
entry_SYSCALL_64_after_hwframe+0x77/0x7f
Local variable new_ni created at:
f2fs_new_node_page+0x9d/0x1630
f2fs_new_inode_page+0xb9/0x100
So adjust 'f2fs_get_node_info()' to ensure that 'flag'
field of 'struct node_info' is always initialized.
Reported-by: syzbot+5141f6db57a2f7614352@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=5141f6db57a2f7614352
Fixes: e05df3b115e7 ("f2fs: add node operations")
Suggested-by: Chao Yu <chao@kernel.org>
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
v2: move flag initialization to f2fs_get_node_info() as suggested by Chao
---
fs/f2fs/node.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c
index 0b900a7a48e5..c04ee1a7ce57 100644
--- a/fs/f2fs/node.c
+++ b/fs/f2fs/node.c
@@ -558,6 +558,7 @@ int f2fs_get_node_info(struct f2fs_sb_info *sbi, nid_t nid,
block_t blkaddr;
int i;
+ ni->flag = 0;
ni->nid = nid;
retry:
/* Check nat cache */
--
2.47.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH v2] f2fs: ensure that node info flags are always initialized
2024-12-12 17:57 ` [PATCH v2] " Dmitry Antipov
@ 2024-12-16 13:47 ` Chao Yu
2024-12-16 16:40 ` [f2fs-dev] " patchwork-bot+f2fs
1 sibling, 0 replies; 5+ messages in thread
From: Chao Yu @ 2024-12-16 13:47 UTC (permalink / raw)
To: Dmitry Antipov
Cc: Chao Yu, Jaegeuk Kim, linux-f2fs-devel, linux-fsdevel,
lvc-project, syzbot+5141f6db57a2f7614352
On 2024/12/13 1:57, Dmitry Antipov wrote:
> Syzbot has reported the following KMSAN splat:
>
> BUG: KMSAN: uninit-value in f2fs_new_node_page+0x1494/0x1630
> f2fs_new_node_page+0x1494/0x1630
> f2fs_new_inode_page+0xb9/0x100
> f2fs_init_inode_metadata+0x176/0x1e90
> f2fs_add_inline_entry+0x723/0xc90
> f2fs_do_add_link+0x48f/0xa70
> f2fs_symlink+0x6af/0xfc0
> vfs_symlink+0x1f1/0x470
> do_symlinkat+0x471/0xbc0
> __x64_sys_symlink+0xcf/0x140
> x64_sys_call+0x2fcc/0x3d90
> do_syscall_64+0xd9/0x1b0
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> Local variable new_ni created at:
> f2fs_new_node_page+0x9d/0x1630
> f2fs_new_inode_page+0xb9/0x100
>
> So adjust 'f2fs_get_node_info()' to ensure that 'flag'
> field of 'struct node_info' is always initialized.
>
> Reported-by: syzbot+5141f6db57a2f7614352@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=5141f6db57a2f7614352
> Fixes: e05df3b115e7 ("f2fs: add node operations")
> Suggested-by: Chao Yu <chao@kernel.org>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Reviewed-by: Chao Yu <chao@kernel.org>
Thanks,
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [f2fs-dev] [PATCH v2] f2fs: ensure that node info flags are always initialized
2024-12-12 17:57 ` [PATCH v2] " Dmitry Antipov
2024-12-16 13:47 ` Chao Yu
@ 2024-12-16 16:40 ` patchwork-bot+f2fs
1 sibling, 0 replies; 5+ messages in thread
From: patchwork-bot+f2fs @ 2024-12-16 16:40 UTC (permalink / raw)
To: Dmitry Antipov
Cc: chao, lvc-project, linux-f2fs-devel, syzbot+5141f6db57a2f7614352,
linux-fsdevel, jaegeuk
Hello:
This patch was applied to jaegeuk/f2fs.git (dev)
by Jaegeuk Kim <jaegeuk@kernel.org>:
On Thu, 12 Dec 2024 20:57:48 +0300 you wrote:
> Syzbot has reported the following KMSAN splat:
>
> BUG: KMSAN: uninit-value in f2fs_new_node_page+0x1494/0x1630
> f2fs_new_node_page+0x1494/0x1630
> f2fs_new_inode_page+0xb9/0x100
> f2fs_init_inode_metadata+0x176/0x1e90
> f2fs_add_inline_entry+0x723/0xc90
> f2fs_do_add_link+0x48f/0xa70
> f2fs_symlink+0x6af/0xfc0
> vfs_symlink+0x1f1/0x470
> do_symlinkat+0x471/0xbc0
> __x64_sys_symlink+0xcf/0x140
> x64_sys_call+0x2fcc/0x3d90
> do_syscall_64+0xd9/0x1b0
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
>
> [...]
Here is the summary with links:
- [f2fs-dev,v2] f2fs: ensure that node info flags are always initialized
https://git.kernel.org/jaegeuk/f2fs/c/76f01376df39
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] 5+ messages in thread
end of thread, other threads:[~2024-12-16 16:40 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-04 6:09 [PATCH] f2fs: ensure that node info flags are always initialized Dmitry Antipov
2024-12-12 14:59 ` Chao Yu
2024-12-12 17:57 ` [PATCH v2] " Dmitry Antipov
2024-12-16 13:47 ` Chao Yu
2024-12-16 16:40 ` [f2fs-dev] " 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