From: Dan Carpenter <dan.carpenter@linaro.org>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: bpf@vger.kernel.org, linux-kselftest@vger.kernel.org
Subject: Re: [bug report] selftest: bpf: Test bpf_sk_assign_tcp_reqsk().
Date: Mon, 19 Aug 2024 22:32:01 +0300 [thread overview]
Message-ID: <54f8f67c-e47f-4da7-9172-d17b5f656587@stanley.mountain> (raw)
In-Reply-To: <20240819191413.23841-1-kuniyu@amazon.com>
On Mon, Aug 19, 2024 at 12:14:13PM -0700, Kuniyuki Iwashima wrote:
> From: Kuniyuki Iwashima <kuniyu@amazon.com>
> Date: Mon, 19 Aug 2024 12:07:04 -0700
> > > > 488 mssind = (cookie & (3 << 6)) >> 6;
> > > > 489 if (ctx->ipv4) {
> > > > 490 if (mssind > ARRAY_SIZE(msstab4))
> > > > ^
> > > > Should be >= instead of >.
> > > >
> > > > 491 goto err;
> > > > 492
> > > > --> 493 ctx->attrs.mss = msstab4[mssind];
> > > > 494 } else {
> > > > 495 if (mssind > ARRAY_SIZE(msstab6))
> > > ^
> > >
> > > Here too, I guess.
> >
> > Thanks for reporting.
> >
> > Will fix it.
> >
> > But I'm curious why BPF verifier couldn't catch it.
>
> Ok, this off-by-one report is false-positive as the test has
>
> mssind = (cookie & (3 << 6)) >> 6;
>
> and the following (mssind > ARRAY_SIZE()) is just to make verifier happy.
In this case, I was testing code that Smatch couldn't parse completely.
But also I have a different check for "> ARRAY_SIZE()" which deliberately
ignores the value of mssind since I was missing "false positive" bugs like this.
regards,
dan carpenter
prev parent reply other threads:[~2024-08-19 19:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-08-19 18:54 [bug report] selftest: bpf: Test bpf_sk_assign_tcp_reqsk() Dan Carpenter
2024-08-19 18:57 ` Dan Carpenter
2024-08-19 19:07 ` Kuniyuki Iwashima
2024-08-19 19:14 ` Kuniyuki Iwashima
2024-08-19 19:32 ` Dan Carpenter [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=54f8f67c-e47f-4da7-9172-d17b5f656587@stanley.mountain \
--to=dan.carpenter@linaro.org \
--cc=bpf@vger.kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kselftest@vger.kernel.org \
/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