2021-01-10 10:22:33

by syzbot

[permalink] [raw]
Subject: KMSAN: kernel-infoleak in move_addr_to_user (4)

Hello,

syzbot found the following issue on:

HEAD commit: 73d62e81 kmsan: random: prevent boot-time reports in _mix_..
git tree: https://github.com/google/kmsan.git master
console output: https://syzkaller.appspot.com/x/log.txt?x=15c8b8c7500000
kernel config: https://syzkaller.appspot.com/x/.config?x=2cdf4151c9653e32
dashboard link: https://syzkaller.appspot.com/bug?extid=057884e2f453e8afebc8
compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project.git ca2dcbd030eadbf0aa9b660efe864ff08af6e18b)
syz repro: https://syzkaller.appspot.com/x/repro.syz?x=101520c7500000
C reproducer: https://syzkaller.appspot.com/x/repro.c?x=100b8f4f500000

IMPORTANT: if you fix the issue, please add the following tag to the commit:
Reported-by: [email protected]

=====================================================
BUG: KMSAN: kernel-infoleak in kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
CPU: 0 PID: 8245 Comm: syz-executor868 Not tainted 5.10.0-rc4-syzkaller #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
Call Trace:
__dump_stack lib/dump_stack.c:77 [inline]
dump_stack+0x21c/0x280 lib/dump_stack.c:118
kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
kmsan_internal_check_memory+0x202/0x520 mm/kmsan/kmsan.c:402
kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
instrument_copy_to_user include/linux/instrumented.h:121 [inline]
_copy_to_user+0x1af/0x270 lib/usercopy.c:33
copy_to_user include/linux/uaccess.h:209 [inline]
move_addr_to_user+0x3a2/0x640 net/socket.c:237
__sys_getsockname+0x407/0x5d0 net/socket.c:1906
__do_sys_getsockname net/socket.c:1917 [inline]
__se_sys_getsockname+0x91/0xb0 net/socket.c:1914
__x64_sys_getsockname+0x4a/0x70 net/socket.c:1914
do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48
entry_SYSCALL_64_after_hwframe+0x44/0xa9
RIP: 0033:0x441219
Code: e8 fc ab 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 1b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
RSP: 002b:00007ffe3c24eaf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000033
RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441219
RDX: 0000000020000000 RSI: 0000000020000100 RDI: 0000000000000003
RBP: 00000000006cb018 R08: 00000000004002c8 R09: 00000000004002c8
R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000401fc0
R13: 0000000000402050 R14: 0000000000000000 R15: 0000000000000000

Local variable ----address@__sys_getsockname created at:
__sys_getsockname+0x91/0x5d0 net/socket.c:1891
__sys_getsockname+0x91/0x5d0 net/socket.c:1891

Bytes 2-3 of 20 are uninitialized
Memory access of size 20 starts at ffff888124bbbdf0
Data copied to user address 0000000020000100
=====================================================


---
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 [email protected].

syzbot will keep track of this issue. See:
https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
syzbot can test patches for this issue, for details see:
https://goo.gl/tpsmEJ#testing-patches


2021-01-11 19:35:08

by Jakub Kicinski

[permalink] [raw]
Subject: Re: KMSAN: kernel-infoleak in move_addr_to_user (4)

Looks like a AF_CAN socket:

r0 = socket(0x1d, 0x2, 0x6)
getsockname$packet(r0, &(0x7f0000000100)={0x11, 0x0, 0x0, 0x1, 0x0, 0x6, @broadcast}, &(0x7f0000000000)=0x14)


On Sun, 10 Jan 2021 02:19:15 -0800 syzbot wrote:
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: 73d62e81 kmsan: random: prevent boot-time reports in _mix_..
> git tree: https://github.com/google/kmsan.git master
> console output: https://syzkaller.appspot.com/x/log.txt?x=15c8b8c7500000
> kernel config: https://syzkaller.appspot.com/x/.config?x=2cdf4151c9653e32
> dashboard link: https://syzkaller.appspot.com/bug?extid=057884e2f453e8afebc8
> compiler: clang version 11.0.0 (https://github.com/llvm/llvm-project.git ca2dcbd030eadbf0aa9b660efe864ff08af6e18b)
> syz repro: https://syzkaller.appspot.com/x/repro.syz?x=101520c7500000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=100b8f4f500000
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: [email protected]
>
> =====================================================
> BUG: KMSAN: kernel-infoleak in kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
> CPU: 0 PID: 8245 Comm: syz-executor868 Not tainted 5.10.0-rc4-syzkaller #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011
> Call Trace:
> __dump_stack lib/dump_stack.c:77 [inline]
> dump_stack+0x21c/0x280 lib/dump_stack.c:118
> kmsan_report+0xf7/0x1e0 mm/kmsan/kmsan_report.c:118
> kmsan_internal_check_memory+0x202/0x520 mm/kmsan/kmsan.c:402
> kmsan_copy_to_user+0x9c/0xb0 mm/kmsan/kmsan_hooks.c:249
> instrument_copy_to_user include/linux/instrumented.h:121 [inline]
> _copy_to_user+0x1af/0x270 lib/usercopy.c:33
> copy_to_user include/linux/uaccess.h:209 [inline]
> move_addr_to_user+0x3a2/0x640 net/socket.c:237
> __sys_getsockname+0x407/0x5d0 net/socket.c:1906
> __do_sys_getsockname net/socket.c:1917 [inline]
> __se_sys_getsockname+0x91/0xb0 net/socket.c:1914
> __x64_sys_getsockname+0x4a/0x70 net/socket.c:1914
> do_syscall_64+0x9f/0x140 arch/x86/entry/common.c:48
> entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x441219
> Code: e8 fc ab 02 00 48 83 c4 18 c3 0f 1f 80 00 00 00 00 48 89 f8 48 89 f7 48 89 d6 48 89 ca 4d 89 c2 4d 89 c8 4c 8b 4c 24 08 0f 05 <48> 3d 01 f0 ff ff 0f 83 1b 09 fc ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:00007ffe3c24eaf8 EFLAGS: 00000246 ORIG_RAX: 0000000000000033
> RAX: ffffffffffffffda RBX: 0000000000000000 RCX: 0000000000441219
> RDX: 0000000020000000 RSI: 0000000020000100 RDI: 0000000000000003
> RBP: 00000000006cb018 R08: 00000000004002c8 R09: 00000000004002c8
> R10: 0000000000000004 R11: 0000000000000246 R12: 0000000000401fc0
> R13: 0000000000402050 R14: 0000000000000000 R15: 0000000000000000
>
> Local variable ----address@__sys_getsockname created at:
> __sys_getsockname+0x91/0x5d0 net/socket.c:1891
> __sys_getsockname+0x91/0x5d0 net/socket.c:1891
>
> Bytes 2-3 of 20 are uninitialized
> Memory access of size 20 starts at ffff888124bbbdf0
> Data copied to user address 0000000020000100
> =====================================================
>
>
> ---
> 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 [email protected].
>
> syzbot will keep track of this issue. See:
> https://goo.gl/tpsmEJ#status for how to communicate with syzbot.
> syzbot can test patches for this issue, for details see:
> https://goo.gl/tpsmEJ#testing-patches

2021-01-12 10:29:29

by Cong Wang

[permalink] [raw]
Subject: Re: KMSAN: kernel-infoleak in move_addr_to_user (4)

On Mon, Jan 11, 2021 at 11:33 AM Jakub Kicinski <[email protected]> wrote:
>
> Looks like a AF_CAN socket:
>
> r0 = socket(0x1d, 0x2, 0x6)
> getsockname$packet(r0, &(0x7f0000000100)={0x11, 0x0, 0x0, 0x1, 0x0, 0x6, @broadcast}, &(0x7f0000000000)=0x14)
>

Right, it seems we need a memset(0) in isotp_getname().

Thanks.

2021-01-12 12:21:29

by Oliver Hartkopp

[permalink] [raw]
Subject: Re: KMSAN: kernel-infoleak in move_addr_to_user (4)



On 12.01.21 01:17, Cong Wang wrote:
> On Mon, Jan 11, 2021 at 11:33 AM Jakub Kicinski <[email protected]> wrote:
>>
>> Looks like a AF_CAN socket:
>>
>> r0 = socket(0x1d, 0x2, 0x6)
>> getsockname$packet(r0, &(0x7f0000000100)={0x11, 0x0, 0x0, 0x1, 0x0, 0x6, @broadcast}, &(0x7f0000000000)=0x14)
>>
>
> Right, it seems we need a memset(0) in isotp_getname().

Yes m(

Sent a patch to fix it:

https://lore.kernel.org/linux-can/[email protected]/T/#u

Many thanks!

Oliver