]> git.baikalelectronics.ru Git - kernel.git/commitdiff
xdp: Clear grow memory in bpf_xdp_adjust_tail()
authorJesper Dangaard Brouer <brouer@redhat.com>
Thu, 14 May 2020 10:51:30 +0000 (12:51 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Fri, 15 May 2020 04:21:56 +0000 (21:21 -0700)
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 <brouer@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Toke Høiland-Jørgensen <toke@redhat.com>
Link: https://lore.kernel.org/bpf/158945349039.97035.5262100484553494.stgit@firesoul
net/core/filter.c

index e7b033dad44e0c7b1b801baf4ec6910833620e5f..a85eb538d4d62709a4ee638408b3ff35cbfe2703 100644 (file)
@@ -3427,6 +3427,10 @@ BPF_CALL_2(bpf_xdp_adjust_tail, struct xdp_buff *, xdp, int, offset)
        if (unlikely(data_end < xdp->data + ETH_HLEN))
                return -EINVAL;
 
+       /* Clear memory area on grow, can contain uninit kernel memory */
+       if (offset > 0)
+               memset(xdp->data_end, 0, offset);
+
        xdp->data_end = data_end;
 
        return 0;