]> git.kernelconcepts.de Git - karo-tx-linux.git/commit
bpf: fix checking xdp_adjust_head on tail calls
authorDaniel Borkmann <daniel@iogearbox.net>
Mon, 17 Apr 2017 01:12:07 +0000 (03:12 +0200)
committerDavid S. Miller <davem@davemloft.net>
Mon, 17 Apr 2017 19:51:57 +0000 (15:51 -0400)
commitc2002f983767ea0a53acbb3e21f771e7a7e2ed28
tree82226511f5f60faf8c8bf820051da232e104c026
parent6b1bb01bcc5be91452bd3b5bda4300f179fd4053
bpf: fix checking xdp_adjust_head on tail calls

Commit 17bedab27231 ("bpf: xdp: Allow head adjustment in XDP prog")
added the xdp_adjust_head bit to the BPF prog in order to tell drivers
that the program that is to be attached requires support for the XDP
bpf_xdp_adjust_head() helper such that drivers not supporting this
helper can reject the program. There are also drivers that do support
the helper, but need to check for xdp_adjust_head bit in order to move
packet metadata prepended by the firmware away for making headroom.

For these cases, the current check for xdp_adjust_head bit is insufficient
since there can be cases where the program itself does not use the
bpf_xdp_adjust_head() helper, but tail calls into another program that
uses bpf_xdp_adjust_head(). As such, the xdp_adjust_head bit is still
set to 0. Since the first program has no control over which program it
calls into, we need to assume that bpf_xdp_adjust_head() helper is used
upon tail calls. Thus, for the very same reasons in cb_access, set the
xdp_adjust_head bit to 1 when the main program uses tail calls.

Fixes: 17bedab27231 ("bpf: xdp: Allow head adjustment in XDP prog")
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Alexei Starovoitov <ast@kernel.org>
Cc: Martin KaFai Lau <kafai@fb.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/syscall.c