Thread (3 messages) 3 messages, 3 authors, 2018-02-01

Re: [PATCH bpf v2] bpf: fix null pointer deref in bpf_prog_test_run_xdp

From: Alexei Starovoitov <hidden>
Date: 2018-02-01 15:49:16

On Wed, Jan 31, 2018 at 12:58:56PM +0100, Daniel Borkmann wrote:
syzkaller was able to generate the following XDP program ...

  (18) r0 = 0x0
  (61) r5 = *(u32 *)(r1 +12)
  (04) (u32) r0 += (u32) 0
  (95) exit

... and trigger a NULL pointer dereference in ___bpf_prog_run()
via bpf_prog_test_run_xdp() where this was attempted to run.

Reason is that recent xdp_rxq_info addition to XDP programs
updated all drivers, but not bpf_prog_test_run_xdp(), where
xdp_buff is set up. Thus when context rewriter does the deref
on the netdev it's NULL at runtime. Fix it by using xdp_rxq
from loopback dev. __netif_get_rx_queue() helper can also be
reused in various other locations later on.

Fixes: 02dd3291b2f0 ("bpf: finally expose xdp_rxq_info to XDP bpf-programs")
Reported-by: syzbot+1eb094057b338eb1fc00@syzkaller.appspotmail.com
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Cc: Jesper Dangaard Brouer <redacted>
---
 v1 -> v2:
   - Rename netif_get_rx_queue() into __netif_get_rx_queue().

 [ Note: Needs to wait till Linus pulled Dave's net-next so
   the affected commit lands in bpf tree. ]
Applied to bpf tree, Thank you Daniel.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help