Thread (429 messages) flat view 429 messages, 11 authors, 12d ago

Re: [PATCH 6.12 349/403] NTB: ntb_transport: Reject oversized TX buffers

From: Harshit Mogalapalli <hidden>
Date: 2026-09-05 18:33:30
Also in: linux-patches

Hi Greg/Sasha,


On 04/09/26 10:32 am, Greg Kroah-Hartman wrote:
quoted hunk ↗ jump to hunk
6.12-stable review patch.  If anyone has any objections, please let me know.

------------------

From: Koichiro Den <redacted>

commit a4f2387db6f1cc2f03abba7f3a6807ad61e26ff7 upstream.

ntb_process_tx() handles an oversized buffer by calling tx_handler()
with a NULL data pointer and returning success. ntb_netdev therefore
neither frees the skb in its completion callback nor takes its enqueue
error path, leaking it.

Reject oversized buffers in ntb_transport_tx_enqueue() before acquiring
a queue entry and return -EMSGSIZE. The caller retains ownership of the
buffer, and the preceding netdev patch frees the skb when enqueue
returns this permanent error.

Fixes: fce8a7bb5b4b ("PCI-Express Non-Transparent Bridge Support")
Cc: stable@vger.kernel.org
Signed-off-by: Koichiro Den <redacted>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
Link: https://patch.msgid.link/20260817053519.4135287-5-den@valinux.co.jp
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
  drivers/ntb/ntb_transport.c |   12 +++---------
  1 file changed, 3 insertions(+), 9 deletions(-)
--- a/drivers/ntb/ntb_transport.c
+++ b/drivers/ntb/ntb_transport.c
@@ -1927,15 +1927,6 @@ static int ntb_process_tx(struct ntb_tra
  		return -EAGAIN;
  	}
  
-	if (entry->len > qp->tx_max_frame - sizeof(struct ntb_payload_header)) {
-		if (qp->tx_handler)
-			qp->tx_handler(qp, qp->cb_data, NULL, -EIO);
-
-		ntb_list_add(&qp->ntb_tx_free_q_lock, &entry->entry,
-			     &qp->tx_free_q);
-		return 0;
-	}
-
 >   	ntb_async_tx(qp, entry);>
quoted hunk ↗ jump to hunk
  	qp->tx_index++;
@@ -2310,6 +2301,9 @@ int ntb_transport_tx_enqueue(struct ntb_
  	if (!qp->link_is_up)
  		return -ENOLINK;
  
+	if (len > qp->tx_max_frame - sizeof(struct ntb_payload_header))
+		return -EMSGSIZE;
+
I have run an AI-assisted backport review and it spotted an issue.

Upstream commit: a4f2387db6f1 ("NTB: ntb_transport: Reject oversized
TX buffers") returns -EMSGSIZE before dequeuing a transport entry.
It relies on preceding commit: 8aaa47351db0 ("net: ntb_netdev: Fix
TX busy and drop handling") to free an skb on a permanent enqueue
error and return NETDEV_TX_OK.

The 6.12.y ntb_netdev caller still does this for every error:

     ndev->stats.tx_dropped++;
     ndev->stats.tx_errors++;
     return NETDEV_TX_BUSY;

It does not free the skb.  Thus an oversized packet can never succeed,
but commit: 9d457690ff8c ("NTB: ntb_transport: Reject oversized TX
buffers") tells the stack to retry it as though the condition were
temporary.  That can leave the packet stuck and stall NTB transmit.

I think 6.12.y misses commit: 8aaa47351db0 ("net: ntb_netdev: Fix TX
busy and drop handling"). Thoughts?

These are all part of patch series:
https://lore.kernel.org/all/20260817053519.4135287-1-den@valinux.co.jp/ (local)

thanks,
Harshit
  	entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
  	if (!entry) {
  		qp->tx_err_no_buf++;

  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help