From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 42554379ED2; Sat, 12 Sep 2026 19:32:41 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241562; cv=none; b=BVQL4d6tCwf1WrzqCFg8rCfntEuNM2Cv26cDiWn+ZjP0sLPdugRayvSY9ogJcsIFKAkIk/plBQi4ZI8yi8NLLvboCplPtiry7edD19WDtPjlyyvZZPkK97wkkWYZhIQGwWJNYpwlwaWnOe8325cGCfnobiHvWYQ+SVNora0odhM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1789241562; c=relaxed/simple; bh=tIZa/UTN3pA031tb0ZSiEeUeQod3ju/lJDEI9/bkntQ=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=eA9wpqMzncsOw9hVtlrKoRdgwfZHsiysuCvkrtHTDM7tW3V81iucNfZWhzomYGpdNWmaAwDevIZth3K8IlsIdsfysmBXaL04jotrkA8ZyUhmSEJ827qUpWMRUQY2mjCes1q/SX8zKDOFCvTM47jUaPQ2u7UbMupjwHnEDOn4wqo= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=RIMzwLwl; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="RIMzwLwl" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 477C11F000FF; Sat, 12 Sep 2026 19:32:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1789241561; bh=L7oXfqvALMCJ01mJEfXwgcCHwVuhApv6ptl6mWFEjOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=RIMzwLwluyIZaIvtPGgqJakElxVS862NYqrUh2LBYg6v99mWMRuXPZIWTA3BRgFI8 rzILBFrhgtg4DSR3WCkGBkE9mmP3WLdPB78/eMbXrXaK/+/qbVWJK7s91mmENoc0jt mLDwOEEKE4D9ML+H//uNh/KtWdxIy/p8bQkBiKdo= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Koichiro Den , Dave Jiang , Jakub Kicinski Subject: [PATCH 5.10 162/798] NTB: ntb_transport: Reject oversized TX buffers Date: Sat, 12 Sep 2026 08:56:30 +0200 Message-ID: <20260912065520.735699790@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260912065516.948645775@linuxfoundation.org> References: <20260912065516.948645775@linuxfoundation.org> User-Agent: quilt/0.69 X-stable: review X-Patchwork-Hint: ignore Precedence: bulk X-Mailing-List: patches@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 5.10-stable review patch. If anyone has any objections, please let me know. ------------------ From: Koichiro Den 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 Reviewed-by: Dave Jiang Link: https://patch.msgid.link/20260817053519.4135287-5-den@valinux.co.jp Signed-off-by: Jakub Kicinski Signed-off-by: Greg Kroah-Hartman --- 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 @@ -1913,15 +1913,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); qp->tx_index++; @@ -2296,6 +2287,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; + entry = ntb_list_rm(&qp->ntb_tx_free_q_lock, &qp->tx_free_q); if (!entry) { qp->tx_err_no_buf++;