Re: [PATCH net v2] net: skbuff: make skb_copy_and_csum_bits() report unreadable frags
From: Josef Bacik
Date: Wed Oct 14 2026 - 10:19:38 EST
On Wed, Oct 14, 2026 at 01:51:54PM +0100, David Laight wrote:
> Can't you use that fact that the csum function should only return
> either 0 or ~0 and use the other value to indicate an error.
>
> ISTR this coming up before with the 'copy_to/from_user_and_csum' code.
skb_copy_and_csum_bits() returns an unfolded __wsum starting from 0, so
0 is a valid result today. It would work if it started from ~0 the way
csum_and_copy_from_user() does, since that doesn't change the folded
result and the sum can never come out as 0.
But this is one of those "you have to know the behavior of the function
to use it properly." Explicit errors are always better, it removes
ambiguity and creates cleaner and less error prone code. I'm happy to
change it to start with ~0 as well to add the extra protection, but
explicit errors are always best. Thanks,
Josef