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 CB55045518A; Thu, 30 Jul 2026 15:26:26 +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=1785425188; cv=none; b=RRItWS3yLymumudNgsmM5StjMdXBmeQ4cdsj+Wag/pdKw+IvzNiCv9RyHajqC7IP42HhgdN9JRsfUN0LuDKKwpsnK/VnbpQw0zIBOlulsGqCPy9pFjxkC31t2bgI7j38BAkLEqqkeEdcs1knTLbFBWt2Z7jAZdzpd0+isyQwRcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1785425188; c=relaxed/simple; bh=+myNycgN/KON0A17n3/+kipEBIBb+teaLTmzRkfpcaI=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=hNxyja/oLrMmOAI9n9el06Eg7OalRrVAm+zV1UDRTBB0iWGyj8K5kdNufJRZutrctzFXLRr23RqfPQ0gC9S0SEqGFC6yaM6gyfW/xQM8schEzV+UHMloF0oAgSyIi1RbILlY60pRhA/u8V+0mYua1Sn4X+CSwsnmJ3oFiLVCD4c= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=BJag+JpS; 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="BJag+JpS" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2CCA91F00A3E; Thu, 30 Jul 2026 15:26:26 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1785425186; bh=YZH5uERAH75oGvU5sPHXtA+TuHcrNQ9pkUaEdtjKHXQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=BJag+JpS9ezH2blrltnUzn/5PsA2UWtgx89auijr0H9+FaPMR7QtUekhVPvYc5b2V iqLTtinRFN2MZ5dgu/JwIzGZ7uhRy4K6tEymG/UdtDT9poV1plFOQBapuHSH1FzROG lEL1FNfd2FIrVFUsTIdY2EtFr9Z5p+IEnIUH0BCs= From: Greg Kroah-Hartman To: stable@vger.kernel.org Cc: Greg Kroah-Hartman , patches@lists.linux.dev, Haiyang Zhang , Dexuan Cui , Paolo Abeni , Sasha Levin Subject: [PATCH 6.18 655/675] net: mana: Validate the packet length reported by the NIC Date: Thu, 30 Jul 2026 16:16:25 +0200 Message-ID: <20260730141459.067295144@linuxfoundation.org> X-Mailer: git-send-email 2.55.0 In-Reply-To: <20260730141445.110192266@linuxfoundation.org> References: <20260730141445.110192266@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 6.18-stable review patch. If anyone has any objections, please let me know. ------------------ From: Dexuan Cui [ Upstream commit 2e2a83b4998af4384e677d3b2ac08565274279bf ] Validate the packet length reported in the RX CQE before passing it to skb processing. The CQE is supplied by the NIC device and should not be blindly trusted. Cc: stable@vger.kernel.org Reviewed-by: Haiyang Zhang Signed-off-by: Dexuan Cui Fixes: ca9c54d2d6a5 ("net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)") Link: https://patch.msgid.link/20260702041237.617719-2-decui@microsoft.com Signed-off-by: Paolo Abeni Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- drivers/net/ethernet/microsoft/mana/mana_en.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) --- a/drivers/net/ethernet/microsoft/mana/mana_en.c +++ b/drivers/net/ethernet/microsoft/mana/mana_en.c @@ -2160,6 +2160,19 @@ static void mana_process_rx_cqe(struct m rxbuf_oob = &rxq->rx_oobs[curr]; WARN_ON_ONCE(rxbuf_oob->wqe_inf.wqe_size_in_bu != 1); + if (unlikely(pktlen > rxq->datasize)) { + /* Increase it even if mana_rx_skb() isn't called. */ + rxq->rx_cq.work_done++; + + ++ndev->stats.rx_dropped; + netdev_warn_once(ndev, + "Dropped oversized RX packet: len=%u, datasize=%u\n", + pktlen, rxq->datasize); + + /* Reuse the RX buffer since rxbuf_oob is unchanged. */ + goto drop; + } + mana_refill_rx_oob(dev, rxq, rxbuf_oob, &old_buf, &old_fp); /* Unsuccessful refill will have old_buf == NULL.