All of lore.kernel.org
 help / color / mirror / Atom feed
* [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
@ 2023-10-21 18:49 syzbot
  2023-12-25 22:15 ` syzbot
  2024-03-24  9:13 ` [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
  0 siblings, 2 replies; 7+ messages in thread
From: syzbot @ 2023-10-21 18:49 UTC (permalink / raw)
  To: linux-kernel, luto, peterz, syzkaller-bugs, tglx

Hello,

syzbot found the following issue on:

HEAD commit:    dd72f9c7e512 Merge tag 'spi-fix-v6-6-rc4' of git://git.ker..
git tree:       upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=15fd7ae5680000
kernel config:  https://syzkaller.appspot.com/x/.config?x=3f3af4cd712401d4
dashboard link: https://syzkaller.appspot.com/bug?extid=cfc08744435c4cf94a40
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
userspace arch: i386

Unfortunately, I don't have any reproducer for this issue yet.

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/70e48b37a929/disk-dd72f9c7.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/60aeb36b39dc/vmlinux-dd72f9c7.xz
kernel image: https://storage.googleapis.com/syzbot-assets/71699a83a138/bzImage-dd72f9c7.xz

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

=====================================================
BUG: KMSAN: kernel-infoleak-after-free in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak-after-free 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]
 copy_siginfo_to_user+0x40/0x130 kernel/signal.c:3362
 x64_setup_rt_frame+0x1e74/0x2400 arch/x86/kernel/signal_64.c:197
 setup_rt_frame arch/x86/kernel/signal.c:222 [inline]
 handle_signal arch/x86/kernel/signal.c:266 [inline]
 arch_do_signal_or_restart+0x626/0xca0 arch/x86/kernel/signal.c:311
 exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x2a/0x140 kernel/entry/common.c:296
 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Uninit was stored to memory at:
 copy_siginfo include/linux/signal.h:17 [inline]
 collect_signal kernel/signal.c:596 [inline]
 __dequeue_signal+0x548/0xa00 kernel/signal.c:625
 dequeue_signal+0x14b/0xb10 kernel/signal.c:648
 get_signal+0xc3f/0x2d10 kernel/signal.c:2772
 arch_do_signal_or_restart+0x53/0xca0 arch/x86/kernel/signal.c:309
 exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x2a/0x140 kernel/entry/common.c:296
 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Uninit was created at:
 slab_free_hook mm/slub.c:1770 [inline]
 slab_free_freelist_hook mm/slub.c:1826 [inline]
 slab_free mm/slub.c:3809 [inline]
 kmem_cache_free+0x670/0x12a0 mm/slub.c:3831
 __sigqueue_free kernel/signal.c:460 [inline]
 collect_signal kernel/signal.c:603 [inline]
 __dequeue_signal+0x998/0xa00 kernel/signal.c:625
 dequeue_signal+0x14b/0xb10 kernel/signal.c:648
 get_signal+0xc3f/0x2d10 kernel/signal.c:2772
 arch_do_signal_or_restart+0x53/0xca0 arch/x86/kernel/signal.c:309
 exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x2a/0x140 kernel/entry/common.c:296
 do_syscall_64+0x4d/0xc0 arch/x86/entry/common.c:86
 entry_SYSCALL_64_after_hwframe+0x63/0xcd

Bytes 12-15 of 48 are uninitialized
Memory access of size 48 starts at ffff88801301fdb0
Data copied to user address 000000c000e7bbf0

CPU: 0 PID: 5011 Comm: syz-fuzzer Not tainted 6.6.0-rc6-syzkaller-00043-gdd72f9c7e512 #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 09/06/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 syzkaller@googlegroups.com.

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

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

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

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

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

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

* Re: [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
  2023-10-21 18:49 [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
@ 2023-12-25 22:15 ` syzbot
  2023-12-31  1:51   ` Edward Adam Davis
  2023-12-31  2:41   ` [PATCH] ptrace: fix kernel-infoleak-after-free in copy_siginfo_to_user Edward Adam Davis
  2024-03-24  9:13 ` [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
  1 sibling, 2 replies; 7+ messages in thread
From: syzbot @ 2023-12-25 22:15 UTC (permalink / raw)
  To: linux-kernel, luto, peterz, syzkaller-bugs, tglx, xrivendell7

syzbot has found a reproducer for the following issue on:

HEAD commit:    861deac3b092 Linux 6.7-rc7
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=15826ec9e80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=cfc08744435c4cf94a40
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=17ea5231e80000

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

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

=====================================================
BUG: KMSAN: kernel-infoleak-after-free in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak-after-free 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]
 copy_siginfo_to_user+0x40/0x130 kernel/signal.c:3374
 ptrace_request+0xfa6/0x36d0 kernel/ptrace.c:1066
 arch_ptrace+0x435/0x680 arch/x86/kernel/ptrace.c:848
 __do_sys_ptrace kernel/ptrace.c:1305 [inline]
 __se_sys_ptrace+0x2d8/0x750 kernel/ptrace.c:1278
 __x64_sys_ptrace+0xbd/0x110 kernel/ptrace.c:1278
 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 stored to memory at:
 copy_siginfo include/linux/signal.h:17 [inline]
 ptrace_getsiginfo kernel/ptrace.c:705 [inline]
 ptrace_request+0xf32/0x36d0 kernel/ptrace.c:1064
 arch_ptrace+0x435/0x680 arch/x86/kernel/ptrace.c:848
 __do_sys_ptrace kernel/ptrace.c:1305 [inline]
 __se_sys_ptrace+0x2d8/0x750 kernel/ptrace.c:1278
 __x64_sys_ptrace+0xbd/0x110 kernel/ptrace.c:1278
 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 stored to memory at:
 copy_siginfo include/linux/signal.h:17 [inline]
 collect_signal kernel/signal.c:596 [inline]
 __dequeue_signal+0x548/0xa00 kernel/signal.c:625
 dequeue_signal+0x14b/0xb10 kernel/signal.c:648
 get_signal+0xc3f/0x2d10 kernel/signal.c:2784
 arch_do_signal_or_restart+0x53/0xca0 arch/x86/kernel/signal.c:309
 exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x2a/0x140 kernel/entry/common.c:296
 do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Uninit was created at:
 slab_free_hook mm/slub.c:1770 [inline]
 slab_free_freelist_hook mm/slub.c:1826 [inline]
 slab_free mm/slub.c:3809 [inline]
 kmem_cache_free+0x66f/0x1250 mm/slub.c:3831
 __sigqueue_free kernel/signal.c:460 [inline]
 collect_signal kernel/signal.c:603 [inline]
 __dequeue_signal+0x998/0xa00 kernel/signal.c:625
 dequeue_signal+0x14b/0xb10 kernel/signal.c:648
 get_signal+0xc3f/0x2d10 kernel/signal.c:2784
 arch_do_signal_or_restart+0x53/0xca0 arch/x86/kernel/signal.c:309
 exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
 exit_to_user_mode_prepare+0x163/0x220 kernel/entry/common.c:204
 __syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
 syscall_exit_to_user_mode+0x2a/0x140 kernel/entry/common.c:296
 do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x63/0x6b

Bytes 12-15 of 48 are uninitialized
Memory access of size 48 starts at ffff888115d6bc80
Data copied to user address 00000000016164e0

CPU: 1 PID: 5004 Comm: strace-static-x Not tainted 6.7.0-rc7-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 11/17/2023
=====================================================


---
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.

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

* Re: [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
  2023-12-25 22:15 ` syzbot
@ 2023-12-31  1:51   ` Edward Adam Davis
  2023-12-31  2:15     ` syzbot
  2023-12-31  2:41   ` [PATCH] ptrace: fix kernel-infoleak-after-free in copy_siginfo_to_user Edward Adam Davis
  1 sibling, 1 reply; 7+ messages in thread
From: Edward Adam Davis @ 2023-12-31  1:51 UTC (permalink / raw)
  To: syzbot+cfc08744435c4cf94a40; +Cc: linux-kernel, syzkaller-bugs

please test kernel-infoleak-after-free in copy_siginfo_to_user

#syz test https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git 861deac3b092

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d8b5e13a2229..8bd346b10c6e 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1033,7 +1033,7 @@ int ptrace_request(struct task_struct *child, long request,
 {
 	bool seized = child->ptrace & PT_SEIZED;
 	int ret = -EIO;
-	kernel_siginfo_t siginfo, *si;
+	kernel_siginfo_t siginfo, *si, *psiginfo;
 	void __user *datavp = (void __user *) data;
 	unsigned long __user *datalp = datavp;
 	unsigned long flags;
@@ -1061,9 +1061,13 @@ int ptrace_request(struct task_struct *child, long request,
 		break;
 
 	case PTRACE_GETSIGINFO:
-		ret = ptrace_getsiginfo(child, &siginfo);
+		psiginfo = kvmalloc(sizeof(kernel_siginfo_t), GFP_KERNEL);
+		if (!psiginfo)
+			break;
+		ret = ptrace_getsiginfo(child, psiginfo);
 		if (!ret)
-			ret = copy_siginfo_to_user(datavp, &siginfo);
+			ret = copy_siginfo_to_user(datavp, psiginfo);
+		kvfree(psiginfo);
 		break;
 
 	case PTRACE_SETSIGINFO:


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

* Re: [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
  2023-12-31  1:51   ` Edward Adam Davis
@ 2023-12-31  2:15     ` syzbot
  0 siblings, 0 replies; 7+ messages in thread
From: syzbot @ 2023-12-31  2:15 UTC (permalink / raw)
  To: eadavis, linux-kernel, syzkaller-bugs

Hello,

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

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

Tested on:

commit:         861deac3 Linux 6.7-rc7
git tree:       https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
console output: https://syzkaller.appspot.com/x/log.txt?x=13c1bf11e80000
kernel config:  https://syzkaller.appspot.com/x/.config?x=e0c7078a6b901aa3
dashboard link: https://syzkaller.appspot.com/bug?extid=cfc08744435c4cf94a40
compiler:       Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40
patch:          https://syzkaller.appspot.com/x/patch.diff?x=13310ef9e80000

Note: testing is done by a robot and is best-effort only.

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

* [PATCH] ptrace: fix kernel-infoleak-after-free in  copy_siginfo_to_user
  2023-12-25 22:15 ` syzbot
  2023-12-31  1:51   ` Edward Adam Davis
@ 2023-12-31  2:41   ` Edward Adam Davis
  1 sibling, 0 replies; 7+ messages in thread
From: Edward Adam Davis @ 2023-12-31  2:41 UTC (permalink / raw)
  To: syzbot+cfc08744435c4cf94a40
  Cc: linux-kernel, luto, peterz, syzkaller-bugs, tglx, xrivendell7

To avoid kernel memory leakage into user space, memory should be manually 
allocated instead of using memory from the kernel stack.

Reported-and-tested-by: syzbot+cfc08744435c4cf94a40@syzkaller.appspotmail.com
Signed-off-by: Edward Adam Davis <eadavis@qq.com>
---
 kernel/ptrace.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/kernel/ptrace.c b/kernel/ptrace.c
index d8b5e13a2229..8bd346b10c6e 100644
--- a/kernel/ptrace.c
+++ b/kernel/ptrace.c
@@ -1033,7 +1033,7 @@ int ptrace_request(struct task_struct *child, long request,
 {
 	bool seized = child->ptrace & PT_SEIZED;
 	int ret = -EIO;
-	kernel_siginfo_t siginfo, *si;
+	kernel_siginfo_t siginfo, *si, *psiginfo;
 	void __user *datavp = (void __user *) data;
 	unsigned long __user *datalp = datavp;
 	unsigned long flags;
@@ -1061,9 +1061,13 @@ int ptrace_request(struct task_struct *child, long request,
 		break;
 
 	case PTRACE_GETSIGINFO:
-		ret = ptrace_getsiginfo(child, &siginfo);
+		psiginfo = kvmalloc(sizeof(kernel_siginfo_t), GFP_KERNEL);
+		if (!psiginfo)
+			break;
+		ret = ptrace_getsiginfo(child, psiginfo);
 		if (!ret)
-			ret = copy_siginfo_to_user(datavp, &siginfo);
+			ret = copy_siginfo_to_user(datavp, psiginfo);
+		kvfree(psiginfo);
 		break;
 
 	case PTRACE_SETSIGINFO:
-- 
2.43.0


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

* Re: [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
  2023-10-21 18:49 [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
  2023-12-25 22:15 ` syzbot
@ 2024-03-24  9:13 ` syzbot
  1 sibling, 0 replies; 7+ messages in thread
From: syzbot @ 2024-03-24  9:13 UTC (permalink / raw)
  To: eadavis, linux-kernel, luto, peterz, syzkaller-bugs, tglx, xrivendell7

syzbot has found a reproducer for the following issue on:

HEAD commit:    70293240c5ce Merge tag 'timers-urgent-2024-03-23' of git:/..
git tree:       upstream
console+strace: https://syzkaller.appspot.com/x/log.txt?x=139071be180000
kernel config:  https://syzkaller.appspot.com/x/.config?x=e6bd769cb793b98a
dashboard link: https://syzkaller.appspot.com/bug?extid=cfc08744435c4cf94a40
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=14694231180000
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=15846fc1180000

Downloadable assets:
disk image: https://storage.googleapis.com/syzbot-assets/0de52742d0b8/disk-70293240.raw.xz
vmlinux: https://storage.googleapis.com/syzbot-assets/f304697881bf/vmlinux-70293240.xz
kernel image: https://storage.googleapis.com/syzbot-assets/2b9d8a9376f0/bzImage-70293240.xz

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

=====================================================
BUG: KMSAN: kernel-infoleak-after-free in instrument_copy_to_user include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak-after-free in _copy_to_user+0xbc/0x110 lib/usercopy.c:40
 instrument_copy_to_user include/linux/instrumented.h:114 [inline]
 _copy_to_user+0xbc/0x110 lib/usercopy.c:40
 copy_to_user include/linux/uaccess.h:191 [inline]
 copy_siginfo_to_user+0x40/0x130 kernel/signal.c:3380
 ptrace_request+0xfa7/0x36e0 kernel/ptrace.c:1046
 arch_ptrace+0x43b/0x680 arch/x86/kernel/ptrace.c:848
 __do_sys_ptrace kernel/ptrace.c:1285 [inline]
 __se_sys_ptrace+0x2d8/0x760 kernel/ptrace.c:1258
 __x64_sys_ptrace+0xbd/0x110 kernel/ptrace.c:1258
 do_syscall_64+0xd5/0x1f0
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
 copy_siginfo include/linux/signal.h:18 [inline]
 ptrace_getsiginfo kernel/ptrace.c:685 [inline]
 ptrace_request+0xf33/0x36e0 kernel/ptrace.c:1044
 arch_ptrace+0x43b/0x680 arch/x86/kernel/ptrace.c:848
 __do_sys_ptrace kernel/ptrace.c:1285 [inline]
 __se_sys_ptrace+0x2d8/0x760 kernel/ptrace.c:1258
 __x64_sys_ptrace+0xbd/0x110 kernel/ptrace.c:1258
 do_syscall_64+0xd5/0x1f0
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was stored to memory at:
 copy_siginfo include/linux/signal.h:18 [inline]
 collect_signal kernel/signal.c:587 [inline]
 __dequeue_signal+0x501/0xad0 kernel/signal.c:616
 dequeue_signal+0x14b/0xb20 kernel/signal.c:639
 get_signal+0xb46/0x2d00 kernel/signal.c:2790
 arch_do_signal_or_restart+0x53/0xcb0 arch/x86/kernel/signal.c:310
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x5d/0x160 kernel/entry/common.c:218
 do_syscall_64+0xe4/0x1f0 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Uninit was created at:
 slab_free_hook mm/slub.c:2073 [inline]
 slab_free mm/slub.c:4280 [inline]
 kmem_cache_free+0x257/0xa80 mm/slub.c:4344
 __sigqueue_free kernel/signal.c:451 [inline]
 collect_signal kernel/signal.c:594 [inline]
 __dequeue_signal+0xa58/0xad0 kernel/signal.c:616
 dequeue_signal+0x14b/0xb20 kernel/signal.c:639
 get_signal+0xb46/0x2d00 kernel/signal.c:2790
 arch_do_signal_or_restart+0x53/0xcb0 arch/x86/kernel/signal.c:310
 exit_to_user_mode_loop kernel/entry/common.c:111 [inline]
 exit_to_user_mode_prepare include/linux/entry-common.h:328 [inline]
 __syscall_exit_to_user_mode_work kernel/entry/common.c:207 [inline]
 syscall_exit_to_user_mode+0x5d/0x160 kernel/entry/common.c:218
 do_syscall_64+0xe4/0x1f0 arch/x86/entry/common.c:89
 entry_SYSCALL_64_after_hwframe+0x6d/0x75

Bytes 12-15 of 48 are uninitialized
Memory access of size 48 starts at ffff8881240cfc60
Data copied to user address 0000000014dcf540

CPU: 1 PID: 5012 Comm: strace-static-x Not tainted 6.8.0-syzkaller-13213-g70293240c5ce #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 02/29/2024
=====================================================


---
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.

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

* Re: [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2)
@ 2023-12-25  7:16 xingwei lee
  0 siblings, 0 replies; 7+ messages in thread
From: xingwei lee @ 2023-12-25  7:16 UTC (permalink / raw)
  To: syzbot+cfc08744435c4cf94a40
  Cc: linux-kernel, luto, peterz, syzkaller-bugs, Thomas Gleixner

Hello, I reproduced this bug and comfired in the latest net tree.

If you fix this issue, please add the following tag to the commit:
Reported-by: xingwei lee <xrivendell7@gmail.com>

kernel version: net 7c5e046bdcb2513f9decb3765d8bf92d604279cf
kernel config: https://syzkaller.appspot.com/text?tag=KernelConfig&x=4a65fa9f077ead01
with KMSAN enabled
compiler: Debian clang version 15.0.6, GNU ld (GNU Binutils for Debian) 2.40

syzkaller login: root
Linux syzkaller 6.7.0-rc6-00157-g7c5e046bdcb2 #9 SMP PREEMPT_DYNAMIC
Sat Dec 23 16:03:42 CST 2023 x86_64
The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.
Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.
Last login: Mon Dec 25 01:57:49 UTC 2023 on ttyS0

root@syzkaller:~/linux_amd64# ./syz-execprog -repeat 0 ../f64.txt
BUG: KMSAN: kernel-infoleak-after-free in instrument_copy_to_user
include/linux/instrumented.h:114 [inline]
BUG: KMSAN: kernel-infoleak-after-free in _copy_to_user+0xbf/0x110
lib/usercopy.c:40
instrument_copy_to_user include/linux/instrumented.h:114 [inline]
_copy_to_user+0xbf/0x110 lib/usercopy.c:40
copy_to_user include/linux/uaccess.h:191 [inline]
copy_siginfo_to_user+0x40/0x120 kernel/signal.c:3374
x64_setup_rt_frame+0x1e4b/0x2400 arch/x86/kernel/signal_64.c:194
setup_rt_frame arch/x86/kernel/signal.c:222 [inline]
handle_signal arch/x86/kernel/signal.c:266 [inline]
arch_do_signal_or_restart+0x616/0xc90 arch/x86/kernel/signal.c:311
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Uninit was stored to memory at:
copy_siginfo include/linux/signal.h:17 [inline]
collect_signal kernel/signal.c:596 [inline]
__dequeue_signal+0x52e/0x9f0 kernel/signal.c:625
dequeue_signal+0x15a/0xb40 kernel/signal.c:648
get_signal+0xbd0/0x2c50 kernel/signal.c:2784
arch_do_signal_or_restart+0x53/0xc90 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Uninit was created at:
slab_free_hook mm/slub.c:1770 [inline]
slab_free_freelist_hook mm/slub.c:1826 [inline]
slab_free mm/slub.c:3809 [inline]
kmem_cache_free+0x63b/0x1270 mm/slub.c:3831
__sigqueue_free kernel/signal.c:460 [inline]
collect_signal kernel/signal.c:603 [inline]
__dequeue_signal+0x8e7/0x9f0 kernel/signal.c:625
dequeue_signal+0x15a/0xb40 kernel/signal.c:648
get_signal+0xbd0/0x2c50 kernel/signal.c:2784
arch_do_signal_or_restart+0x53/0xc90 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Bytes 12-15 of 48 are uninitialized
Memory access of size 48 starts at ffff888038b73dc0
Data copied to user address 000000c0013875b0
CPU: 3 PID: 8170 Comm: syz-execprog Not tainted 6.7.0-rc6-00157-g7c5e046bdcb2 #9
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.16.2-1.fc38 04/01/2014
=====================================================
instrument_copy_to_user include/linux/instrumented.h:114 [inline]
_copy_to_user+0xbf/0x110 lib/usercopy.c:40
copy_to_user include/linux/uaccess.h:191 [inline]
copy_siginfo_to_user+0x40/0x120 kernel/signal.c:3374
x64_setup_rt_frame+0x1e4b/0x2400 arch/x86/kernel/signal_64.c:194
setup_rt_frame arch/x86/kernel/signal.c:222 [inline]
handle_signal arch/x86/kernel/signal.c:266 [inline]
arch_do_signal_or_restart+0x616/0xc90 arch/x86/kernel/signal.c:311
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Uninit was stored to memory at:
copy_siginfo include/linux/signal.h:17 [inline]
collect_signal kernel/signal.c:596 [inline]
__dequeue_signal+0x52e/0x9f0 kernel/signal.c:625
dequeue_signal+0x15a/0xb40 kernel/signal.c:648
get_signal+0xbd0/0x2c50 kernel/signal.c:2784
arch_do_signal_or_restart+0x53/0xc90 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Uninit was created at:
slab_free_hook mm/slub.c:1770 [inline]
slab_free_freelist_hook mm/slub.c:1826 [inline]
slab_free mm/slub.c:3809 [inline]
kmem_cache_free+0x63b/0x1270 mm/slub.c:3831
__sigqueue_free kernel/signal.c:460 [inline]
collect_signal kernel/signal.c:603 [inline]
__dequeue_signal+0x8e7/0x9f0 kernel/signal.c:625
dequeue_signal+0x15a/0xb40 kernel/signal.c:648
get_signal+0xbd0/0x2c50 kernel/signal.c:2784
arch_do_signal_or_restart+0x53/0xc90 arch/x86/kernel/signal.c:309
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
Bytes 12-15 of 48 are uninitialized
Memory access of size 48 starts at ffff888038b73dc0
Data copied to user address 000000c0013875b0
CPU: 3 PID: 8170 Comm: syz-execprog Not tainted 6.7.0-rc6-00157-g7c5e046bdcb2 #9
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.16.2-1.fc38 04/01/2014
=====================================================
Disabling lock debugging due to kernel taint
Kernel panic - not syncing: kmsan.panic set ...
CPU: 3 PID: 8170 Comm: syz-execprog Tainted: G B
6.7.0-rc6-00157-g7c5e046bdcb2 #9
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS
1.16.2-1.fc38 04/01/2014
Call Trace:
<TASK>
__dump_stack lib/dump_stack.c:88 [inline]
dump_stack_lvl+0x1af/0x230 lib/dump_stack.c:106
dump_stack+0x1e/0x20 lib/dump_stack.c:113
panic+0x4d6/0xc60 kernel/panic.c:344
kmsan_report+0x2d7/0x2e0 mm/kmsan/report.c:216
kmsan_internal_check_memory+0x1ad/0x530 mm/kmsan/core.c:291
kmsan_copy_to_user+0xd3/0xf0 mm/kmsan/hooks.c:272
instrument_copy_to_user include/linux/instrumented.h:114 [inline]
_copy_to_user+0xbf/0x110 lib/usercopy.c:40
copy_to_user include/linux/uaccess.h:191 [inline]
copy_siginfo_to_user+0x40/0x120 kernel/signal.c:3374
x64_setup_rt_frame+0x1e4b/0x2400 arch/x86/kernel/signal_64.c:194
setup_rt_frame arch/x86/kernel/signal.c:222 [inline]
handle_signal arch/x86/kernel/signal.c:266 [inline]
arch_do_signal_or_restart+0x616/0xc90 arch/x86/kernel/signal.c:311
exit_to_user_mode_loop+0xe8/0x320 kernel/entry/common.c:168
exit_to_user_mode_prepare+0x167/0x220 kernel/entry/common.c:204
__syscall_exit_to_user_mode_work kernel/entry/common.c:285 [inline]
syscall_exit_to_user_mode+0x2b/0x150 kernel/entry/common.c:296
do_syscall_64+0x50/0x110 arch/x86/entry/common.c:89
entry_SYSCALL_64_after_hwframe+0x63/0x6b
RIP: 0033:0x46b981
Code: 89 44 24 20 c3 cc cc cc cc 48 8b 7c 24 08 8b 74 24 10 8b 54 24
14 4c 8b 54 24 18 4c 8b 44 24 2c
RSP: 002b:000000c00129def0 EFLAGS: 00000286
RAX: 00000000000000ca RBX: 0000000000000000 RCX: 000000000046b983
RDX: 0000000000000000 RSI: 0000000000000080 RDI: 0000000002030b58
RBP: 000000c00129df38 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000286 R12: 00000000004678e0
R13: 000000c00126e800 R14: 000000c00127e340 R15: 0000000000000001

Remember to run this repro.txt with the command: syz-execprog -repeat
0 ./repro.txt and wait for about 3-4minus, the bug triggered very
steady.

=* repro.txt =*
socket$inet_udplite(0x2, 0x2, 0x88)
socket$inet_udplite(0x2, 0x2, 0x88)
socket(0x10, 0x80002, 0x0)
r0 = bpf$BPF_PROG_RAW_TRACEPOINT_LOAD(0x5, &(0x7f0000000200)={0x18,
0x4, &(0x7f00000002c0)=ANY=[@ANYBLOB="180100001c00000000000000120000f1850000006d00000095"],
&(0x7f0000000000)='GPL\x00', 0x0, 0x0, 0x0, 0x0, 0x0, '\x00', 0x0,
0x2}, 0x90)
bpf$BPF_RAW_TRACEPOINT_OPEN(0x11,
&(0x7f0000001700)={&(0x7f0000001740)='hrtimer_expire_entry\x00', r0},
0x10)


and see also in
https://gist.github.com/xrivendell7/921e9e3bb7a4d2b8b291c0612781ce4d

I hope it helps.
Merry Christmas!
xingwei Lee

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

end of thread, other threads:[~2024-03-24  9:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-10-21 18:49 [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
2023-12-25 22:15 ` syzbot
2023-12-31  1:51   ` Edward Adam Davis
2023-12-31  2:15     ` syzbot
2023-12-31  2:41   ` [PATCH] ptrace: fix kernel-infoleak-after-free in copy_siginfo_to_user Edward Adam Davis
2024-03-24  9:13 ` [syzbot] [kernel?] KMSAN: kernel-infoleak-after-free in copy_siginfo_to_user (2) syzbot
2023-12-25  7:16 xingwei lee

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.