netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Petr Machata <petrm@nvidia.com>
To: Petr Machata <petrm@nvidia.com>
Cc: Eric Dumazet <edumazet@google.com>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	<netdev@vger.kernel.org>, David Ahern <dsahern@kernel.org>,
	<mlxsw@nvidia.com>, Ido Schimmel <idosch@nvidia.com>
Subject: Re: [PATCH net] net: nexthop: Initialize all fields in dumped nexthops
Date: Thu, 25 Jul 2024 14:56:47 +0200	[thread overview]
Message-ID: <8734nx8w6s.fsf@nvidia.com> (raw)
In-Reply-To: <877cd98woh.fsf@nvidia.com>


Petr Machata <petrm@nvidia.com> writes:

> Eric Dumazet <edumazet@google.com> writes:
>
>> On Wed, Jul 24, 2024 at 12:09 PM Petr Machata <petrm@nvidia.com> wrote:
>>>
>>>
>>> Eric Dumazet <edumazet@google.com> writes:
>>>
>>> > On Tue, Jul 23, 2024 at 7:41 PM Eric Dumazet <edumazet@google.com> wrote:
>>> >>
>>> >> On Tue, Jul 23, 2024 at 7:26 PM Eric Dumazet <edumazet@google.com> wrote:
>>> >> >
>>> >> > On Tue, Jul 23, 2024 at 6:50 PM Eric Dumazet <edumazet@google.com> wrote:
>>> >> > >
>>> >> > > On Tue, Jul 23, 2024 at 6:05 PM Petr Machata <petrm@nvidia.com> wrote:
>>> >> > > >
>>> >> > > > struct nexthop_grp contains two reserved fields that are not initialized by
>>> >> > > > nla_put_nh_group(), and carry garbage. This can be observed e.g. with
>>> >> > > > strace (edited for clarity):
>>> >> > > >
>>> >> > > >     # ip nexthop add id 1 dev lo
>>> >> > > >     # ip nexthop add id 101 group 1
>>> >> > > >     # strace -e recvmsg ip nexthop get id 101
>>> >> > > >     ...
>>> >> > > >     recvmsg(... [{nla_len=12, nla_type=NHA_GROUP},
>>> >> > > >                  [{id=1, weight=0, resvd1=0x69, resvd2=0x67}]] ...) = 52
>>> >> > > >
>>> >> > > > The fields are reserved and therefore not currently used. But as they are, they
>>> >> > > > leak kernel memory, and the fact they are not just zero complicates repurposing
>>> >> > > > of the fields for new ends. Initialize the full structure.
>>> >> > > >
>>> >> > > > Fixes: 430a049190de ("nexthop: Add support for nexthop groups")
>>> >> > > > Signed-off-by: Petr Machata <petrm@nvidia.com>
>>> >> > > > Reviewed-by: Ido Schimmel <idosch@nvidia.com>
>>> >> > >
>>> >> > > Interesting... not sure why syzbot did not catch this one.
>>>
>>> Could it? I'm not sure of the exact syzcaller capabilities, but there
>>> are no warnings, no splats etc. It just returns values.
>>
>> Yes, KMSAN can detect such things (uninit-value)
>
> But that would involve a splat. There's no splat with this issue, even
> though I'm testing on a CONFIG_HAVE_ARCH_KMSAN kernel.

OK, Ido tells me this is just the "it's available on this arch" option
and the actual option apparently needs clang. So disregard what I said.

  reply	other threads:[~2024-07-25 12:59 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-23 16:04 [PATCH net] net: nexthop: Initialize all fields in dumped nexthops Petr Machata
2024-07-23 16:50 ` Eric Dumazet
2024-07-23 17:26   ` Eric Dumazet
2024-07-23 17:41     ` Eric Dumazet
2024-07-23 17:42       ` Eric Dumazet
2024-07-24  9:12         ` Petr Machata
2024-07-24 10:36           ` Eric Dumazet
2024-07-25 12:42             ` Petr Machata
2024-07-25 12:56               ` Petr Machata [this message]
2024-07-24 14:20 ` patchwork-bot+netdevbpf

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=8734nx8w6s.fsf@nvidia.com \
    --to=petrm@nvidia.com \
    --cc=davem@davemloft.net \
    --cc=dsahern@kernel.org \
    --cc=edumazet@google.com \
    --cc=idosch@nvidia.com \
    --cc=kuba@kernel.org \
    --cc=mlxsw@nvidia.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;
as well as URLs for NNTP newsgroup(s).