Re: [PATCH net-next v2] bpf: fix verifier NULL pointer dereference
From: Craig GallekDate: Thu, 2 Nov 2017 11:18:01 -0400 > From: Craig Gallek > > do_check() can fail early without allocating env->cur_state under > memory pressure. Syzkaller found the stack below on the linux-next > tree because of this. ... > Fixes: 638f5b90d460 ("bpf: reduce verifier memory consumption") > Fixes: 1969db47f8d0 ("bpf: fix verifier memory leaks") > Signed-off-by: Craig Gallek Applied, thanks Craig.
Re: [PATCH net-next v2] bpf: fix verifier NULL pointer dereference
On 11/02/2017 04:18 PM, Craig Gallek wrote: From: Craig Gallekdo_check() can fail early without allocating env->cur_state under memory pressure. Syzkaller found the stack below on the linux-next tree because of this. kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 1 PID: 27062 Comm: syz-executor5 Not tainted 4.14.0-rc7+ #106 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: 8801c2c74700 task.stack: 8801c3e28000 RIP: 0010:free_verifier_state kernel/bpf/verifier.c:347 [inline] RIP: 0010:bpf_check+0xcf4/0x19c0 kernel/bpf/verifier.c:4533 RSP: 0018:8801c3e2f5c8 EFLAGS: 00010202 RAX: dc00 RBX: fff4 RCX: RDX: 0070 RSI: 817d5aa9 RDI: 0380 RBP: 8801c3e2f668 R08: R09: 1100387c5d9f R10: 218c4e80 R11: 85b34380 R12: 8801c4dc6a28 R13: R14: 8801c4dc6a00 R15: 8801c4dc6a20 FS: 7f311079b700() GS:8801db30() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: 004d4a24 CR3: 0001cbcd CR4: 001406e0 DR0: DR1: DR2: DR3: DR6: fffe0ff0 DR7: 0400 Call Trace: bpf_prog_load+0xcbb/0x18e0 kernel/bpf/syscall.c:1166 SYSC_bpf kernel/bpf/syscall.c:1690 [inline] SyS_bpf+0xae9/0x4620 kernel/bpf/syscall.c:1652 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x452869 RSP: 002b:7f311079abe8 EFLAGS: 0212 ORIG_RAX: 0141 RAX: ffda RBX: 00758020 RCX: 00452869 RDX: 0030 RSI: 20168000 RDI: 0005 RBP: 7f311079aa20 R08: R09: R10: R11: 0212 R12: 004b7550 R13: 7f311079ab58 R14: 004b7560 R15: Code: df 48 c1 ea 03 80 3c 02 00 0f 85 e6 0b 00 00 4d 8b 6e 20 48 b8 00 00 00 00 00 fc ff df 49 8d bd 80 03 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 b6 0b 00 00 49 8b bd 80 03 00 00 e8 d6 0c 26 RIP: free_verifier_state kernel/bpf/verifier.c:347 [inline] RSP: 8801c3e2f5c8 RIP: bpf_check+0xcf4/0x19c0 kernel/bpf/verifier.c:4533 RSP: 8801c3e2f5c8 ---[ end trace c8d37f339dc64004 ]--- Fixes: 638f5b90d460 ("bpf: reduce verifier memory consumption") Fixes: 1969db47f8d0 ("bpf: fix verifier memory leaks") Signed-off-by: Craig Gallek Acked-by: Daniel Borkmann
Re: [PATCH net-next v2] bpf: fix verifier NULL pointer dereference
On 11/2/17 8:18 AM, Craig Gallek wrote: From: Craig Gallekdo_check() can fail early without allocating env->cur_state under memory pressure. Syzkaller found the stack below on the linux-next tree because of this. kasan: CONFIG_KASAN_INLINE enabled kasan: GPF could be caused by NULL-ptr deref or user memory access general protection fault: [#1] SMP KASAN Dumping ftrace buffer: (ftrace buffer empty) Modules linked in: CPU: 1 PID: 27062 Comm: syz-executor5 Not tainted 4.14.0-rc7+ #106 Hardware name: Google Google Compute Engine/Google Compute Engine, BIOS Google 01/01/2011 task: 8801c2c74700 task.stack: 8801c3e28000 RIP: 0010:free_verifier_state kernel/bpf/verifier.c:347 [inline] RIP: 0010:bpf_check+0xcf4/0x19c0 kernel/bpf/verifier.c:4533 RSP: 0018:8801c3e2f5c8 EFLAGS: 00010202 RAX: dc00 RBX: fff4 RCX: RDX: 0070 RSI: 817d5aa9 RDI: 0380 RBP: 8801c3e2f668 R08: R09: 1100387c5d9f R10: 218c4e80 R11: 85b34380 R12: 8801c4dc6a28 R13: R14: 8801c4dc6a00 R15: 8801c4dc6a20 FS: 7f311079b700() GS:8801db30() knlGS: CS: 0010 DS: ES: CR0: 80050033 CR2: 004d4a24 CR3: 0001cbcd CR4: 001406e0 DR0: DR1: DR2: DR3: DR6: fffe0ff0 DR7: 0400 Call Trace: bpf_prog_load+0xcbb/0x18e0 kernel/bpf/syscall.c:1166 SYSC_bpf kernel/bpf/syscall.c:1690 [inline] SyS_bpf+0xae9/0x4620 kernel/bpf/syscall.c:1652 entry_SYSCALL_64_fastpath+0x1f/0xbe RIP: 0033:0x452869 RSP: 002b:7f311079abe8 EFLAGS: 0212 ORIG_RAX: 0141 RAX: ffda RBX: 00758020 RCX: 00452869 RDX: 0030 RSI: 20168000 RDI: 0005 RBP: 7f311079aa20 R08: R09: R10: R11: 0212 R12: 004b7550 R13: 7f311079ab58 R14: 004b7560 R15: Code: df 48 c1 ea 03 80 3c 02 00 0f 85 e6 0b 00 00 4d 8b 6e 20 48 b8 00 00 00 00 00 fc ff df 49 8d bd 80 03 00 00 48 89 fa 48 c1 ea 03 <80> 3c 02 00 0f 85 b6 0b 00 00 49 8b bd 80 03 00 00 e8 d6 0c 26 RIP: free_verifier_state kernel/bpf/verifier.c:347 [inline] RSP: 8801c3e2f5c8 RIP: bpf_check+0xcf4/0x19c0 kernel/bpf/verifier.c:4533 RSP: 8801c3e2f5c8 ---[ end trace c8d37f339dc64004 ]--- Fixes: 638f5b90d460 ("bpf: reduce verifier memory consumption") Fixes: 1969db47f8d0 ("bpf: fix verifier memory leaks") Signed-off-by: Craig Gallek Acked-by: Alexei Starovoitov Thanks!