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 21:57:57 +0300 [thread overview]
Message-ID: <a063a534-0ccf-4192-a15a-732a73dbcbd0@stanley.mountain> (raw)
In-Reply-To: <6ae12487-d3f1-488b-9514-af0dac96608f@stanley.mountain>
On Mon, Aug 19, 2024 at 09:54:00PM +0300, Dan Carpenter wrote:
> Hello Kuniyuki Iwashima,
>
> Commit a74712241b46 ("selftest: bpf: Test
> bpf_sk_assign_tcp_reqsk().") from Jan 15, 2024 (linux-next), leads to
> the following Smatch static checker warning:
>
> tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c:493 tcp_validate_cookie()
> warn: off by one 'mssind' == ARRAY_SIZE()?
>
> ./tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c
> 462 static int tcp_validate_cookie(struct tcp_syncookie *ctx)
> 463 {
> 464 u32 cookie = bpf_ntohl(ctx->tcp->ack_seq) - 1;
> 465 u32 seq = bpf_ntohl(ctx->tcp->seq) - 1;
> 466 u64 first = 0, second;
> 467 int mssind;
> 468 u32 hash;
> 469
> 470 if (ctx->ipv4)
> 471 first = (u64)ctx->ipv4->saddr << 32 | ctx->ipv4->daddr;
> 472 else if (ctx->ipv6)
> 473 first = (u64)ctx->ipv6->saddr.in6_u.u6_addr8[0] << 32 |
> 474 ctx->ipv6->daddr.in6_u.u6_addr32[0];
> 475
> 476 second = (u64)seq << 32 | ctx->tcp->source << 16 | ctx->tcp->dest;
> 477 hash = siphash_2u64(first, second, &test_key_siphash);
> 478
> 479 if (ctx->attrs.tstamp_ok)
> 480 hash -= ctx->attrs.rcv_tsecr & COOKIE_MASK;
> 481 else
> 482 hash &= ~COOKIE_MASK;
> 483
> 484 hash -= cookie & ~COOKIE_MASK;
> 485 if (hash)
> 486 goto err;
> 487
> 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.
regards,
dan carpenter
next prev parent reply other threads:[~2024-08-19 18:58 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 [this message]
2024-08-19 19:07 ` Kuniyuki Iwashima
2024-08-19 19:14 ` Kuniyuki Iwashima
2024-08-19 19:32 ` Dan Carpenter
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=a063a534-0ccf-4192-a15a-732a73dbcbd0@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