summaryrefslogtreecommitdiff
path: root/net/xdp
diff options
context:
space:
mode:
authorStanislav Fomichev <sdf@google.com>2023-11-27 22:03:13 +0300
committerAlexei Starovoitov <ast@kernel.org>2023-11-30 01:59:40 +0300
commitce59f9686e0eca19431571c7403394a6c36371e2 (patch)
tree0cc41665be78edc0bc31892f88179d322217b078 /net/xdp
parent9620e956d5b592d305728144931e89d780a598aa (diff)
downloadlinux-ce59f9686e0eca19431571c7403394a6c36371e2.tar.xz
xsk: Validate xsk_tx_metadata flags
Accept only the flags that the kernel knows about to make sure we can extend this field in the future. Note that only in XDP_COPY mode we propagate the error signal back to the user (via sendmsg). For zerocopy mode we silently skip the metadata for the descriptors that have wrong flags (since we process the descriptors deep in the driver). Signed-off-by: Stanislav Fomichev <sdf@google.com> Link: https://lore.kernel.org/r/20231127190319.1190813-8-sdf@google.com Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Diffstat (limited to 'net/xdp')
-rw-r--r--net/xdp/xsk.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index e83ade32f1fd..d66ba9d6154f 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -728,6 +728,10 @@ static struct sk_buff *xsk_build_skb(struct xdp_sock *xs,
}
meta = buffer - xs->pool->tx_metadata_len;
+ if (unlikely(!xsk_buff_valid_tx_metadata(meta))) {
+ err = -EINVAL;
+ goto free_err;
+ }
if (meta->flags & XDP_TXMD_FLAGS_CHECKSUM) {
if (unlikely(meta->request.csum_start +