Skip to content

Commit ddb47d5

Browse files
netoptimizerAlexei Starovoitov
authored andcommitted
xdp: Clear grow memory in bpf_xdp_adjust_tail()
Clearing memory of tail when grow happens, because it is too easy to write a XDP_PASS program that extend the tail, which expose this memory to users that can run tcpdump. Signed-off-by: Jesper Dangaard Brouer <[email protected]> Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: Toke Høiland-Jørgensen <[email protected]> Link: https://lore.kernel.org/bpf/158945349039.97035.5262100484553494.stgit@firesoul
1 parent c8741e2 commit ddb47d5

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

net/core/filter.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3427,6 +3427,10 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
34273427
if (unlikely(data_end < xdp->data + ETH_HLEN))
34283428
return -EINVAL;
34293429

3430+
/* Clear memory area on grow, can contain uninit kernel memory */
3431+
if (offset > 0)
3432+
memset(xdp->data_end, 0, offset);
3433+
34303434
xdp->data_end = data_end;
34313435

34323436
return 0;

0 commit comments

Comments
 (0)