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

2024-05-07 Thread Andrii Nakryiko
On Sun, May 5, 2024 at 9:13 AM syzbot
 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=153c1dc498
> 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=17d4b58898
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16cb047098
>
> 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+3ab78ff125b7979e4...@syzkaller.appspotmail.com
>
> general protection fault, probably for non-canonical address 
> 0xdc00:  [#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 [0x-0x0007]
> 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:c90002f9fba8 EFLAGS: 00010246
> RAX:  RBX:  RCX: 888029575a00
> RDX:  RSI: c9ace048 RDI: 
> RBP: c90002f9fbc0 R08: 89938ae7 R09: 125e80a0
> R10: dc00 R11: a950 R12: c90002f9fc80
> R13: dc00 R14: dc00 R15: 
> FS:  78992380() GS:8880b940() knlGS:
> CS:  0010 DS:  ES:  CR0: 80050033
> CR2: 2e3e9388 CR3: 791c2000 CR4: 003506f0
> DR0:  DR1:  DR2: 
> DR3:  DR6: fffe0ff0 DR7: 0400
> Call Trace:
>  
>  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:7ffdcf680a08 EFLAGS: 0246 ORIG_RAX: 0141
> RAX: ffda RBX: 7ffdcf680bd8 RCX: 7f53be8a0469
> RDX: 000c RSI: 2080 RDI: 000a
> RBP: 7f53be913610 R08:  R09: 7ffdcf680bd8
> R10: 7f53be8dbae3 R11: 0246 R12: 0001
> R13: 7ffdcf680bc8 R14: 0001 R15: 0001
>  
> Modules linked in:
> ---[ end trace  ]---
> 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:c90002f9fba8 EFLAGS: 00010246
> RAX:  RBX:  RCX: 888029575a00
> RDX:  RSI: c9ace048 RDI: 
> RBP: c90002f9fbc0 R08: 89938ae7 R09: 125e80a0
> R10: dc00 R11: a950 

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

2024-05-05 Thread syzbot
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=153c1dc498
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=17d4b58898
C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=16cb047098

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+3ab78ff125b7979e4...@syzkaller.appspotmail.com

general protection fault, probably for non-canonical address 
0xdc00:  [#1] PREEMPT SMP KASAN PTI
KASAN: null-ptr-deref in range [0x-0x0007]
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:c90002f9fba8 EFLAGS: 00010246
RAX:  RBX:  RCX: 888029575a00
RDX:  RSI: c9ace048 RDI: 
RBP: c90002f9fbc0 R08: 89938ae7 R09: 125e80a0
R10: dc00 R11: a950 R12: c90002f9fc80
R13: dc00 R14: dc00 R15: 
FS:  78992380() GS:8880b940() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2e3e9388 CR3: 791c2000 CR4: 003506f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400
Call Trace:
 
 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:7ffdcf680a08 EFLAGS: 0246 ORIG_RAX: 0141
RAX: ffda RBX: 7ffdcf680bd8 RCX: 7f53be8a0469
RDX: 000c RSI: 2080 RDI: 000a
RBP: 7f53be913610 R08:  R09: 7ffdcf680bd8
R10: 7f53be8dbae3 R11: 0246 R12: 0001
R13: 7ffdcf680bc8 R14: 0001 R15: 0001
 
Modules linked in:
---[ end trace  ]---
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:c90002f9fba8 EFLAGS: 00010246
RAX:  RBX:  RCX: 888029575a00
RDX:  RSI: c9ace048 RDI: 
RBP: c90002f9fbc0 R08: 89938ae7 R09: 125e80a0
R10: dc00 R11: a950 R12: c90002f9fc80
R13: dc00 R14: dc00 R15: 
FS:  78992380() GS:8880b940() knlGS:
CS:  0010 DS:  ES:  CR0: 80050033
CR2: 2e3e9388 CR3: 791c2000 CR4: 003506f0
DR0:  DR1:  DR2: 
DR3:  DR6: fffe0ff0 DR7: 0400

Code