Re: [PATCH net-next v5 02/12] net: airoha: Reserve RX headroom to avoid skb reallocation
Lorenzo Bianconi <[email protected]> Mon, 11 May 2026 10:13:29 +0200
| Newsgroups | dev.linux.lists.sashiko,org.kernel.vger.linux-devicetree,org.kernel.vger.netdev |
|---|---|
| Message-ID | <agGPqVvwyCbVbROt@lore-desk> |
On May 10, [email protected] wrote: > Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider: > - [High] Missing bounds check adjustment for RX packet length allows buffer overflows > -- > > commit f34e8812cb62dd63f96801a39b0d65ee905cd258 > Author: Lorenzo Bianconi <[email protected]> > > net: airoha: Reserve RX headroom to avoid skb reallocation > > This commit reserves NET_SKB_PAD + NET_IP_ALIGN bytes of headroom for > received packets to avoid skb head reallocation when pushing protocol > headers into the skb. > > > diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c > > --- a/drivers/net/ethernet/airoha/airoha_eth.c > > +++ b/drivers/net/ethernet/airoha/airoha_eth.c > [ ... ] > > @@ -627,10 +629,12 @@ static int airoha_qdma_rx_process(struct airoha_queue *q, int budget) > > > > port = eth->ports[p]; > > if (!q->skb) { /* first buffer */ > > - q->skb = napi_build_skb(e->buf, q->buf_size); > > + q->skb = napi_build_skb(e->buf - AIROHA_RX_HEADROOM, > > + q->buf_size); > > if (!q->skb) > > goto free_frag; > > > > + skb_reserve(q->skb, AIROHA_RX_HEADROOM); > > __skb_put(q->skb, len); > > Does this code overlook adjusting the bounds check for the RX packet > length? > > Earlier in airoha_qdma_rx_process(), the software validation check > uses the unadjusted lengths: > > data_len = q->skb ? q->buf_size > : SKB_WITH_OVERHEAD(q->buf_size); > if (!len || data_len < len) > goto free_frag; > > If the hardware descriptor returns a len that is larger than the newly > adjusted dma_len but smaller than or equal to the old data_len, the > check will pass. > > Since skb_reserve() shifts the skb->tail forward by AIROHA_RX_HEADROOM, > will calling __skb_put(q->skb, len) with this unvalidated oversized len > push skb->tail past skb->end and overflow the skb_shared_info structure? > > Similarly for scattered fragments, could an oversized len passed to > skb_add_rx_frag() cause out-of-bounds memory accesses beyond the allocated > page fragment? ack, I will fix it in v6. Regards, Lorenzo > > -- > Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=2
signature.asc
(application/pgp-signature, 228 B)
-----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQTquNwa3Txd3rGGn7Y6cBh0uS2trAUCagGPqQAKCRA6cBh0uS2t rO72AQDvA7/niPO4yeyKs0rtSPk8+ow7Dxz9QLxaPhPQyzVw5QD/eRwgM68iCKuS xVwvKSRijfyXRKGUmKBzERC8c8PwHwg= =DNP2 -----END PGP SIGNATURE-----