From: Jesper Dangaard Brouer <brouer@redhat.com>
To: Daniel Borkmann <borkmann@iogearbox.net>,
Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: netdev@vger.kernel.org, Jesper Dangaard Brouer <brouer@redhat.com>
Subject: [RFC net-next PATCH 1/2] bpf: avoid clear xdp_frame area again
Date: Wed, 18 Apr 2018 14:10:11 +0200 [thread overview]
Message-ID: <152405341177.30730.1255927134630901578.stgit@firesoul> (raw)
In-Reply-To: <152405338404.30730.9846848505925123326.stgit@firesoul>
Avoid clearing xdp_frame area if this was already done by prevous
invocations of bpf_xdp_adjust_head.
The xdp_adjust_head helper can be called multiple times by the
bpf_prog. If increasing the packet header size (with a negative
offset), kernel must assume bpf_prog store valuable information here,
and not clear this information.
In case of extending header into xdp_frame area the kernel clear this
area to avoid any info leaking.
The bug in the current implementation is that if existing xdp->data
pointer have already been moved into xdp_frame area, then memory is
cleared between new-data pointer and xdp_frame-end, which covers an
area that might contain information store by BPF-prog (as curr
xdp->data lays between those pointers).
Fixes: 6dfb970d3dbd ("xdp: avoid leaking info stored in frame data on page reuse")
Signed-off-by: Jesper Dangaard Brouer <brouer@redhat.com>
---
net/core/filter.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/net/core/filter.c b/net/core/filter.c
index a374b8560bc4..15e9b5477360 100644
--- a/net/core/filter.c
+++ b/net/core/filter.c
@@ -2705,6 +2705,13 @@ BPF_CALL_2(bpf_xdp_adjust_head, struct xdp_buff *, xdp, int, offset)
if (data < xdp_frame_end) {
unsigned long clearlen = xdp_frame_end - data;
+ /* Handle if prev call adjusted xdp->data into xdp_frame area */
+ if (unlikely(xdp->data < xdp_frame_end)) {
+ if (data < xdp->data)
+ clearlen = xdp->data - data;
+ else
+ clearlen = 0;
+ }
memset(data, 0, clearlen);
}
next prev parent reply other threads:[~2018-04-18 12:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-18 12:10 [RFC net-next PATCH 0/2] bpf: followup avoid leaking info stored in frame data on page reuse Jesper Dangaard Brouer
2018-04-18 12:10 ` Jesper Dangaard Brouer [this message]
2018-04-18 12:10 ` [RFC net-next PATCH 2/2] bpf: disallow XDP data_meta to overlap with xdp_frame area Jesper Dangaard Brouer
2018-04-18 16:21 ` Daniel Borkmann
2018-04-18 17:53 ` Jesper Dangaard Brouer
2018-04-18 20:28 ` Daniel Borkmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=152405341177.30730.1255927134630901578.stgit@firesoul \
--to=brouer@redhat.com \
--cc=alexei.starovoitov@gmail.com \
--cc=borkmann@iogearbox.net \
--cc=netdev@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox