Re: [syzbot] [bpf?] [trace?] general protection fault in bpf_get_attach_cookie_tracing

From: Andrii Nakryiko
Date: Tue May 07 2024 - 17:24:11 EST


On Sun, May 5, 2024 at 9:13 AM syzbot
<syzbot+3ab78ff125b7979e45f9@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit: a9e7715ce8b3 libbpf: Avoid casts from pointers to enums in..
> git tree: bpf-next
> console+strace: https://syzkaller.appspot.com/x/log.txt?x=153c1dc4980000
> kernel config: https://syzkaller.appspot.com/x/.config?x=e8aa3e4736485e94
> dashboard link: https://syzkaller.appspot.com/bug?extid=3ab78ff125b7979e45f9
> 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=17d4b588980000
> C reproducer: https://syzkaller.appspot.com/x/repro.c?x=16cb0470980000
>
> Downloadable assets:
> disk image: https://storage.googleapis.com/syzbot-assets/a6daa7801875/disk-a9e7715c.raw.xz
> vmlinux: https://storage.googleapis.com/syzbot-assets/0d5b51385a69/vmlinux-a9e7715c.xz
> kernel image: https://storage.googleapis.com/syzbot-assets/999297a08631/bzImage-a9e7715c.xz
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+3ab78ff125b7979e45f9@xxxxxxxxxxxxxxxxxxxxxxxxx
>
> general protection fault, probably for non-canonical address 0xdffffc0000000000: 0000 [#1] PREEMPT SMP KASAN PTI

I suspect it's the same issue that we already fixed ([0]) in
bpf/master, the fixes just haven't made it into bpf-next tree

[0] 1a80dbcb2dba bpf: support deferring bpf_link dealloc to after
RCU grace period

> KASAN: null-ptr-deref in range [0x0000000000000000-0x0000000000000007]
> CPU: 0 PID: 5082 Comm: syz-executor316 Not tainted 6.9.0-rc5-syzkaller-01452-ga9e7715ce8b3 #0
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 03/27/2024
> RIP: 0010:____bpf_get_attach_cookie_tracing kernel/trace/bpf_trace.c:1179 [inline]
> RIP: 0010:bpf_get_attach_cookie_tracing+0x46/0x60 kernel/trace/bpf_trace.c:1174
> Code: d3 03 00 48 81 c3 00 18 00 00 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 54 b9 59 00 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 3b b9 59 00 48 8b 03 5b 41 5e c3
> RSP: 0018:ffffc90002f9fba8 EFLAGS: 00010246
> RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff888029575a00
> RDX: 0000000000000000 RSI: ffffc90000ace048 RDI: 0000000000000000
> RBP: ffffc90002f9fbc0 R08: ffffffff89938ae7 R09: 1ffffffff25e80a0
> R10: dffffc0000000000 R11: ffffffffa0000950 R12: ffffc90002f9fc80
> R13: dffffc0000000000 R14: dffffc0000000000 R15: 0000000000000000
> FS: 0000555578992380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000002e3e9388 CR3: 00000000791c2000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> <TASK>
> bpf_prog_fe13437f26555f61+0x1a/0x1c
> bpf_dispatcher_nop_func include/linux/bpf.h:1243 [inline]
> __bpf_prog_run include/linux/filter.h:691 [inline]
> bpf_prog_run include/linux/filter.h:698 [inline]
> __bpf_prog_test_run_raw_tp+0x149/0x310 net/bpf/test_run.c:732
> bpf_prog_test_run_raw_tp+0x47b/0x6a0 net/bpf/test_run.c:772
> bpf_prog_test_run+0x33a/0x3b0 kernel/bpf/syscall.c:4286
> __sys_bpf+0x48d/0x810 kernel/bpf/syscall.c:5700
> __do_sys_bpf kernel/bpf/syscall.c:5789 [inline]
> __se_sys_bpf kernel/bpf/syscall.c:5787 [inline]
> __x64_sys_bpf+0x7c/0x90 kernel/bpf/syscall.c:5787
> do_syscall_x64 arch/x86/entry/common.c:52 [inline]
> do_syscall_64+0xf5/0x240 arch/x86/entry/common.c:83
> entry_SYSCALL_64_after_hwframe+0x77/0x7f
> RIP: 0033:0x7f53be8a0469
> 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:00007ffdcf680a08 EFLAGS: 00000246 ORIG_RAX: 0000000000000141
> RAX: ffffffffffffffda RBX: 00007ffdcf680bd8 RCX: 00007f53be8a0469
> RDX: 000000000000000c RSI: 0000000020000080 RDI: 000000000000000a
> RBP: 00007f53be913610 R08: 0000000000000000 R09: 00007ffdcf680bd8
> R10: 00007f53be8dbae3 R11: 0000000000000246 R12: 0000000000000001
> R13: 00007ffdcf680bc8 R14: 0000000000000001 R15: 0000000000000001
> </TASK>
> Modules linked in:
> ---[ end trace 0000000000000000 ]---
> RIP: 0010:____bpf_get_attach_cookie_tracing kernel/trace/bpf_trace.c:1179 [inline]
> RIP: 0010:bpf_get_attach_cookie_tracing+0x46/0x60 kernel/trace/bpf_trace.c:1174
> Code: d3 03 00 48 81 c3 00 18 00 00 48 89 d8 48 c1 e8 03 42 80 3c 30 00 74 08 48 89 df e8 54 b9 59 00 48 8b 1b 48 89 d8 48 c1 e8 03 <42> 80 3c 30 00 74 08 48 89 df e8 3b b9 59 00 48 8b 03 5b 41 5e c3
> RSP: 0018:ffffc90002f9fba8 EFLAGS: 00010246
> RAX: 0000000000000000 RBX: 0000000000000000 RCX: ffff888029575a00
> RDX: 0000000000000000 RSI: ffffc90000ace048 RDI: 0000000000000000
> RBP: ffffc90002f9fbc0 R08: ffffffff89938ae7 R09: 1ffffffff25e80a0
> R10: dffffc0000000000 R11: ffffffffa0000950 R12: ffffc90002f9fc80
> R13: dffffc0000000000 R14: dffffc0000000000 R15: 0000000000000000
> FS: 0000555578992380(0000) GS:ffff8880b9400000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 000000002e3e9388 CR3: 00000000791c2000 CR4: 00000000003506f0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> ----------------
> Code disassembly (best guess):
> 0: d3 03 roll %cl,(%rbx)
> 2: 00 48 81 add %cl,-0x7f(%rax)
> 5: c3 ret
> 6: 00 18 add %bl,(%rax)
> 8: 00 00 add %al,(%rax)
> a: 48 89 d8 mov %rbx,%rax
> d: 48 c1 e8 03 shr $0x3,%rax
> 11: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1)
> 16: 74 08 je 0x20
> 18: 48 89 df mov %rbx,%rdi
> 1b: e8 54 b9 59 00 call 0x59b974
> 20: 48 8b 1b mov (%rbx),%rbx
> 23: 48 89 d8 mov %rbx,%rax
> 26: 48 c1 e8 03 shr $0x3,%rax
> * 2a: 42 80 3c 30 00 cmpb $0x0,(%rax,%r14,1) <-- trapping instruction
> 2f: 74 08 je 0x39
> 31: 48 89 df mov %rbx,%rdi
> 34: e8 3b b9 59 00 call 0x59b974
> 39: 48 8b 03 mov (%rbx),%rax
> 3c: 5b pop %rbx
> 3d: 41 5e pop %r14
> 3f: c3 ret
>
>
> ---
> 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@xxxxxxxxxxxxxxxx.
>
> 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