Subject: general protection fault in __bpf_prog_put

From: syzbot <[email-masked]>
Date: Wed, 10 Jan 2018 04:58:03 -0800

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-masked]
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(1515578290.027:11): avc:  denied  { map_read  
map_write } for  pid=3509 comm="syzkaller506401"  
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: 0 PID: 3509 Comm: syzkaller506401 Not tainted  
4.15.0-rc7-next-20180110+ #93
Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS  
Google 01/01/2011
RIP: 0010:__bpf_prog_put+0x8d/0x640 kernel/bpf/syscall.c:944
RSP: 0018:ffff8801bfd9f718 EFLAGS: 00010a03
RAX: 1d700037000001b9 RBX: 0000000000000001 RCX: ffffffff817e697e
RDX: 0000000000000000 RSI: 0000000000000001 RDI: eb8001b800000db5
RBP: ffff8801bfd9f7f8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000000 R12: 1ffff10037fb3ee6
R13: ffff8801bfd9f7d0 R14: eb8001b800000db5 R15: dffffc0000000000
FS:  0000000001f35880(0000) GS:ffff8801db200000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 0000000020000000 CR3: 0000000006822001 CR4: 00000000001606f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
Call Trace:
  bpf_prog_put+0x1a/0x20 kernel/bpf/syscall.c:961
  prog_fd_array_put_ptr+0x15/0x20 kernel/bpf/arraymap.c:446
  fd_array_map_delete_elem kernel/bpf/arraymap.c:420 [inline]
  bpf_fd_array_map_clear+0xd2/0x140 kernel/bpf/arraymap.c:461
  bpf_map_put_uref+0x54/0x70 kernel/bpf/syscall.c:224
  bpf_map_put_with_uref kernel/bpf/syscall.c:248 [inline]
  bpf_map_release+0x91/0xc0 kernel/bpf/syscall.c:259
  __fput+0x327/0x7e0 fs/file_table.c:209
  ____fput+0x15/0x20 fs/file_table.c:243
  task_work_run+0x199/0x270 kernel/task_work.c:113
  exit_task_work include/linux/task_work.h:22 [inline]
  do_exit+0x9bb/0x1ad0 kernel/exit.c:869
  do_group_exit+0x149/0x400 kernel/exit.c:972
  SYSC_exit_group kernel/exit.c:983 [inline]
  SyS_exit_group+0x1d/0x20 kernel/exit.c:981
  entry_SYSCALL_64_fastpath+0x29/0xa0
RIP: 0033:0x440a69
RSP: 002b:00000000007dff48 EFLAGS: 00000206 ORIG_RAX: 00000000000000e7
RAX: ffffffffffffffda RBX: 00007fff895d3150 RCX: 0000000000440a69
RDX: 0000000000440a69 RSI: 000000000000002c RDI: 0000000000000001
RBP: 0000000000000000 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000000 R11: 0000000000000206 R12: 0000000000402240
R13: 00000000004022d0 R14: 0000000000000000 R15: 0000000000000000
Code: f2 f2 c7 40 08 f2 f2 f2 f2 c7 40 0c 00 f2 f2 f2 c7 40 10 f3 f3 f3 f3  
e8 72 f9 f1 ff 49 8d 46 18 48 89 85 28 ff ff ff 48 c1 e8 03 <42> 80 3c 38  
00 0f 85 44 05 00 00 49 8b 46 18 f0 ff 08 74 3b e8
RIP: __bpf_prog_put+0x8d/0x640 kernel/bpf/syscall.c:944 RSP:  
ffff8801bfd9f718
---[ end trace ddd64fb244865abd ]---

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

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.