From: John Hubbard <jhubbard@nvidia.com>
To: Willem de Bruijn <willemdebruijn.kernel@gmail.com>,
Shuah Khan <shuah@kernel.org>,
richardbgobert@gmail.com
Cc: "David S . Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Steffen Klassert" <steffen.klassert@secunet.com>,
"Herbert Xu" <herbert@gondor.apana.org.au>,
"Andreas Färber" <afaerber@suse.de>,
"Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Matthieu Baerts" <matttbe@kernel.org>,
"Mat Martineau" <martineau@kernel.org>,
"Geliang Tang" <geliang@kernel.org>,
"Pravin B Shelar" <pshelar@ovn.org>,
"Alexander Mikhalitsyn" <alexander@mihalicyn.com>,
zhujun2 <zhujun2@cmss.chinamobile.com>,
"Petr Machata" <petrm@nvidia.com>,
"Ido Schimmel" <idosch@nvidia.com>,
"Hangbin Liu" <liuhangbin@gmail.com>,
"Nikolay Aleksandrov" <razor@blackwall.org>,
"Benjamin Poirier" <bpoirier@nvidia.com>,
"Sebastian Andrzej Siewior" <bigeasy@linutronix.de>,
"Dmitry Safonov" <0x7f454c46@gmail.com>,
netdev@vger.kernel.org, linux-arm-kernel@lists.infradead.org,
linux-actions@lists.infradead.org, mptcp@lists.linux.dev,
dev@openvswitch.org, "Valentin Obst" <kernel@valentinobst.de>,
linux-kselftest@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>,
llvm@lists.linux.dev
Subject: Re: [PATCH 2/2] selftests/net: fix uninitialized variables
Date: Mon, 6 May 2024 11:50:40 -0700 [thread overview]
Message-ID: <fd74de9a-4deb-4fb7-9461-65c38ff1443c@nvidia.com> (raw)
In-Reply-To: <66391ab83771c_516de294d7@willemb.c.googlers.com.notmuch>
On 5/6/24 11:00 AM, Willem de Bruijn wrote:
> John Hubbard wrote:
...
>> diff --git a/tools/testing/selftests/net/gro.c b/tools/testing/selftests/net/gro.c
>> index 353e1e867fbb..0eb61edaad83 100644
>> --- a/tools/testing/selftests/net/gro.c
>> +++ b/tools/testing/selftests/net/gro.c
>> @@ -110,7 +110,8 @@ static void setup_sock_filter(int fd)
>> const int dport_off = tcp_offset + offsetof(struct tcphdr, dest);
>> const int ethproto_off = offsetof(struct ethhdr, h_proto);
>> int optlen = 0;
>> - int ipproto_off, opt_ipproto_off;
>> + int ipproto_off;
>> + int opt_ipproto_off = 0;
>
> This is only intended to be used in the case where the IP proto is not TCP:
>
> BPF_STMT(BPF_LD + BPF_B + BPF_ABS, ipproto_off),
> + BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_TCP, 2, 0),
> + BPF_STMT(BPF_LD + BPF_B + BPF_ABS, opt_ipproto_off),
> BPF_JUMP(BPF_JMP + BPF_JEQ + BPF_K, IPPROTO_TCP, 0, 5),
>
> In that case the test tries again at a different offset that accounts
> for optional IPv6 extension headers.
>
> This is indeed buggy, in that it might accidentally accept packets
> that should be dropped.
>
> Initializing to 0 compares against against the first byte of the
> Ethernet header. Which is an external argument to the test. So
> safest is to initialize opt_ipproto_off to ipproto_off and just
> repeat the previous check. Perhaps:
>
> @@ -118,6 +118,7 @@ static void setup_sock_filter(int fd)
> else
> next_off = offsetof(struct ipv6hdr, nexthdr);
> ipproto_off = ETH_HLEN + next_off;
> + opt_ipproto_off = ipproto_off; /* overridden later if may have exthdrs */
OK, thanks for pointing out the right fix, I'll send a v2 that does that.
thanks,
--
John Hubbard
NVIDIA
prev parent reply other threads:[~2024-05-06 18:50 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-05 22:26 [PATCH 1/2] selftests/net: suppress clang's "variable-sized type not at the end" warning John Hubbard
2024-05-05 22:26 ` [PATCH 2/2] selftests/net: fix uninitialized variables John Hubbard
2024-05-06 7:49 ` Matthieu Baerts
2024-05-06 18:00 ` Willem de Bruijn
2024-05-06 18:50 ` John Hubbard [this message]
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=fd74de9a-4deb-4fb7-9461-65c38ff1443c@nvidia.com \
--to=jhubbard@nvidia.com \
--cc=0x7f454c46@gmail.com \
--cc=afaerber@suse.de \
--cc=alexander@mihalicyn.com \
--cc=bigeasy@linutronix.de \
--cc=bpoirier@nvidia.com \
--cc=davem@davemloft.net \
--cc=dev@openvswitch.org \
--cc=edumazet@google.com \
--cc=geliang@kernel.org \
--cc=herbert@gondor.apana.org.au \
--cc=idosch@nvidia.com \
--cc=kernel@valentinobst.de \
--cc=kuba@kernel.org \
--cc=linux-actions@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=liuhangbin@gmail.com \
--cc=llvm@lists.linux.dev \
--cc=manivannan.sadhasivam@linaro.org \
--cc=martineau@kernel.org \
--cc=matttbe@kernel.org \
--cc=mptcp@lists.linux.dev \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=petrm@nvidia.com \
--cc=pshelar@ovn.org \
--cc=razor@blackwall.org \
--cc=richardbgobert@gmail.com \
--cc=shuah@kernel.org \
--cc=steffen.klassert@secunet.com \
--cc=willemdebruijn.kernel@gmail.com \
--cc=zhujun2@cmss.chinamobile.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