diff options
author | Jesper Dangaard Brouer <brouer@redhat.com> | 2020-05-14 13:51:30 +0300 |
---|---|---|
committer | Alexei Starovoitov <ast@kernel.org> | 2020-05-15 07:21:56 +0300 |
commit | ddb47d518ca10948d1f64a983cb9274720f691cd (patch) | |
tree | 0cf318eef490d4bc486d0eeae7604cd6a660f8ab /net | |
parent | c8741e2bfe872425ea6f10bb6f7dc1d67bc60c3a (diff) | |
download | linux-ddb47d518ca10948d1f64a983cb9274720f691cd.tar.xz |
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 <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
Diffstat (limited to 'net')
-rw-r--r-- | net/core/filter.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/core/filter.c b/net/core/filter.c index e7b033dad44e..a85eb538d4d6 100644 --- a/net/core/filter.c +++ b/net/core/filter.c @@ -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; |