[syzbot] [nfs?] KMSAN: kernel-infoleak in sys_name_to_handle_at (4)

8 views
Skip to first unread message

syzbot

unread,
Jan 14, 2024, 5:14:17 AMJan 14
to amir...@gmail.com, bra...@kernel.org, chuck...@oracle.com, jla...@kernel.org, linux-...@vger.kernel.org, linux-...@vger.kernel.org, linu...@vger.kernel.org, syzkall...@googlegroups.com, vi...@zeniv.linux.org.uk
Hello,

syzbot found the following issue on:

HEAD commit: 861deac3b092 Linux 6.7-rc7
git tree: upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=155d9131e80000
kernel config: https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=09b349b3066c2e0b1e96
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=16cefdc9e80000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=164fe7e9e80000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0ea60ee8ed32/disk-861deac3.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/6d69fdc33021/vmlinux-861deac3.xz
kernel image: https://storage.googleapis.com/syzbot-assets/f0158750d452/bzImage-861deac3.xz
mounted in repro: https://storage.googleapis.com/syzbot-assets/bb450f076a10/mount_0.gz

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: syzbot+09b349...@syzkaller.appspotmail.com

option from the mount to silence this warning.
=======================================================
=====================================================
BUG: KMSAN: kernel-infoleak in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak in _copy_to_user+0xbc/0x100 lib/usercopy.c:40
instrument_copy_to_user include/linux/instrumented.h:114 [inline]
_copy_to_user+0xbc/0x100 lib/usercopy.c:40
copy_to_user include/linux/uaccess.h:191 [inline]
do_sys_name_to_handle fs/fhandle.c:73 [inline]
__do_sys_name_to_handle_at fs/fhandle.c:112 [inline]
__se_sys_name_to_handle_at+0x949/0xb10 fs/fhandle.c:94
__x64_sys_name_to_handle_at+0xe4/0x140 fs/fhandle.c:94
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was created at:
slab_post_alloc_hook+0x129/0xa70 mm/slab.h:768
slab_alloc_node mm/slub.c:3478 [inline]
__kmem_cache_alloc_node+0x5c9/0x970 mm/slub.c:3517
__do_kmalloc_node mm/slab_common.c:1006 [inline]
__kmalloc+0x121/0x3c0 mm/slab_common.c:1020
kmalloc include/linux/slab.h:604 [inline]
do_sys_name_to_handle fs/fhandle.c:39 [inline]
__do_sys_name_to_handle_at fs/fhandle.c:112 [inline]
__se_sys_name_to_handle_at+0x441/0xb10 fs/fhandle.c:94
__x64_sys_name_to_handle_at+0xe4/0x140 fs/fhandle.c:94
do_syscall_x64 arch/x86/entry/common.c:52 [inline]
do_syscall_64+0x44/0x110 arch/x86/entry/common.c:83
entry_SYSCALL_64_after_hwframe+0x63/0x6b

Bytes 18-19 of 20 are uninitialized
Memory access of size 20 starts at ffff888128a46380
Data copied to user address 0000000020000240

CPU: 0 PID: 5006 Comm: syz-executor975 Not tainted 6.7.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


---
This report is generated by a bot. It may contain errors.
See https://goo.gl/tpsmEJ for more information about syzbot.
syzbot engineers can be reached at syzk...@googlegroups.com.

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.

If the report is already addressed, let syzbot know by replying with:
#syz fix: exact-commit-title

If you want syzbot to run the reproducer, reply with:
#syz test: git://repo/address.git branch-or-commit-hash
If you attach or paste a git patch, syzbot will apply it before testing.

If you want to overwrite report's subsystems, reply with:
#syz set subsystems: new-subsystem
(See the list of subsystem names on the web dashboard)

If the report is a duplicate of another one, reply with:
#syz dup: exact-subject-of-another-report

If you want to undo deduplication, reply with:
#syz undup

Chuck Lever III

unread,
Jan 16, 2024, 10:11:56 AMJan 16
to Amir Goldstein, syzbot, Christian Brauner, Jeff Layton, linux-fsdevel, Linux Kernel Mailing List, Linux NFS Mailing List, syzkall...@googlegroups.com, Al Viro
Hi Amir-

The kmalloc() at fs/fhandle.c:39 could be made a kzalloc().

But I wonder if those uninitialized bytes in the file_handle
buffer are actually a logic bug in do_sys_name_to_handle().


--
Chuck Lever


Amir Goldstein

unread,
Jan 16, 2024, 12:21:13 PMJan 16
to Chuck Lever III, syzbot, Christian Brauner, Jeff Layton, linux-fsdevel, Linux Kernel Mailing List, Linux NFS Mailing List, syzkall...@googlegroups.com, Al Viro
I am not sure I understand from the report which bytes are not initialized.
If it's the bytes of the opaque f_handle, then it sounds like a
filesystem (nilfs) bug.

Thanks,
Amir.

Nikita Zhandarovich

unread,
Jan 18, 2024, 11:45:50 AMJan 18
to syzbot+09b349...@syzkaller.appspotmail.com, Nikita Zhandarovich, syzkall...@googlegroups.com
Try using kzalloc() instead of kmalloc() in do_sys_name_to_handle()

#syz test: https://github.com/google/kmsan.git master

---
fs/fhandle.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/fs/fhandle.c b/fs/fhandle.c
index 18b3ba8dc8ea..57a12614addf 100644
--- a/fs/fhandle.c
+++ b/fs/fhandle.c
@@ -36,7 +36,7 @@ static long do_sys_name_to_handle(const struct path *path,
if (f_handle.handle_bytes > MAX_HANDLE_SZ)
return -EINVAL;

- handle = kmalloc(sizeof(struct file_handle) + f_handle.handle_bytes,
+ handle = kzalloc(sizeof(struct file_handle) + f_handle.handle_bytes,
GFP_KERNEL);
if (!handle)
return -ENOMEM;
--
2.25.1

syzbot

unread,
Jan 18, 2024, 12:12:06 PMJan 18
to gli...@google.com, linux-...@vger.kernel.org, n.zhand...@fintech.ru, syzkall...@googlegroups.com
Hello,

syzbot has tested the proposed patch and the reproducer did not trigger any issue:

Reported-and-tested-by: syzbot+09b349...@syzkaller.appspotmail.com

Tested on:

commit: d1d7f15c DO-NOT-SUBMIT: kmsan: add the kmsan_exceed_ma..
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=125bb51be80000
kernel config: https://syzkaller.appspot.com/x/.config?x=4778da307461370c
dashboard link: https://syzkaller.appspot.com/bug?extid=09b349b3066c2e0b1e96
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch: https://syzkaller.appspot.com/x/patch.diff?x=10f39bfbe80000

Note: testing is done by a robot and is best-effort only.
Reply all
Reply to author
Forward
0 new messages