Netdev List
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	"luwei (O)" <luwei32@huawei.com>,
	Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
	Eric Dumazet <edumazet@google.com>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	"kuba@kernel.org" <kuba@kernel.org>,
	"pabeni@redhat.com" <pabeni@redhat.com>,
	"asml.silence@gmail.com" <asml.silence@gmail.com>,
	"imagedong@tencent.com" <imagedong@tencent.com>,
	"brouer@redhat.com" <brouer@redhat.com>,
	"keescook@chromium.org" <keescook@chromium.org>,
	"jbenc@redhat.com" <jbenc@redhat.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: RE: 答复: [PATCH net] net: Add check for csum_start in skb_partial_csum_set()
Date: Fri, 14 Apr 2023 13:20:12 -0400	[thread overview]
Message-ID: <64398b4c4585f_17abe429442@willemb.c.googlers.com.notmuch> (raw)
In-Reply-To: <643983f69b440_17854f2948c@willemb.c.googlers.com.notmuch>

Willem de Bruijn wrote:
> luwei (O) wrote:
> > yes, here is the vnet_hdr:
> > 
> >     flags: 3
> >     gso_type: 3
> >     hdr_len: 23
> >     gso_size: 58452
> >     csum_start: 5
> >     csum_offset: 16
> > 
> > and the packet:
> > 
> > | vnet_hdr | mac header | network header | data ... |
> > 
> >   memcpy((void*)0x20000200,
> >          "\x03\x03\x02\x00\x54\xe4\x05\x00\x10\x00\x80\x00\x00\x53\xcc\x9c\x2b"
> >          "\x19\x3b\x00\x00\x00\x89\x4f\x08\x03\x83\x81\x04",
> >          29);
> >   *(uint16_t*)0x200000c0 = 0x11;
> >   *(uint16_t*)0x200000c2 = htobe16(0);
> >   *(uint32_t*)0x200000c4 = r[3];
> >   *(uint16_t*)0x200000c8 = 1;
> >   *(uint8_t*)0x200000ca = 0;
> >   *(uint8_t*)0x200000cb = 6;
> >   memset((void*)0x200000cc, 170, 5);
> >   *(uint8_t*)0x200000d1 = 0;
> >   memset((void*)0x200000d2, 0, 2);
> >   syscall(__NR_sendto, r[1], 0x20000200ul, 0xe45ful, 0ul, 0x200000c0ul, 0x14ul);
> 
> Thanks. So this can happen whenever a packet is injected into the tx
> path with a virtio_net_hdr.
> 
> Even if we add bounds checking for the link layer header in pf_packet,
> it can still point to the network header.
> 
> If packets are looped to the tx path, skb_pull is common if a packet
> traverses tunnel devices. But csum_start does not directly matter in
> the rx path (CHECKSUM_PARTIAL is just seen as CHECKSUM_UNNECESSARY).
> Until it is forwarded again to the tx path.
> 
> So the question is which code calls skb_checksum_start_offset on the
> tx path. Clearly, skb_checksum_help. Also a lot of drivers. Which
> may cast the signed int return value to an unsigned. Even an u8 in 
> the first driver I spotted (alx).
> 
> skb_postpull_rcsum anticipates a negative return value, as do other
> core functions. So it clearly allowed in certain cases. We cannot
> just bound it.
> 
> Summary after a long story: an initial investigation, but I don't have
> a good solution so far. Maybe others have a good suggestiong based on
> this added context.

Specific to skb_checksum_help, it appears that skb_checksum will
work with negative offset just fine.

Perhaps the only issue is that the WARN_ON_ONCE compares signed to
unsigned, and thus incorrectly interprets a negative offset as
 >= skb_headlen(skb)

  reply	other threads:[~2023-04-14 17:20 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-10  2:21 [PATCH net] net: Add check for csum_start in skb_partial_csum_set() Lu Wei
2023-04-10 13:02 ` Eric Dumazet
2023-04-10 17:30   ` Willem de Bruijn
     [not found]     ` <450994d7-4a77-99df-6317-b535ea73e01d@huawei.com>
2023-04-11  8:13       ` Eric Dumazet
2023-04-11 13:50         ` luwei (O)
2023-04-11 14:03         ` luwei (O)
2023-04-12 13:44           ` Willem de Bruijn
2023-04-14  8:45             ` 答复: " luwei (O)
2023-04-14 16:48               ` Willem de Bruijn
2023-04-14 17:20                 ` Willem de Bruijn [this message]
2023-04-15  2:18                   ` luwei (O)
2023-04-15 13:47                     ` Willem de Bruijn
2023-04-18  1:59                       ` luwei (O)
2023-04-18 12:44                         ` Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=64398b4c4585f_17abe429442@willemb.c.googlers.com.notmuch \
    --to=willemdebruijn.kernel@gmail.com \
    --cc=asml.silence@gmail.com \
    --cc=brouer@redhat.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=imagedong@tencent.com \
    --cc=jbenc@redhat.com \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=luwei32@huawei.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox