public inbox for virtio-comment@lists.linux.dev
 help / color / mirror / Atom feed
From: Paolo Abeni <pabeni@redhat.com>
To: Willem de Bruijn <willemb@google.com>
Cc: virtio-comment@lists.linux.dev, maxime.coquelin@redhat.com,
	Eelco Chaudron <echaudro@redhat.com>,
	Jason Wang <jasowang@redhat.com>,
	Stefano Garzarella <sgarzare@redhat.com>
Subject: Re: [PATCH v7 1/2] virtio-net: define UDP tunnel segmentation offload feature
Date: Thu, 22 Aug 2024 16:25:51 +0200	[thread overview]
Message-ID: <fec4d009-df32-40f4-9741-88a267e430e2@redhat.com> (raw)
In-Reply-To: <CA+FuTSd5PW6D0iSDSYjh3S6OpGCL1Lf95q_=eOfi=APXoBZyOg@mail.gmail.com>



On 8/21/24 21:48, Willem de Bruijn wrote:
>>> +Geneve UDP tunnel (again IPv4) with no tunnel options. Note that the
>>> +only relevant variable related to the tunnel type is the tunnel header length.
>>> +The packet will have a 14 byte outer ethernet header, 20 byte outer IP header
>>> +followed by the 8 byte UDP header (with a 0 checksum value), 8 byte Geneve header,
>>> +14 byte inner ethernet header, 20 byte inner IP header
>>> +and the TCP header (with the TCP checksum field 16 bytes
>>> +into that header). \field{csum_start} will be 14+20+8+8+14+20 = 84 (the TCP
>>> +checksum includes the header), \field{csum_offset} will be 16.
>>
>> The csum_offset field is not even needed in virtio_net_hdr if gso is
>> enabled, as then the gso type already defines the protocol.
> 
> We recently started testing this invariant in the Linux code. We have
> learned the hard way to not trust userspace processes to set up any
> fields correctly.
> 
> For the new fields, we should from the start think of such invariants
> that can detect bad input. For instance,
> 
>      outer_th_offset < inner_nh_offset
>      inner_nh_offset < csum_start
>      csum_start < pkt_len
> 
> Maybe even more stringent invariant checks are possible. The only
> ones that truly matter are the ones that can affect device side
> correctness (such as host kernel crashes).

FTR, I intend to implement something alike:

	outer_th_offset >= 14 + base outer network hdr size
	outer_th_offset + 8 <= inner_nh_offset
	inner_nh_offset + base inner network hdr size  <= csum_start
	csum_start <= pkt_len - base inner transport hdr size

where base inner/outer network hdr size is 20 or 40 depending on ipv4 vs 
ipv6 and base inner transport hdr size is 8 or 20 debending on udp vs tcp.

> Not sure that we have to call them out in the spec, but perhaps
> helpful too. Either way, good to think about possible attacks on
> the new interface even before coding, before the spec is complete.

AFIACS the current spec currently does not describe validation for the 
existing fields subject to such issues (e.g. csum_start/csum_offset). I 
think it could be added in a second moment, if needed.

Thanks,

Paolo


  reply	other threads:[~2024-08-22 14:25 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-08-21 10:02 [PATCH v7 0/2] virtio-net: define UDP tunnel offload Paolo Abeni
2024-08-21 10:02 ` [PATCH v7 1/2] virtio-net: define UDP tunnel segmentation offload feature Paolo Abeni
2024-08-21 19:28   ` Willem de Bruijn
2024-08-21 19:48     ` Willem de Bruijn
2024-08-22 14:25       ` Paolo Abeni [this message]
2024-08-22 14:30         ` Willem de Bruijn
2024-08-22 14:11     ` Paolo Abeni
2024-08-26 12:23       ` [EXTERNAL] " Shiva Shankar Kommula
2024-08-29 15:49         ` Paolo Abeni
2024-09-02 12:31           ` Shiva Shankar Kommula
2024-09-04 14:53             ` Paolo Abeni
2024-08-21 10:02 ` [PATCH v7 2/2] virtio-net: define UDP tunnel checksum " Paolo Abeni
2024-08-21 19:42   ` Willem de Bruijn
2024-08-22 15:18     ` Paolo Abeni
2024-08-22 15:20       ` 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=fec4d009-df32-40f4-9741-88a267e430e2@redhat.com \
    --to=pabeni@redhat.com \
    --cc=echaudro@redhat.com \
    --cc=jasowang@redhat.com \
    --cc=maxime.coquelin@redhat.com \
    --cc=sgarzare@redhat.com \
    --cc=virtio-comment@lists.linux.dev \
    --cc=willemb@google.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