From: Jakub Sitnicki <jakub@cloudflare.com>
To: Dan Carpenter <error27@gmail.com>
Cc: oe-kbuild@lists.linux.dev, netdev@vger.kernel.org, lkp@intel.com,
oe-kbuild-all@lists.linux.dev, kernel-team@cloudflare.com,
John Fastabend <john.fastabend@gmail.com>,
Eric Dumazet <edumazet@google.com>,
Daniel Borkmann <daniel@iogearbox.net>,
Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
syzbot+04c21ed96d861dccc5cd@syzkaller.appspotmail.com
Subject: Re: [PATCH bpf 1/3] bpf, sockmap: Check for any of tcp_bpf_prots when cloning a listener
Date: Mon, 16 Jan 2023 12:31:11 +0100 [thread overview]
Message-ID: <87h6wqyaq6.fsf@cloudflare.com> (raw)
In-Reply-To: <Y8UxRmxdqGv92Szw@kadam>
On Mon, Jan 16, 2023 at 02:13 PM +03, Dan Carpenter wrote:
> On Mon, Jan 16, 2023 at 11:09:02AM +0100, Jakub Sitnicki wrote:
[...]
>> Smatch doesn't seem to graps the 2D array concept here. We can make it
>> happy by being explicit but harder on the eyes:
>>
>> if (&tcp_bpf_prots[0][0] <= prot && prot < &tcp_bpf_prots[ARRAY_SIZE(tcp_bpf_prots)][0])
>> newsk->sk_prot = sk->sk_prot_creator;
>
> Huh. I can silence this false positive in Smatch... It never even
> occured to me that this was a two dimensional array (I only have the
> information in the email).
>
No need. Eric's macro helper makes Smatch happy. I'll use it in v2.
>>
>> Clang can do pointer arithmetic on 2D arrays just fine :-)
>
> Heh. I must have an older version of Clang.
>
> CC net/ipv4/tcp_bpf.o
> net/ipv4/tcp_bpf.c:644:41: warning: array index 2 is past the end of the array (that has type 'struct proto[2][4]') [-Warray-bounds]
> if (tcp_bpf_prots[0] <= prot && prot < tcp_bpf_prots[ARRAY_SIZE(tcp_bpf_prots)])
> ^ ~~~~~~~~~~~~~~~~~~~~~~~~~
> net/ipv4/tcp_bpf.c:544:1: note: array 'tcp_bpf_prots' declared here
> static struct proto tcp_bpf_prots[TCP_BPF_NUM_PROTS][TCP_BPF_NUM_CFGS];
> ^
> 1 warning generated.
FWIW, I've checked against:
$ clang --version
clang version 15.0.6 (Fedora 15.0.6-2.fc37)
Gotta keep it fresh to be able to build bpf selftests ;-)
But I sure don't want to break builds with older Clangs.
Thanks for pointing it out.
next prev parent reply other threads:[~2023-01-16 11:34 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-13 14:56 [PATCH bpf 0/3] bpf, sockmap: Fix infinite recursion in sock_map_close Jakub Sitnicki
2023-01-13 14:56 ` [PATCH bpf 1/3] bpf, sockmap: Check for any of tcp_bpf_prots when cloning a listener Jakub Sitnicki
2023-01-14 8:04 ` Dan Carpenter
2023-01-16 10:09 ` Jakub Sitnicki
2023-01-16 10:39 ` Eric Dumazet
2023-01-16 11:27 ` Jakub Sitnicki
2023-01-16 11:13 ` Dan Carpenter
2023-01-16 11:31 ` Jakub Sitnicki [this message]
2023-01-16 11:53 ` Dan Carpenter
2023-01-13 14:56 ` [PATCH bpf 2/3] selftests/bpf: Pass BPF skeleton to sockmap_listen ops tests Jakub Sitnicki
2023-01-13 14:56 ` [PATCH bpf 3/3] selftests/bpf: Cover listener cloning with progs attached to sockmap Jakub Sitnicki
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=87h6wqyaq6.fsf@cloudflare.com \
--to=jakub@cloudflare.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=daniel@iogearbox.net \
--cc=edumazet@google.com \
--cc=error27@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=kernel-team@cloudflare.com \
--cc=lkp@intel.com \
--cc=netdev@vger.kernel.org \
--cc=oe-kbuild-all@lists.linux.dev \
--cc=oe-kbuild@lists.linux.dev \
--cc=syzbot+04c21ed96d861dccc5cd@syzkaller.appspotmail.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).