2018-01-10 12:58:07

by syzbot

[permalink] [raw]
Subject: general protection fault in __bpf_map_put

Hello,

syzkaller hit the following crash on
b4464bcab38d3f7fe995a7cb960eeac6889bec08
git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master
compiler: gcc (GCC) 7.1.1 20170620
.config is attached
Raw console output is attached.
C reproducer is attached
syzkaller reproducer is attached. See https://goo.gl/kgGztJ
for information about syzkaller reproducers


IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: [email protected]
It will help syzbot understand when the bug is fixed. See footer for
details.
If you forward the report, please keep this part and the footer.

audit: type=1400 audit(1515571663.627:11): avc: denied { map_read
map_write } for pid=3537 comm="syzkaller597104"
scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf
permissive=1
kasan: CONFIG_KASAN_INLINE enabled
kasan: GPF could be caused by NULL-ptr deref or user memory access
general protection fault: 0000 [#1] SMP KASAN
Dumping ftrace buffer:
(ftrace buffer empty)
Modules linked in:
CPU: 1 PID: 23 Comm: kworker/1:1 Not tainted 4.15.0-rc7-next-20180110+ #93
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
Google 01/01/2011
Workqueue: events bpf_map_free_deferred
RIP: 0010:__bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233
RSP: 0018:ffff8801d98b7458 EFLAGS: 00010293
RAX: ffff8801d98ac600 RBX: ad6001bc00000dd1 RCX: ffffffff817e4454
RDX: 0000000000000000 RSI: 0000000000000001 RDI: ad6001bc00000dd1
RBP: ffff8801d98b74e8 R08: 1ffff1003b316e6a R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1003b316e8c
R13: dffffc0000000000 R14: dffffc0000000000 R15: 0000000000000001
FS: 0000000000000000(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00000000204f9fe4 CR3: 0000000006822003 CR4: 00000000001606e0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
bpf_map_put+0x1a/0x20 kernel/bpf/syscall.c:243
bpf_map_fd_put_ptr+0x15/0x20 kernel/bpf/map_in_map.c:96
fd_array_map_delete_elem kernel/bpf/arraymap.c:420 [inline]
bpf_fd_array_map_clear kernel/bpf/arraymap.c:461 [inline]
array_of_map_free+0x100/0x180 kernel/bpf/arraymap.c:618
bpf_map_free_deferred+0xb0/0xe0 kernel/bpf/syscall.c:217
process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2112
worker_thread+0x223/0x1990 kernel/workqueue.c:2246
kthread+0x33c/0x400 kernel/kthread.c:238
ret_from_fork+0x4b/0x60 arch/x86/entry/entry_64.S:547
Code: b5 41 48 c7 45 80 1d 2c 59 86 48 c7 45 88 f0 43 7e 81 c7 00 f1 f1 f1
f1 c7 40 04 00 f2 f2 f2 c7 40 08 f3 f3 f3 f3 e8 9c 1e f2 ff <f0> ff 4b 48
74 2f e8 91 1e f2 ff 48 b8 00 00 00 00 00 fc ff df
RIP: __bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233 RSP: ffff8801d98b7458
---[ end trace 61592f27aaa1e096 ]---
Kernel panic - not syncing: Fatal exception
Dumping ftrace buffer:
(ftrace buffer empty)
Kernel Offset: disabled
Rebooting in 86400 seconds..


---
This bug is generated by a dumb bot. It may contain errors.
See https://goo.gl/tpsmEJ for details.
Direct all questions to [email protected].

syzbot will keep track of this bug report.
If you forgot to add the Reported-by tag, once the fix for this bug is
merged
into any tree, please reply to this email with:
#syz fix: exact-commit-title
If you want to test a patch for this bug, please reply with:
#syz test: git://repo/address.git branch
and provide the patch inline or as an attachment.
To mark this as a duplicate of another syzbot report, please reply with:
#syz dup: exact-subject-of-another-report
If it's a one-off invalid bug report, please reply with:
#syz invalid
Note: if the crash happens again, it will cause creation of a new bug
report.
Note: all commands must start from beginning of the line in the email body.


Attachments:
config.txt (131.01 kB)
raw.log (7.37 kB)
repro.txt (620.00 B)
repro.c (10.61 kB)
Download all attachments

2018-01-13 07:17:08

by Dmitry Vyukov

[permalink] [raw]
Subject: Re: general protection fault in __bpf_map_put

On Wed, Jan 10, 2018 at 1:58 PM, syzbot
<[email protected]> wrote:
> Hello,
>
> syzkaller hit the following crash on
> b4464bcab38d3f7fe995a7cb960eeac6889bec08
> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master
> compiler: gcc (GCC) 7.1.1 20170620
> .config is attached
> Raw console output is attached.
> C reproducer is attached
> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
> for information about syzkaller reproducers
>
>
> IMPORTANT: if you fix the bug, please add the following tag to the commit:
> Reported-by: [email protected]
> It will help syzbot understand when the bug is fixed. See footer for
> details.
> If you forward the report, please keep this part and the footer.

Daniel, is it the same bug that was fixed by "bpf, array: fix overflow
in max_entries and undefined behavior in index_mask"?

> audit: type=1400 audit(1515571663.627:11): avc: denied { map_read
> map_write } for pid=3537 comm="syzkaller597104"
> scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
> tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf
> permissive=1
> kasan: CONFIG_KASAN_INLINE enabled
> kasan: GPF could be caused by NULL-ptr deref or user memory access
> general protection fault: 0000 [#1] SMP KASAN
> Dumping ftrace buffer:
> (ftrace buffer empty)
> Modules linked in:
> CPU: 1 PID: 23 Comm: kworker/1:1 Not tainted 4.15.0-rc7-next-20180110+ #93
> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
> Google 01/01/2011
> Workqueue: events bpf_map_free_deferred
> RIP: 0010:__bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233
> RSP: 0018:ffff8801d98b7458 EFLAGS: 00010293
> RAX: ffff8801d98ac600 RBX: ad6001bc00000dd1 RCX: ffffffff817e4454
> RDX: 0000000000000000 RSI: 0000000000000001 RDI: ad6001bc00000dd1
> RBP: ffff8801d98b74e8 R08: 1ffff1003b316e6a R09: 0000000000000000
> R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1003b316e8c
> R13: dffffc0000000000 R14: dffffc0000000000 R15: 0000000000000001
> FS: 0000000000000000(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> CR2: 00000000204f9fe4 CR3: 0000000006822003 CR4: 00000000001606e0
> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
> Call Trace:
> bpf_map_put+0x1a/0x20 kernel/bpf/syscall.c:243
> bpf_map_fd_put_ptr+0x15/0x20 kernel/bpf/map_in_map.c:96
> fd_array_map_delete_elem kernel/bpf/arraymap.c:420 [inline]
> bpf_fd_array_map_clear kernel/bpf/arraymap.c:461 [inline]
> array_of_map_free+0x100/0x180 kernel/bpf/arraymap.c:618
> bpf_map_free_deferred+0xb0/0xe0 kernel/bpf/syscall.c:217
> process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2112
> worker_thread+0x223/0x1990 kernel/workqueue.c:2246
> kthread+0x33c/0x400 kernel/kthread.c:238
> ret_from_fork+0x4b/0x60 arch/x86/entry/entry_64.S:547
> Code: b5 41 48 c7 45 80 1d 2c 59 86 48 c7 45 88 f0 43 7e 81 c7 00 f1 f1 f1
> f1 c7 40 04 00 f2 f2 f2 c7 40 08 f3 f3 f3 f3 e8 9c 1e f2 ff <f0> ff 4b 48 74
> 2f e8 91 1e f2 ff 48 b8 00 00 00 00 00 fc ff df
> RIP: __bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233 RSP: ffff8801d98b7458
> ---[ end trace 61592f27aaa1e096 ]---
> Kernel panic - not syncing: Fatal exception
> Dumping ftrace buffer:
> (ftrace buffer empty)
> Kernel Offset: disabled
> Rebooting in 86400 seconds..
>
>
> ---
> This bug is generated by a dumb bot. It may contain errors.
> See https://goo.gl/tpsmEJ for details.
> Direct all questions to [email protected].
>
> syzbot will keep track of this bug report.
> If you forgot to add the Reported-by tag, once the fix for this bug is
> merged
> into any tree, please reply to this email with:
> #syz fix: exact-commit-title
> If you want to test a patch for this bug, please reply with:
> #syz test: git://repo/address.git branch
> and provide the patch inline or as an attachment.
> To mark this as a duplicate of another syzbot report, please reply with:
> #syz dup: exact-subject-of-another-report
> If it's a one-off invalid bug report, please reply with:
> #syz invalid
> Note: if the crash happens again, it will cause creation of a new bug
> report.
> Note: all commands must start from beginning of the line in the email body.
>
> --
> You received this message because you are subscribed to the Google Groups
> "syzkaller-bugs" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/syzkaller-bugs/94eb2c06de30df3d1605626b941b%40google.com.
> For more options, visit https://groups.google.com/d/optout.

2018-01-14 00:21:59

by Daniel Borkmann

[permalink] [raw]
Subject: Re: general protection fault in __bpf_map_put

On 01/13/2018 08:16 AM, Dmitry Vyukov wrote:
> On Wed, Jan 10, 2018 at 1:58 PM, syzbot
> <[email protected]> wrote:
>> Hello,
>>
>> syzkaller hit the following crash on
>> b4464bcab38d3f7fe995a7cb960eeac6889bec08
>> git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/master
>> compiler: gcc (GCC) 7.1.1 20170620
>> .config is attached
>> Raw console output is attached.
>> C reproducer is attached
>> syzkaller reproducer is attached. See https://goo.gl/kgGztJ
>> for information about syzkaller reproducers
>>
>>
>> IMPORTANT: if you fix the bug, please add the following tag to the commit:
>> Reported-by: [email protected]
>> It will help syzbot understand when the bug is fixed. See footer for
>> details.
>> If you forward the report, please keep this part and the footer.
>
> Daniel, is it the same bug that was fixed by "bpf, array: fix overflow
> in max_entries and undefined behavior in index_mask"?

Yes, fixed by:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf.git/commit/?id=bbeb6e4323dad9b5e0ee9f60c223dd532e2403b1

>> audit: type=1400 audit(1515571663.627:11): avc: denied { map_read
>> map_write } for pid=3537 comm="syzkaller597104"
>> scontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023
>> tcontext=unconfined_u:system_r:insmod_t:s0-s0:c0.c1023 tclass=bpf
>> permissive=1
>> kasan: CONFIG_KASAN_INLINE enabled
>> kasan: GPF could be caused by NULL-ptr deref or user memory access
>> general protection fault: 0000 [#1] SMP KASAN
>> Dumping ftrace buffer:
>> (ftrace buffer empty)
>> Modules linked in:
>> CPU: 1 PID: 23 Comm: kworker/1:1 Not tainted 4.15.0-rc7-next-20180110+ #93
>> Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS
>> Google 01/01/2011
>> Workqueue: events bpf_map_free_deferred
>> RIP: 0010:__bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233
>> RSP: 0018:ffff8801d98b7458 EFLAGS: 00010293
>> RAX: ffff8801d98ac600 RBX: ad6001bc00000dd1 RCX: ffffffff817e4454
>> RDX: 0000000000000000 RSI: 0000000000000001 RDI: ad6001bc00000dd1
>> RBP: ffff8801d98b74e8 R08: 1ffff1003b316e6a R09: 0000000000000000
>> R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff1003b316e8c
>> R13: dffffc0000000000 R14: dffffc0000000000 R15: 0000000000000001
>> FS: 0000000000000000(0000) GS:ffff8801db300000(0000) knlGS:0000000000000000
>> CS: 0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> CR2: 00000000204f9fe4 CR3: 0000000006822003 CR4: 00000000001606e0
>> DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
>> DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
>> Call Trace:
>> bpf_map_put+0x1a/0x20 kernel/bpf/syscall.c:243
>> bpf_map_fd_put_ptr+0x15/0x20 kernel/bpf/map_in_map.c:96
>> fd_array_map_delete_elem kernel/bpf/arraymap.c:420 [inline]
>> bpf_fd_array_map_clear kernel/bpf/arraymap.c:461 [inline]
>> array_of_map_free+0x100/0x180 kernel/bpf/arraymap.c:618
>> bpf_map_free_deferred+0xb0/0xe0 kernel/bpf/syscall.c:217
>> process_one_work+0xbbf/0x1af0 kernel/workqueue.c:2112
>> worker_thread+0x223/0x1990 kernel/workqueue.c:2246
>> kthread+0x33c/0x400 kernel/kthread.c:238
>> ret_from_fork+0x4b/0x60 arch/x86/entry/entry_64.S:547
>> Code: b5 41 48 c7 45 80 1d 2c 59 86 48 c7 45 88 f0 43 7e 81 c7 00 f1 f1 f1
>> f1 c7 40 04 00 f2 f2 f2 c7 40 08 f3 f3 f3 f3 e8 9c 1e f2 ff <f0> ff 4b 48 74
>> 2f e8 91 1e f2 ff 48 b8 00 00 00 00 00 fc ff df
>> RIP: __bpf_map_put+0x64/0x2e0 kernel/bpf/syscall.c:233 RSP: ffff8801d98b7458
>> ---[ end trace 61592f27aaa1e096 ]---
>> Kernel panic - not syncing: Fatal exception
>> Dumping ftrace buffer:
>> (ftrace buffer empty)
>> Kernel Offset: disabled
>> Rebooting in 86400 seconds..
>>
>>
>> ---
>> This bug is generated by a dumb bot. It may contain errors.
>> See https://goo.gl/tpsmEJ for details.
>> Direct all questions to [email protected].
>>
>> syzbot will keep track of this bug report.
>> If you forgot to add the Reported-by tag, once the fix for this bug is
>> merged
>> into any tree, please reply to this email with:
>> #syz fix: exact-commit-title
>> If you want to test a patch for this bug, please reply with:
>> #syz test: git://repo/address.git branch
>> and provide the patch inline or as an attachment.
>> To mark this as a duplicate of another syzbot report, please reply with:
>> #syz dup: exact-subject-of-another-report
>> If it's a one-off invalid bug report, please reply with:
>> #syz invalid
>> Note: if the crash happens again, it will cause creation of a new bug
>> report.
>> Note: all commands must start from beginning of the line in the email body.
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "syzkaller-bugs" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected].
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/syzkaller-bugs/94eb2c06de30df3d1605626b941b%40google.com.
>> For more options, visit https://groups.google.com/d/optout.