Skip to content

Commit 6080189

Browse files
dcuigregkh
authored andcommitted
net: mana: Validate the packet length reported by the NIC
[ Upstream commit 2e2a83b ] 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 <haiyangz@microsoft.com> Signed-off-by: Dexuan Cui <decui@microsoft.com> Fixes: ca9c54d ("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 <pabeni@redhat.com> Signed-off-by: Sasha Levin <sashal@kernel.org> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 1f0d56d commit 6080189

1 file changed

Lines changed: 13 additions & 0 deletions

File tree

drivers/net/ethernet/microsoft/mana/mana_en.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1724,6 +1724,19 @@ static void mana_process_rx_cqe(struct mana_rxq *rxq, struct mana_cq *cq,
17241724
rxbuf_oob = &rxq->rx_oobs[curr];
17251725
WARN_ON_ONCE(rxbuf_oob->wqe_inf.wqe_size_in_bu != 1);
17261726

1727+
if (unlikely(pktlen > rxq->datasize)) {
1728+
/* Increase it even if mana_rx_skb() isn't called. */
1729+
rxq->rx_cq.work_done++;
1730+
1731+
++ndev->stats.rx_dropped;
1732+
netdev_warn_once(ndev,
1733+
"Dropped oversized RX packet: len=%u, datasize=%u\n",
1734+
pktlen, rxq->datasize);
1735+
1736+
/* Reuse the RX buffer since rxbuf_oob is unchanged. */
1737+
goto drop;
1738+
}
1739+
17271740
mana_refill_rx_oob(dev, rxq, rxbuf_oob, &old_buf, &old_fp);
17281741

17291742
/* Unsuccessful refill will have old_buf == NULL.

0 commit comments

Comments
 (0)