Re: [PATCH net-next 5/9] net: skbuff: don't BUG() on leftover length in skb_checksum() and friends

From: Mina Almasry

Date: Fri Oct 09 2026 - 12:38:38 EST


On Tue, Oct 6, 2026 at 10:10 AM Josef Bacik <josef@xxxxxxxxxxxxxx> wrote:
>
> skb_checksum(), skb_crc32c() and __skb_to_sgvec() walk the head, frags
> and frag_list and BUG() if they run out of skb before they run out of
> @len. By then nothing has been read past the end of the skb. The walk
> stopped at the end of the data, and the check only tells us the caller
> asked for a range the skb doesn't have. commit 06a0afcfe2f5 ("xfrm: do
> pskb_pull properly in __xfrm_transport_prep") fixed one such caller that
> crashed in __skb_to_sgvec().
>
> Warn once and return what each function already returns when it can't
> do the work:
>
> - __skb_to_sgvec() returns -EINVAL. Every skb_to_sgvec() caller has
> checked for a negative return since it learned to return -EMSGSIZE.
> - skb_checksum() and skb_crc32c() return 0, as they already do for
> unreadable frags. The resulting checksum is wrong, so the packet
> fails verification on receive or goes out with a bad checksum on
> transmit, rather than taking the machine down.
>
> Assisted-by: LLM
> Signed-off-by: Josef Bacik <josef@xxxxxxxxxxxxxx>


Reviewed-by: Mina Almasry <almasrymina@xxxxxxxxxx>

--
Thanks,
Mina