* [Patch net] ip: fix csum_sub() with csum_block_sub()
@ 2018-11-08 22:04 Cong Wang
2018-11-08 22:16 ` Eric Dumazet
0 siblings, 1 reply; 3+ messages in thread
From: Cong Wang @ 2018-11-08 22:04 UTC (permalink / raw)
To: netdev; +Cc: Cong Wang, Paolo Abeni, Eric Dumazet, Willem de Bruijn
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").
Fixes: ca4ef4574f1e ("ip: fix IP_CHECKSUM handling")
Cc: Paolo Abeni <pabeni@redhat.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Willem de Bruijn <willemb@google.com>
Signed-off-by: Cong Wang <xiyou.wangcong@gmail.com>
---
net/ipv4/ip_sockglue.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/net/ipv4/ip_sockglue.c b/net/ipv4/ip_sockglue.c
index fffcc130900e..0d69f0823c08 100644
--- a/net/ipv4/ip_sockglue.c
+++ b/net/ipv4/ip_sockglue.c
@@ -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);
--
2.19.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [Patch net] ip: fix csum_sub() with csum_block_sub()
2018-11-08 22:04 [Patch net] ip: fix csum_sub() with csum_block_sub() Cong Wang
@ 2018-11-08 22:16 ` Eric Dumazet
2018-11-08 22:22 ` Cong Wang
0 siblings, 1 reply; 3+ messages in thread
From: Eric Dumazet @ 2018-11-08 22:16 UTC (permalink / raw)
To: Cong Wang, Dimitris Michailidis; +Cc: netdev, Paolo Abeni, Willem de Bruijn
On Thu, Nov 8, 2018 at 2:04 PM Cong Wang <xiyou.wangcong@gmail.com> wrote:
>
> 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").
>
> 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.
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [Patch net] ip: fix csum_sub() with csum_block_sub()
2018-11-08 22:16 ` Eric Dumazet
@ 2018-11-08 22:22 ` Cong Wang
0 siblings, 0 replies; 3+ messages in thread
From: Cong Wang @ 2018-11-08 22:22 UTC (permalink / raw)
To: Eric Dumazet
Cc: Dimitris Michailidis, Linux Kernel Network Developers,
Paolo Abeni, Willem de Bruijn
On Thu, Nov 8, 2018 at 2:17 PM Eric Dumazet <edumazet@google.com> wrote:
>
> On Thu, Nov 8, 2018 at 2:04 PM Cong Wang <xiyou.wangcong@gmail.com> wrote:
> >
> > 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").
> >
> > 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.
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-11-09 7:59 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-11-08 22:04 [Patch net] ip: fix csum_sub() with csum_block_sub() Cong Wang
2018-11-08 22:16 ` Eric Dumazet
2018-11-08 22:22 ` Cong Wang
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox