ip: fix csum_sub() with csum_block_sub()
Subsystems (3)
PATCH 1/1 ip: fix csum_sub() with csum_block_sub()
When subtracting the checksum of a block of data, csum_block_sub() must be used to respect the offset.
We learned this lesson from both commit d55bef5059dd
("net: fix pskb_trim_rcsum_slow() with odd trim offset") and commit d48051c5b837 ("net/mlx5e: fix csum adjustments caused by RXFCS").
--- net/ipv4/ip_sockglue.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
net/ipv4/ip_sockglue.c +4 -1
@@ -122,7 +122,10 @@ static void ip_cmsg_recv_checksum(struct msghdr *msg, struct sk_buff *skb,if (offset !=0 ) {int tend_off =skb_transport_offset (skb) + tlen; - csum =csum_sub (csum,skb_checksum (skb, tend_off, offset,0 )); + + csum =csum_block_sub (csum, +skb_checksum (skb, tend_off, offset,0 ), + tend_off); }put_cmsg (msg,SOL_IP ,IP_CHECKSUM ,sizeof (__wsum), &csum);
Signature · 1 line
2.19.1
Quoted 9 lines · Cong Wang
When subtracting the checksum of a block of data,
csum_block_sub()must be used to respect the offset.We learned this lesson from both commit
d55bef5059dd
("net: fixpskb_trim_rcsum_slow()with odd trim offset") and commitd48051c5b837("net/mlx5e: fix csum adjustments caused by RXFCS").Fixes ca4ef4574f1e ("ip: fix IP_CHECKSUM handling")
I do not believe you fix any bug here...
I do not know of any inet protocol having odd header sizes.
Quoted 10 lines · Eric Dumazet
Quoted 8 lines · Cong Wang
When subtracting the checksum of a block of data,
csum_block_sub()must be used to respect the offset.We learned this lesson from both commit
d55bef5059dd
("net: fixpskb_trim_rcsum_slow()with odd trim offset") and commitd48051c5b837("net/mlx5e: fix csum adjustments caused by RXFCS").
Quoted 5 lines
Quoted 1 line
Fixes ca4ef4574f1e ("ip: fix IP_CHECKSUM handling")I do not believe you fix any bug here...
I do not know of any inet protocol having odd header sizes.
That offset is payload offset, but yeah, the payload offset must be aligned some way. Good point!
Let's drop it.