In the Linux kernel, the following vulnerability has been resolved:
bpf: make sure skb->len != 0 when redirecting to a tunneling device
syzkaller managed to trigger another case where skb->len == 0
when we enter __dev_queue_xmit:
WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576 skb_assert_len include/linux/skbuff.h:2576[inline]WARNING: CPU: 0 PID: 2470 at include/linux/skbuff.h:2576__dev_queue_xmit+0x2069/0x35e0net/core/dev.c:4295Call Trace:dev_queue_xmit+0x17/0x20net/core/dev.c:4406__bpf_tx_skbnet/core/filter.c:2115[inline]__bpf_redirect_no_macnet/core/filter.c:2140[inline]__bpf_redirect+0x5fb/0xda0net/core/filter.c:2163____bpf_clone_redirectnet/core/filter.c:2447[inline]bpf_clone_redirect+0x247/0x390net/core/filter.c:2419bpf_prog_48159a89cb4a9a16+0x59/0x5ebpf_dispatcher_nop_funcinclude/linux/bpf.h:897[inline]__bpf_prog_runinclude/linux/filter.h:596[inline]bpf_prog_runinclude/linux/filter.h:603[inline]bpf_test_run+0x46c/0x890net/bpf/test_run.c:402bpf_prog_test_run_skb+0xbdc/0x14c0net/bpf/test_run.c:1170bpf_prog_test_run+0x345/0x3c0kernel/bpf/syscall.c:3648__sys_bpf+0x43a/0x6c0kernel/bpf/syscall.c:5005__do_sys_bpfkernel/bpf/syscall.c:5091[inline]__se_sys_bpfkernel/bpf/syscall.c:5089[inline]__x64_sys_bpf+0x7c/0x90kernel/bpf/syscall.c:5089do_syscall_64+0x54/0x70arch/x86/entry/common.c:48entry_SYSCALL_64_after_hwframe+0x61/0xc6
The reproducer doesn't really reproduce outside of syzkaller
environment, so I'm taking a guess here. It looks like we
do generate correct ETH_HLEN-sized packet, but we redirect
the packet to the tunneling device. Before we do so, we
__skb_pull l2 header and arrive again at skb->len == 0.
Doesn't seem like we can do anything better than having
an explicit check after __skb_pull?