[PATCH] debugfs: add fsd's methods initialization

Edward Adam Davis posted 1 patch 10 months, 2 weeks ago
fs/debugfs/file.c | 1 +
1 file changed, 1 insertion(+)
[PATCH] debugfs: add fsd's methods initialization
Posted by Edward Adam Davis 10 months, 2 weeks ago
syzbot reported a uninit-value in full_proxy_unlocked_ioctl. [1]

The newly created fsd does not initialize methods, and increases the
initialization of methods for fsd.

[1]
BUG: KMSAN: uninit-value in full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
 full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
 vfs_ioctl fs/ioctl.c:51 [inline]
 __do_sys_ioctl fs/ioctl.c:906 [inline]
 __se_sys_ioctl+0x246/0x440 fs/ioctl.c:892
 __x64_sys_ioctl+0x96/0xe0 fs/ioctl.c:892
 x64_sys_call+0x19f0/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:17
 do_syscall_x64 arch/x86/entry/common.c:52 [inline]
 do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
 entry_SYSCALL_64_after_hwframe+0x77/0x7f

Fixes: 41a0ecc0997c ("debugfs: get rid of dynamically allocation proxy_ops")
Reported-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=8928e473a91452caca2f
Tested-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 fs/debugfs/file.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c
index e33cc77699cd..5fbefce2b372 100644
--- a/fs/debugfs/file.c
+++ b/fs/debugfs/file.c
@@ -102,6 +102,7 @@ static int __debugfs_file_get(struct dentry *dentry, enum dbgfs_get_mode mode)
 		if (!fsd)
 			return -ENOMEM;
 
+		fsd->methods = 0;
 		if (mode == DBGFS_GET_SHORT) {
 			const struct debugfs_short_fops *ops;
 			ops = fsd->short_fops = DEBUGFS_I(inode)->short_fops;
-- 
2.43.0
Re: [PATCH] debugfs: add fsd's methods initialization
Posted by Greg KH 10 months, 2 weeks ago
On Mon, Feb 03, 2025 at 11:27:56AM +0800, Edward Adam Davis wrote:
> syzbot reported a uninit-value in full_proxy_unlocked_ioctl. [1]
> 
> The newly created fsd does not initialize methods, and increases the
> initialization of methods for fsd.
> 
> [1]
> BUG: KMSAN: uninit-value in full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
>  full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
>  vfs_ioctl fs/ioctl.c:51 [inline]
>  __do_sys_ioctl fs/ioctl.c:906 [inline]
>  __se_sys_ioctl+0x246/0x440 fs/ioctl.c:892
>  __x64_sys_ioctl+0x96/0xe0 fs/ioctl.c:892
>  x64_sys_call+0x19f0/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:17
>  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
>  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
>  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> 
> Fixes: 41a0ecc0997c ("debugfs: get rid of dynamically allocation proxy_ops")
> Reported-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> Closes: https://syzkaller.appspot.com/bug?extid=8928e473a91452caca2f
> Tested-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> ---
>  fs/debugfs/file.c | 1 +
>  1 file changed, 1 insertion(+)

Is this still an issue on 6.14-rc1, specifically after commit
57b314752ec0 ("debugfs: Fix the missing initializations in
__debugfs_file_get()")?

thanks,

greg k-h
Re: [PATCH] debugfs: add fsd's methods initialization
Posted by Edward Adam Davis 10 months, 2 weeks ago
On Mon, 3 Feb 2025 09:14:51 +0100, Greg KH wrote:
> On Mon, Feb 03, 2025 at 11:27:56AM +0800, Edward Adam Davis wrote:
> > syzbot reported a uninit-value in full_proxy_unlocked_ioctl. [1]
> >
> > The newly created fsd does not initialize methods, and increases the
> > initialization of methods for fsd.
> >
> > [1]
> > BUG: KMSAN: uninit-value in full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
> >  full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
> >  vfs_ioctl fs/ioctl.c:51 [inline]
> >  __do_sys_ioctl fs/ioctl.c:906 [inline]
> >  __se_sys_ioctl+0x246/0x440 fs/ioctl.c:892
> >  __x64_sys_ioctl+0x96/0xe0 fs/ioctl.c:892
> >  x64_sys_call+0x19f0/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:17
> >  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> >  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
> >  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> >
> > Fixes: 41a0ecc0997c ("debugfs: get rid of dynamically allocation proxy_ops")
> > Reported-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> > Closes: https://syzkaller.appspot.com/bug?extid=8928e473a91452caca2f
> > Tested-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > ---
> >  fs/debugfs/file.c | 1 +
> >  1 file changed, 1 insertion(+)
> 
> Is this still an issue on 6.14-rc1, specifically after commit
> 57b314752ec0 ("debugfs: Fix the missing initializations in
> __debugfs_file_get()")?
No.

Edward
Re: [PATCH] debugfs: add fsd's methods initialization
Posted by Greg KH 10 months, 2 weeks ago
On Mon, Feb 03, 2025 at 07:05:32PM +0800, Edward Adam Davis wrote:
> On Mon, 3 Feb 2025 09:14:51 +0100, Greg KH wrote:
> > On Mon, Feb 03, 2025 at 11:27:56AM +0800, Edward Adam Davis wrote:
> > > syzbot reported a uninit-value in full_proxy_unlocked_ioctl. [1]
> > >
> > > The newly created fsd does not initialize methods, and increases the
> > > initialization of methods for fsd.
> > >
> > > [1]
> > > BUG: KMSAN: uninit-value in full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
> > >  full_proxy_unlocked_ioctl+0xed/0x3a0 fs/debugfs/file.c:399
> > >  vfs_ioctl fs/ioctl.c:51 [inline]
> > >  __do_sys_ioctl fs/ioctl.c:906 [inline]
> > >  __se_sys_ioctl+0x246/0x440 fs/ioctl.c:892
> > >  __x64_sys_ioctl+0x96/0xe0 fs/ioctl.c:892
> > >  x64_sys_call+0x19f0/0x3c30 arch/x86/include/generated/asm/syscalls_64.h:17
> > >  do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> > >  do_syscall_64+0xcd/0x1e0 arch/x86/entry/common.c:83
> > >  entry_SYSCALL_64_after_hwframe+0x77/0x7f
> > >
> > > Fixes: 41a0ecc0997c ("debugfs: get rid of dynamically allocation proxy_ops")
> > > Reported-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> > > Closes: https://syzkaller.appspot.com/bug?extid=8928e473a91452caca2f
> > > Tested-by: syzbot+8928e473a91452caca2f@syzkaller.appspotmail.com
> > > Signed-off-by: Edward Adam Davis <eadavis@qq.com>
> > > ---
> > >  fs/debugfs/file.c | 1 +
> > >  1 file changed, 1 insertion(+)
> > 
> > Is this still an issue on 6.14-rc1, specifically after commit
> > 57b314752ec0 ("debugfs: Fix the missing initializations in
> > __debugfs_file_get()")?
> No.

Great, I'll forget about it then :)

thanks!

greg k-h