Thread (38 messages) 38 messages, 4 authors, 2020-05-10

[PATCH net-next v3 30/33] xdp: clear grow memory in bpf_xdp_adjust_tail()

flat view
STALE2363d SUPERSEDED: 1 (0M)

From: Jesper Dangaard Brouer <hidden>
Date: 2020-05-08 11:11:34
Also in: bpf
Subsystem: bpf [general] (safe dynamic programs and tools), bpf [networking] (tcx & tc bpf, sock_addr), networking [general], the rest · Maintainers: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman, Kumar Kartikeya Dwivedi, "David S. Miller", Eric Dumazet, Jakub Kicinski, Paolo Abeni, Linus Torvalds

Status: Superseded by v4 (posted 2020-05-14). [go to v4]

Revision v3 (4 revisions archived); 1 review trailer.

Revisions (4)
  1. v2 re-posted go to this post
  2. v1 [diff against previous]
  3. v3 current [diff against previous]
  4. v4 [diff against previous]
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 <redacted>
Acked-by: Toke Høiland-Jørgensen <redacted>
---
 net/core/filter.c |    4 ++++
 1 file changed, 4 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index ec3ab2e2d800..691235208e0b 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;

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help