Commit f54ba391 authored by Björn Töpel's avatar Björn Töpel Committed by Daniel Borkmann

xsk: fix to reject invalid flags in xsk_bind

Passing a non-existing flag in the sxdp_flags member of struct
sockaddr_xdp was, incorrectly, silently ignored. This patch addresses
that behavior, and rejects any non-existing flags.

We have examined existing user space code, and to our best knowledge,
no one is relying on the current incorrect behavior. AF_XDP is still
in its infancy, so from our perspective, the risk of breakage is very
low, and addressing this problem now is important.

Fixes: 965a9909 ("xsk: add support for bind for Rx")
Signed-off-by: default avatarBjörn Töpel <bjorn.topel@intel.com>
Signed-off-by: default avatarDaniel Borkmann <daniel@iogearbox.net>
parent 243b4cda
...@@ -407,6 +407,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) ...@@ -407,6 +407,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
if (sxdp->sxdp_family != AF_XDP) if (sxdp->sxdp_family != AF_XDP)
return -EINVAL; return -EINVAL;
flags = sxdp->sxdp_flags;
if (flags & ~(XDP_SHARED_UMEM | XDP_COPY | XDP_ZEROCOPY))
return -EINVAL;
mutex_lock(&xs->mutex); mutex_lock(&xs->mutex);
if (xs->dev) { if (xs->dev) {
err = -EBUSY; err = -EBUSY;
...@@ -425,7 +429,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len) ...@@ -425,7 +429,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
} }
qid = sxdp->sxdp_queue_id; qid = sxdp->sxdp_queue_id;
flags = sxdp->sxdp_flags;
if (flags & XDP_SHARED_UMEM) { if (flags & XDP_SHARED_UMEM) {
struct xdp_sock *umem_xs; struct xdp_sock *umem_xs;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment