aboutsummaryrefslogtreecommitdiffstats
path: root/net/xdp
diff options
context:
space:
mode:
authorMagnus Karlsson <magnus.karlsson@intel.com>2018-05-22 03:34:58 -0400
committerDaniel Borkmann <daniel@iogearbox.net>2018-05-22 04:25:06 -0400
commit2e59dd5e4f6e884d1f7a70acf9845d223429026e (patch)
treefaf2820390b4291d5c10f8a3d2d54d6f24261a38 /net/xdp
parentad75646c68a6e344a3609f40825855a0e742d04d (diff)
xsk: proper queue id check at bind
Validate the queue id against both Rx and Tx on the netdev. Also, make sure that the queue exists at xmit time. Reported-by: Jesper Dangaard Brouer <brouer@redhat.com> Tested-by: Jesper Dangaard Brouer <brouer@redhat.com> Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Diffstat (limited to 'net/xdp')
-rw-r--r--net/xdp/xsk.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/net/xdp/xsk.c b/net/xdp/xsk.c
index cb1acd7009f4..29707354cf78 100644
--- a/net/xdp/xsk.c
+++ b/net/xdp/xsk.c
@@ -142,6 +142,11 @@ static int xsk_generic_xmit(struct sock *sk, struct msghdr *m,
142 goto out; 142 goto out;
143 } 143 }
144 144
145 if (xs->queue_id >= xs->dev->real_num_tx_queues) {
146 err = -ENXIO;
147 goto out;
148 }
149
145 skb = sock_alloc_send_skb(sk, len, !need_wait, &err); 150 skb = sock_alloc_send_skb(sk, len, !need_wait, &err);
146 if (unlikely(!skb)) { 151 if (unlikely(!skb)) {
147 err = -EAGAIN; 152 err = -EAGAIN;
@@ -305,7 +310,8 @@ static int xsk_bind(struct socket *sock, struct sockaddr *addr, int addr_len)
305 goto out_unlock; 310 goto out_unlock;
306 } 311 }
307 312
308 if (sxdp->sxdp_queue_id >= dev->num_rx_queues) { 313 if ((xs->rx && sxdp->sxdp_queue_id >= dev->real_num_rx_queues) ||
314 (xs->tx && sxdp->sxdp_queue_id >= dev->real_num_tx_queues)) {
309 err = -EINVAL; 315 err = -EINVAL;
310 goto out_unlock; 316 goto out_unlock;
311 } 317 }