Skip to content

Commit af8a066

Browse files
q2venMartin KaFai Lau
authored and
Martin KaFai Lau
committed
selftest: bpf: Remove mssind boundary check in test_tcp_custom_syncookie.c.
Smatch reported a possible off-by-one in tcp_validate_cookie(). However, it's false positive because the possible range of mssind is limited from 0 to 3 by the preceding calculation. mssind = (cookie & (3 << 6)) >> 6; Now, the verifier does not complain without the boundary check. Let's remove the checks. Reported-by: Dan Carpenter <[email protected]> Closes: https://lore.kernel.org/bpf/[email protected]/ Signed-off-by: Kuniyuki Iwashima <[email protected]> Acked-by: Yonghong Song <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Martin KaFai Lau <[email protected]>
1 parent db16377 commit af8a066

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

tools/testing/selftests/bpf/progs/test_tcp_custom_syncookie.c

+2-9
Original file line numberDiff line numberDiff line change
@@ -486,17 +486,10 @@ static int tcp_validate_cookie(struct tcp_syncookie *ctx)
486486
goto err;
487487

488488
mssind = (cookie & (3 << 6)) >> 6;
489-
if (ctx->ipv4) {
490-
if (mssind > ARRAY_SIZE(msstab4))
491-
goto err;
492-
489+
if (ctx->ipv4)
493490
ctx->attrs.mss = msstab4[mssind];
494-
} else {
495-
if (mssind > ARRAY_SIZE(msstab6))
496-
goto err;
497-
491+
else
498492
ctx->attrs.mss = msstab6[mssind];
499-
}
500493

501494
ctx->attrs.snd_wscale = cookie & BPF_SYNCOOKIE_WSCALE_MASK;
502495
ctx->attrs.rcv_wscale = ctx->attrs.snd_wscale;

0 commit comments

Comments
 (0)