syzbot


BUG: bad usercopy in raw_getsockopt

Status: fixed on 2024/04/10 16:40
Subsystems: mm hardening
[Documentation on labels]
Reported-by: syzbot+0c35af046fa98c893c84@syzkaller.appspotmail.com
Fix commit: c8fba5d6df5e can: raw: fix getsockopt() for new CAN_RAW_XL_VCID_OPTS
First crash: 97d, last: 94d
Cause bisection: introduced by (bisect log) :
commit c83c22ec1493c0b7cc77327bedbd387e295872b6
Author: Oliver Hartkopp <socketcan@hartkopp.net>
Date: Mon Feb 12 21:35:50 2024 +0000

  can: canxl: add virtual CAN network identifier support

Crash: BUG: bad usercopy in raw_getsockopt (log)
Repro: C syz .config
  
Discussions (1)
Title Replies (including bot) Last reply
[syzbot] [mm?] [hardening?] BUG: bad usercopy in raw_getsockopt 2 (3) 2024/02/20 18:46

Sample crash report:
usercopy: Kernel memory exposure attempt detected from null address (offset 0, size 4)!
------------[ cut here ]------------
kernel BUG at mm/usercopy.c:102!
invalid opcode: 0000 [#1] PREEMPT SMP KASAN PTI
CPU: 1 PID: 5070 Comm: syz-executor201 Not tainted 6.8.0-rc4-syzkaller-01053-g74293ea1c4db #0
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/25/2024
RIP: 0010:usercopy_abort+0x84/0x90 mm/usercopy.c:102
Code: 49 89 ce 48 c7 c3 40 db b7 8b 48 0f 44 de 48 c7 c7 e0 d9 b7 8b 4c 89 de 48 89 c1 41 52 41 56 53 e8 01 c5 60 09 48 83 c4 18 90 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90003a3fc50 EFLAGS: 00010296
RAX: 0000000000000057 RBX: ffffffff8bb7db20 RCX: b071ef5fcc834300
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffffffffffffff R08: ffffffff81753e6c R09: 1ffff92000747f28
R10: dffffc0000000000 R11: fffff52000747f29 R12: 0000000000000001
R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000
FS:  0000555555f8e380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020001480 CR3: 000000001f404000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
 <TASK>
 __check_object_size+0x601/0xa00
 check_object_size include/linux/thread_info.h:215 [inline]
 check_copy_size include/linux/thread_info.h:251 [inline]
 copy_to_user include/linux/uaccess.h:190 [inline]
 raw_getsockopt+0x37a/0x490 net/can/raw.c:852
 do_sock_getsockopt+0x373/0x850 net/socket.c:2373
 __sys_getsockopt+0x270/0x330 net/socket.c:2402
 __do_sys_getsockopt net/socket.c:2412 [inline]
 __se_sys_getsockopt net/socket.c:2409 [inline]
 __x64_sys_getsockopt+0xb5/0xd0 net/socket.c:2409
 do_syscall_64+0xf9/0x240
 entry_SYSCALL_64_after_hwframe+0x6f/0x77
RIP: 0033:0x7f21bfe782a9
Code: 48 83 c4 28 c3 e8 37 17 00 00 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 73 01 c3 48 c7 c1 b8 ff ff ff f7 d8 64 89 01 48
RSP: 002b:00007ffcdfc8f038 EFLAGS: 00000246 ORIG_RAX: 0000000000000037
RAX: ffffffffffffffda RBX: 00007ffcdfc8f208 RCX: 00007f21bfe782a9
RDX: 0000000000000008 RSI: 0000000000000065 RDI: 0000000000000003
RBP: 00007f21bfeeb610 R08: 0000000020001480 R09: 00007ffcdfc8f208
R10: 0000000020001440 R11: 0000000000000246 R12: 0000000000000001
R13: 00007ffcdfc8f1f8 R14: 0000000000000001 R15: 0000000000000001
 </TASK>
Modules linked in:
---[ end trace 0000000000000000 ]---
RIP: 0010:usercopy_abort+0x84/0x90 mm/usercopy.c:102
Code: 49 89 ce 48 c7 c3 40 db b7 8b 48 0f 44 de 48 c7 c7 e0 d9 b7 8b 4c 89 de 48 89 c1 41 52 41 56 53 e8 01 c5 60 09 48 83 c4 18 90 <0f> 0b 66 2e 0f 1f 84 00 00 00 00 00 90 90 90 90 90 90 90 90 90 90
RSP: 0018:ffffc90003a3fc50 EFLAGS: 00010296
RAX: 0000000000000057 RBX: ffffffff8bb7db20 RCX: b071ef5fcc834300
RDX: 0000000000000000 RSI: 0000000080000000 RDI: 0000000000000000
RBP: ffffffffffffffff R08: ffffffff81753e6c R09: 1ffff92000747f28
R10: dffffc0000000000 R11: fffff52000747f29 R12: 0000000000000001
R13: 0000000000000004 R14: 0000000000000000 R15: 0000000000000000
FS:  0000555555f8e380(0000) GS:ffff8880b9500000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020001480 CR3: 000000001f404000 CR4: 00000000003506f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400

Crashes (4):
Time Kernel Commit Syzkaller Config Log Report Syz repro C repro VM info Assets (help?) Manager Title
2024/02/20 15:39 net-next 74293ea1c4db 3af7dd65 .config strace log report syz C [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce BUG: bad usercopy in raw_getsockopt
2024/02/20 15:24 net-next 74293ea1c4db 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci-upstream-net-kasan-gce BUG: bad usercopy in raw_getsockopt
2024/02/20 10:44 net-next 74293ea1c4db 3af7dd65 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce BUG: bad usercopy in raw_getsockopt
2024/02/18 05:35 net-next a6e0cb150c51 578f7538 .config console log report info [disk image] [vmlinux] [kernel image] ci2-upstream-net-next-test-gce BUG: bad usercopy in raw_getsockopt
* Struck through repros no longer work on HEAD.