mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net-next] net/ionic: avoid OOB TX partner lookup for hwstamp RXQ
@ 2026-08-12 11:52 Anand Khoje
  2026-08-12 15:16 ` Dave Kleikamp
  0 siblings, 1 reply; 2+ messages in thread
From: Anand Khoje @ 2026-08-12 11:52 UTC (permalink / raw)
  To: Shannon Nelson, drivers, David S . Miller, Jakub Kicinski,
	Dave Kleikamp, Joe Dobosenski, netdev, linux-kernel
  Cc: anand.a.khoje

The dedicated hardware timestamp RX queue is allocated with q->index
equal to lif->ionic->nrxqs_per_lif. The normal txqcqs array only
contains the regular queue pairs, so using that index to set rxq->partner
can read one entry past txqcqs[] and then write through the derived
pointer.
Only link RX/TX partners for normal queue-pair indexes. Leave the hwstamp
RX queue unpaired, and make the XDP_TX path abort cleanly if an RX queue
has no TX partner.

Fixes: e1615dda41144 ("net/ethernet/pensando: Add out-of-tree network drivers")
Signed-off-by: Anand Khoje <anand.a.khoje@oracle.com>
Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>
---
 drivers/net/ethernet/pensando/ionic/ionic_lif.c  | 14 ++++++++++++++
 drivers/net/ethernet/pensando/ionic/ionic_txrx.c |  7 ++++++-
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
index fd3ee9820531..1822361e1070 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
@@ -920,9 +920,23 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)
 	};
 	int err;
 
+	q->partner = NULL;
+
+	/* Only normal RX queues have matching TX queue partners,
+	 * skip partner pairing for hwstamp RX queue.
+	 */
+	if (q->index >= lif->nxqs)
+		goto skip_partner;
+
+	if (WARN_ON_ONCE(!lif->txqcqs ||
+	    q->index >= lif->ionic->ntxqs_per_lif ||
+	    !lif->txqcqs[q->index]))
+		return -EINVAL;
+
 	q->partner = &lif->txqcqs[q->index]->q;
 	q->partner->partner = q;
 
+skip_partner:
 	if (!lif->xdp_prog ||
 	    (lif->xdp_prog->aux && lif->xdp_prog->aux->xdp_has_frags))
 		ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_SG);
diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
index 301ebee2fdc5..73998d61593a 100644
--- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
+++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
@@ -545,13 +545,18 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
 		break;
 
 	case XDP_TX:
+		txq = rxq->partner;
+		if (unlikely(!txq)) {
+			err = -EIO;
+			break;
+		}
+
 		xdpf = xdp_convert_buff_to_frame(&xdp_buf);
 		if (!xdpf) {
 			err = -ENOSPC;
 			break;
 		}
 
-		txq = rxq->partner;
 		nq = netdev_get_tx_queue(netdev, txq->index);
 		__netif_tx_lock(nq, smp_processor_id());
 		txq_trans_cond_update(nq);
-- 
2.52.0


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH net-next] net/ionic: avoid OOB TX partner lookup for hwstamp RXQ
  2026-08-12 11:52 [PATCH net-next] net/ionic: avoid OOB TX partner lookup for hwstamp RXQ Anand Khoje
@ 2026-08-12 15:16 ` Dave Kleikamp
  0 siblings, 0 replies; 2+ messages in thread
From: Dave Kleikamp @ 2026-08-12 15:16 UTC (permalink / raw)
  To: Anand Khoje, Shannon Nelson, drivers, David S . Miller,
	Jakub Kicinski, Joe Dobosenski, netdev, linux-kernel

On 8/12/26 6:52AM, Anand Khoje wrote:
> The dedicated hardware timestamp RX queue is allocated with q->index
> equal to lif->ionic->nrxqs_per_lif. The normal txqcqs array only
> contains the regular queue pairs, so using that index to set rxq->partner
> can read one entry past txqcqs[] and then write through the derived
> pointer.
> Only link RX/TX partners for normal queue-pair indexes. Leave the hwstamp
> RX queue unpaired, and make the XDP_TX path abort cleanly if an RX queue
> has no TX partner.
> 
> Fixes: e1615dda41144 ("net/ethernet/pensando: Add out-of-tree network drivers")

The above commit is local to UEK. It needs to either be removed or 
replaced with the relevant mainline commit.

> Signed-off-by: Anand Khoje <anand.a.khoje@oracle.com>
> Reviewed-by: Si-Wei Liu <si-wei.liu@oracle.com>
> ---
>   drivers/net/ethernet/pensando/ionic/ionic_lif.c  | 14 ++++++++++++++
>   drivers/net/ethernet/pensando/ionic/ionic_txrx.c |  7 ++++++-
>   2 files changed, 20 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_lif.c b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> index fd3ee9820531..1822361e1070 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_lif.c
> @@ -920,9 +920,23 @@ static int ionic_lif_rxq_init(struct ionic_lif *lif, struct ionic_qcq *qcq)
>   	};
>   	int err;
>   
> +	q->partner = NULL;
> +
> +	/* Only normal RX queues have matching TX queue partners,
> +	 * skip partner pairing for hwstamp RX queue.
> +	 */
> +	if (q->index >= lif->nxqs)
> +		goto skip_partner;
> +
> +	if (WARN_ON_ONCE(!lif->txqcqs ||
> +	    q->index >= lif->ionic->ntxqs_per_lif ||
> +	    !lif->txqcqs[q->index]))
> +		return -EINVAL;
> +
>   	q->partner = &lif->txqcqs[q->index]->q;
>   	q->partner->partner = q;
>   
> +skip_partner:
>   	if (!lif->xdp_prog ||
>   	    (lif->xdp_prog->aux && lif->xdp_prog->aux->xdp_has_frags))
>   		ctx.cmd.q_init.flags |= cpu_to_le16(IONIC_QINIT_F_SG);
> diff --git a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> index 301ebee2fdc5..73998d61593a 100644
> --- a/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> +++ b/drivers/net/ethernet/pensando/ionic/ionic_txrx.c
> @@ -545,13 +545,18 @@ static bool ionic_run_xdp(struct ionic_rx_stats *stats,
>   		break;
>   
>   	case XDP_TX:
> +		txq = rxq->partner;
> +		if (unlikely(!txq)) {
> +			err = -EIO;
> +			break;
> +		}
> +
>   		xdpf = xdp_convert_buff_to_frame(&xdp_buf);
>   		if (!xdpf) {
>   			err = -ENOSPC;
>   			break;
>   		}
>   
> -		txq = rxq->partner;
>   		nq = netdev_get_tx_queue(netdev, txq->index);
>   		__netif_tx_lock(nq, smp_processor_id());
>   		txq_trans_cond_update(nq);


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-08-12 15:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-08-12 11:52 [PATCH net-next] net/ionic: avoid OOB TX partner lookup for hwstamp RXQ Anand Khoje
2026-08-12 15:16 ` Dave Kleikamp

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®