mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-09-18 22:09:30 +02:00
NTB: ntb_transport: Reject oversized TX buffers
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: fce8a7bb5b ("PCI-Express Non-Transparent Bridge Support")
Cc: stable@vger.kernel.org
Signed-off-by: Koichiro Den <den@valinux.co.jp>
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>
This commit is contained in:
committed by
Jakub Kicinski
parent
873ce713fe
commit
a4f2387db6
@@ -1955,15 +1955,6 @@ static int ntb_process_tx(struct ntb_transport_qp *qp,
|
||||
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);
|
||||
|
||||
qp->tx_pkts++;
|
||||
@@ -2356,6 +2347,9 @@ int ntb_transport_tx_enqueue(struct ntb_transport_qp *qp, void *cb, void *data,
|
||||
if (!qp->link_is_up)
|
||||
return -ENOLINK;
|
||||
|
||||
if (len > qp->tx_max_frame - sizeof(struct ntb_payload_header))
|
||||
return -EMSGSIZE;
|
||||
|
||||
entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q);
|
||||
if (!entry) {
|
||||
qp->tx_err_no_buf++;
|
||||
|
||||
Reference in New Issue
Block a user