summaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
authorBjörn Töpel <bjorn.topel@intel.com>2019-03-08 08:57:26 +0100
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-04-05 22:34:20 +0200
commitb48475a66ef541b7550ed62b52f665e81652786d (patch)
treeea484fd2f9e8568ddabee620c69c5496ef5e8936 /net
parent3cac5ce088c2f9a947f61e05806db7086a52701c (diff)
downloadtalos-obmc-linux-b48475a66ef541b7550ed62b52f665e81652786d.tar.gz
talos-obmc-linux-b48475a66ef541b7550ed62b52f665e81652786d.zip
xsk: fix to reject invalid flags in xsk_bind
[ Upstream commit f54ba391d88f5a5d032175b4c308c176e34b80b7 ] 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: 965a99098443 ("xsk: add support for bind for Rx") Signed-off-by: Björn Töpel <bjorn.topel@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Sasha Levin <sashal@kernel.org>
Diffstat (limited to 'net')
-rw-r--r--net/xdp/xsk.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index 85e4fe4f18cc..f3031c8907d9 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -407,6 +407,10 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
if (sxdp->sxdp_family != AF_XDP)
return -EINVAL;
+ flags = sxdp->sxdp_flags;
+ if (flags & ~(XDP_SHARED_UMEM | XDP_COPY | XDP_ZEROCOPY))
+ return -EINVAL;
+
mutex_lock(&xs->mutex);
if (xs->dev) {
err = -EBUSY;
@@ -425,7 +429,6 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
}
qid = sxdp->sxdp_queue_id;
- flags = sxdp->sxdp_flags;
if (flags & XDP_SHARED_UMEM) {
struct xdp_sock *umem_xs;
OpenPOWER on IntegriCloud