Re: WARNING in bpf_raw_tp_link_fill_link_info

2020-10-30 Thread Dmitry Vyukov
On Fri, Sep 11, 2020 at 12:01 AM Andrii Nakryiko
 wrote:
>
> On Thu, Sep 10, 2020 at 2:31 AM syzbot
>  wrote:
> >
> > Hello,
> >
> > syzbot found the following issue on:
> >
> > HEAD commit:7fb5eefd selftests/bpf: Fix test_sysctl_loop{1, 2} failure..
> > git tree:   bpf-next
> > console output: https://syzkaller.appspot.com/x/log.txt?x=1424fdb390
> > kernel config:  https://syzkaller.appspot.com/x/.config?x=b6856d16f78d8fa9
> > dashboard link: https://syzkaller.appspot.com/bug?extid=976d5ecfab0c7eb43ac3
> > compiler:   gcc (GCC) 10.1.0-syz 20200507
> > syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14a1f41190
> > C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10929c1190
> >
> > IMPORTANT: if you fix the issue, please add the following tag to the commit:
> > Reported-by: syzbot+976d5ecfab0c7eb43...@syzkaller.appspotmail.com
> >
> > [ cut here ]
> > WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 
> > check_copy_size include/linux/thread_info.h:150 [inline]
> > WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 copy_to_user 
> > include/linux/uaccess.h:167 [inline]
> > WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 
> > bpf_raw_tp_link_fill_link_info+0x306/0x350 kernel/bpf/syscall.c:2661
> > Kernel panic - not syncing: panic_on_warn set ...
> > CPU: 0 PID: 6854 Comm: syz-executor574 Not tainted 5.9.0-rc1-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+0x18f/0x20d lib/dump_stack.c:118
> >  panic+0x2e3/0x75c kernel/panic.c:231
> >  __warn.cold+0x20/0x4a kernel/panic.c:600
> >  report_bug+0x1bd/0x210 lib/bug.c:198
> >  handle_bug+0x38/0x90 arch/x86/kernel/traps.c:234
> >  exc_invalid_op+0x14/0x40 arch/x86/kernel/traps.c:254
> >  asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536
> > RIP: 0010:check_copy_size include/linux/thread_info.h:150 [inline]
> > RIP: 0010:copy_to_user include/linux/uaccess.h:167 [inline]
> > RIP: 0010:bpf_raw_tp_link_fill_link_info+0x306/0x350 
> > kernel/bpf/syscall.c:2661
> > Code: 41 bc ea ff ff ff e9 35 ff ff ff 4c 89 ff e8 41 66 33 00 e9 d0 fd ff 
> > ff 4c 89 ff e8 a4 66 33 00 e9 06 ff ff ff e8 ca ed f2 ff <0f> 0b eb 94 48 
> > 89 ef e8 2e 66 33 00 e9 65 fd ff ff e8 24 66 33 00
> > RSP: 0018:c900051c7bd0 EFLAGS: 00010293
> > RAX:  RBX: c900051c7c60 RCX: 818179d6
> > RDX: 88808b49 RSI: 81817a96 RDI: 0006
> > RBP: 0019 R08:  R09: c900051c7c7f
> > R10:  R11:  R12: 0019
> > R13: 1265 R14: 8986ecc0 R15: c900051c7c78
> >  bpf_link_get_info_by_fd kernel/bpf/syscall.c:3626 [inline]
> >  bpf_obj_get_info_by_fd+0x43a/0xc40 kernel/bpf/syscall.c:3664
> >  __do_sys_bpf+0x1906/0x4b30 kernel/bpf/syscall.c:4237
> >  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
> >  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> > RIP: 0033:0x4405f9
> > Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 7b 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
> > RSP: 002b:7fff47155808 EFLAGS: 0246 ORIG_RAX: 0141
> > RAX: ffda RBX: 004002c8 RCX: 004405f9
> > RDX: 0010 RSI: 20c0 RDI: 000f
> > RBP: 006ca018 R08: 004002c8 R09: 004002c8
> > R10: 004002c8 R11: 0246 R12: 00401e00
> > R13: 00401e90 R14:  R15: 
> > Kernel Offset: disabled
> > Rebooting in 86400 seconds..
> >
>
> #syz fix: b474959d5afd ("bpf: Fix a buffer out-of-bound access when
> filling raw_tp link_info")

Complete patch title:

#syz fix:
bpf: Fix a buffer out-of-bound access when filling raw_tp link_info


Re: WARNING in bpf_raw_tp_link_fill_link_info

2020-09-10 Thread Andrii Nakryiko
On Thu, Sep 10, 2020 at 2:31 AM syzbot
 wrote:
>
> Hello,
>
> syzbot found the following issue on:
>
> HEAD commit:7fb5eefd selftests/bpf: Fix test_sysctl_loop{1, 2} failure..
> git tree:   bpf-next
> console output: https://syzkaller.appspot.com/x/log.txt?x=1424fdb390
> kernel config:  https://syzkaller.appspot.com/x/.config?x=b6856d16f78d8fa9
> dashboard link: https://syzkaller.appspot.com/bug?extid=976d5ecfab0c7eb43ac3
> compiler:   gcc (GCC) 10.1.0-syz 20200507
> syz repro:  https://syzkaller.appspot.com/x/repro.syz?x=14a1f41190
> C reproducer:   https://syzkaller.appspot.com/x/repro.c?x=10929c1190
>
> IMPORTANT: if you fix the issue, please add the following tag to the commit:
> Reported-by: syzbot+976d5ecfab0c7eb43...@syzkaller.appspotmail.com
>
> [ cut here ]
> WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 check_copy_size 
> include/linux/thread_info.h:150 [inline]
> WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 copy_to_user 
> include/linux/uaccess.h:167 [inline]
> WARNING: CPU: 0 PID: 6854 at include/linux/thread_info.h:150 
> bpf_raw_tp_link_fill_link_info+0x306/0x350 kernel/bpf/syscall.c:2661
> Kernel panic - not syncing: panic_on_warn set ...
> CPU: 0 PID: 6854 Comm: syz-executor574 Not tainted 5.9.0-rc1-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+0x18f/0x20d lib/dump_stack.c:118
>  panic+0x2e3/0x75c kernel/panic.c:231
>  __warn.cold+0x20/0x4a kernel/panic.c:600
>  report_bug+0x1bd/0x210 lib/bug.c:198
>  handle_bug+0x38/0x90 arch/x86/kernel/traps.c:234
>  exc_invalid_op+0x14/0x40 arch/x86/kernel/traps.c:254
>  asm_exc_invalid_op+0x12/0x20 arch/x86/include/asm/idtentry.h:536
> RIP: 0010:check_copy_size include/linux/thread_info.h:150 [inline]
> RIP: 0010:copy_to_user include/linux/uaccess.h:167 [inline]
> RIP: 0010:bpf_raw_tp_link_fill_link_info+0x306/0x350 kernel/bpf/syscall.c:2661
> Code: 41 bc ea ff ff ff e9 35 ff ff ff 4c 89 ff e8 41 66 33 00 e9 d0 fd ff ff 
> 4c 89 ff e8 a4 66 33 00 e9 06 ff ff ff e8 ca ed f2 ff <0f> 0b eb 94 48 89 ef 
> e8 2e 66 33 00 e9 65 fd ff ff e8 24 66 33 00
> RSP: 0018:c900051c7bd0 EFLAGS: 00010293
> RAX:  RBX: c900051c7c60 RCX: 818179d6
> RDX: 88808b49 RSI: 81817a96 RDI: 0006
> RBP: 0019 R08:  R09: c900051c7c7f
> R10:  R11:  R12: 0019
> R13: 1265 R14: 8986ecc0 R15: c900051c7c78
>  bpf_link_get_info_by_fd kernel/bpf/syscall.c:3626 [inline]
>  bpf_obj_get_info_by_fd+0x43a/0xc40 kernel/bpf/syscall.c:3664
>  __do_sys_bpf+0x1906/0x4b30 kernel/bpf/syscall.c:4237
>  do_syscall_64+0x2d/0x70 arch/x86/entry/common.c:46
>  entry_SYSCALL_64_after_hwframe+0x44/0xa9
> RIP: 0033:0x4405f9
> Code: 18 89 d0 c3 66 2e 0f 1f 84 00 00 00 00 00 0f 1f 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 7b 13 fc ff c3 66 2e 0f 1f 84 00 00 00 00
> RSP: 002b:7fff47155808 EFLAGS: 0246 ORIG_RAX: 0141
> RAX: ffda RBX: 004002c8 RCX: 004405f9
> RDX: 0010 RSI: 20c0 RDI: 000f
> RBP: 006ca018 R08: 004002c8 R09: 004002c8
> R10: 004002c8 R11: 0246 R12: 00401e00
> R13: 00401e90 R14:  R15: 
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
>

#syz fix: b474959d5afd ("bpf: Fix a buffer out-of-bound access when
filling raw_tp link_info")

>
> ---
> 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 syzkal...@googlegroups.com.
>
> 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