linux-hardening.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Gal Pressman <gal@nvidia.com>
To: Ilya Maximets <i.maximets@ovn.org>,
	netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Andrew Lunn <andrew+netdev@lunn.ch>
Cc: dev@openvswitch.org,
	"Gustavo A. R. Silva" <gustavoars@kernel.org>,
	Jiri Pirko <jiri@resnulli.us>,
	Jamal Hadi Salim <jhs@mojatatu.com>, Kees Cook <kees@kernel.org>,
	David Ahern <dsahern@kernel.org>, Yotam Gigi <yotam.gi@gmail.com>,
	Tariq Toukan <tariqt@nvidia.com>,
	linux-hardening@vger.kernel.org, Simon Horman <horms@kernel.org>,
	Cong Wang <xiyou.wangcong@gmail.com>,
	Cosmin Ratiu <cratiu@nvidia.com>
Subject: Re: [ovs-dev] [PATCH net-next] net: Add options as a flexible array to struct ip_tunnel_info
Date: Sun, 9 Feb 2025 21:37:59 +0200	[thread overview]
Message-ID: <fe814549-3bd4-4ef6-8e7d-9d21626766e1@nvidia.com> (raw)
In-Reply-To: <2ef88acc-d4d7-4309-8c14-73ac107d1d07@ovn.org>

Hi Ilya, thanks for the review.

On 09/02/2025 18:21, Ilya Maximets wrote:
> On 2/9/25 11:18, Gal Pressman via dev wrote:
>> Remove the hidden assumption that options are allocated at the end of
>> the struct, and teach the compiler about them using a flexible array.
>>
>> With this, we can revert the unsafe_memcpy() call we have in
>> tun_dst_unclone() [1], and resolve the false field-spanning write
>> warning caused by the memcpy() in ip_tunnel_info_opts_set().
>>
>> Note that this patch changes the layout of struct ip_tunnel_info since
>> there is padding at the end of the struct.
>> Before this, options would be written at 'info + 1' which is after the
>> padding.
>> After this patch, options are written right after 'mode' field (into the
>> padding).
> 
> This doesn't sound like a safe thing to do.  'info + 1' ensures that the
> options are aligned the same way as the struct ip_tunnel_info itself.

What is special about the alignment of struct ip_tunnel_info? What are
you assuming it to be, and how is it related to whatever alignment the
options need?

> In many places in the code, the options are cast into a specific tunnel
> options type that may require sufficient alignment.  And the alignment can
> no longer be guaranteed once the options are put directly after the 'mode'.

What guaranteed it was aligned before? A hidden assumption that a u64 is
hidden somewhere in ip_tunnel_info?

> May cause crashes on some architectures as well as performance impact on
> others.
> 
> Should the alignment attribute be also added to the field?

Align to what?
To the first field of every potential options type? To eight bytes?

  reply	other threads:[~2025-02-09 19:38 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-09 10:18 [PATCH net-next] net: Add options as a flexible array to struct ip_tunnel_info Gal Pressman
2025-02-09 16:21 ` [ovs-dev] " Ilya Maximets
2025-02-09 19:37   ` Gal Pressman [this message]
2025-02-09 20:16     ` Ilya Maximets
2025-02-11 15:38       ` Gal Pressman
2025-02-11 17:49 ` Kees Cook
2025-02-11 18:59   ` Gal Pressman
2025-02-12  0:28     ` Jakub Kicinski

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=fe814549-3bd4-4ef6-8e7d-9d21626766e1@nvidia.com \
    --to=gal@nvidia.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=cratiu@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dev@openvswitch.org \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=gustavoars@kernel.org \
    --cc=horms@kernel.org \
    --cc=i.maximets@ovn.org \
    --cc=jhs@mojatatu.com \
    --cc=jiri@resnulli.us \
    --cc=kees@kernel.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=tariqt@nvidia.com \
    --cc=xiyou.wangcong@gmail.com \
    --cc=yotam.gi@gmail.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;
as well as URLs for NNTP newsgroup(s).