octeontx2-pf: fix NULL deref of af_xdp_zc_qidx on rep setup
authorSuman Ghosh <sumang@marvell.com>
Fri, 21 Aug 2026 10:55:35 +0000 (16:25 +0530)
committerJakub Kicinski <kuba@kernel.org>
Mon, 24 Aug 2026 19:05:22 +0000 (12:05 -0700)
af_xdp_zc_qidx tracks receive queues using AF_XDP zero-copy and is
allocated during PF/VF probe. Representors and other non-AF_XDP paths
leave the pointer NULL, but several call sites used test_bit() on it
unconditionally.

Switching to devlink eswitch mode creates representors and runs
otx2_init_hw_resources(), which reaches otx2_pool_aq_init() and oopses
when dereferencing the NULL bitmap. Add NULL checks before every
af_xdp_zc_qidx test_bit() use in the RSS, ethtool, XSK, and pool init
paths.

Fixes: efabce290151 ("octeontx2-pf: AF_XDP zero copy receive support")
Signed-off-by: Suman Ghosh <sumang@marvell.com>
Signed-off-by: Geetha sowjanya <gakula@marvell.com>
Signed-off-by: Ratheesh Kannoth <rkannoth@marvell.com>
Link: https://patch.msgid.link/20260821105536.2998765-1-rkannoth@marvell.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/marvell/octeontx2/nic/otx2_common.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_ethtool.c
drivers/net/ethernet/marvell/octeontx2/nic/otx2_xsk.c

index ca73a94..1759921 100644 (file)
@@ -333,7 +333,8 @@ int otx2_set_rss_table(struct otx2_nic *pfvf, int ctx_id, const u32 *ind_tbl)
        /* Get memory to put this msg */
        for (idx = 0; idx < rss->rss_size; idx++) {
                /* Ignore the queue if AF_XDP zero copy is enabled */
-               if (test_bit(ind_tbl[idx], pfvf->af_xdp_zc_qidx))
+               if (pfvf->af_xdp_zc_qidx &&
+                   test_bit(ind_tbl[idx], pfvf->af_xdp_zc_qidx))
                        continue;
 
                aq = otx2_mbox_alloc_msg_nix_aq_enq(mbox);
@@ -1509,7 +1510,8 @@ int otx2_pool_aq_init(struct otx2_nic *pfvf, u16 pool_id,
        if (type != AURA_NIX_RQ)
                return 0;
 
-       if (!test_bit(pool_id, pfvf->af_xdp_zc_qidx)) {
+       if (!pfvf->af_xdp_zc_qidx ||
+           !test_bit(pool_id, pfvf->af_xdp_zc_qidx)) {
                pp_params.order = get_order(buf_size);
                pp_params.flags = PP_FLAG_DMA_MAP;
                pp_params.pool_size = min(OTX2_PAGE_POOL_SZ, numptrs);
index a0340f3..9bee1b9 100644 (file)
@@ -939,7 +939,8 @@ static int otx2_get_rxfh(struct net_device *dev,
 
        for (idx = 0; idx < rss->rss_size; idx++) {
                /* Ignore if the rx queue is AF_XDP zero copy enabled */
-               if (test_bit(rss->ind_tbl[idx], pfvf->af_xdp_zc_qidx))
+               if (pfvf->af_xdp_zc_qidx &&
+                   test_bit(rss->ind_tbl[idx], pfvf->af_xdp_zc_qidx))
                        continue;
                indir[idx] = rss->ind_tbl[idx];
        }
index 7d67b4c..0e8a6a6 100644 (file)
@@ -193,7 +193,8 @@ int otx2_xsk_wakeup(struct net_device *dev, u32 queue_id, u32 flags)
 
 void otx2_attach_xsk_buff(struct otx2_nic *pfvf, struct otx2_snd_queue *sq, int qidx)
 {
-       if (test_bit(qidx, pfvf->af_xdp_zc_qidx))
+       if (pfvf->af_xdp_zc_qidx &&
+           test_bit(qidx, pfvf->af_xdp_zc_qidx))
                sq->xsk_pool = xsk_get_pool_from_qid(pfvf->netdev, qidx);
 }