Commit af8a066f authored by Kuniyuki Iwashima's avatar Kuniyuki Iwashima Committed by Martin KaFai Lau

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: default avatarDan Carpenter <dan.carpenter@linaro.org>
Closes: https://lore.kernel.org/bpf/6ae12487-d3f1-488b-9514-af0dac96608f@stanley.mountain/Signed-off-by: default avatarKuniyuki Iwashima <kuniyu@amazon.com>
Acked-by: default avatarYonghong Song <yonghong.song@linux.dev>
Link: https://lore.kernel.org/r/20240821013425.49316-1-kuniyu@amazon.comSigned-off-by: default avatarMartin KaFai Lau <martin.lau@kernel.org>
parent db163778
...@@ -486,17 +486,10 @@ static int tcp_validate_cookie(struct tcp_syncookie *ctx) ...@@ -486,17 +486,10 @@ static int tcp_validate_cookie(struct tcp_syncookie *ctx)
goto err; goto err;
mssind = (cookie & (3 << 6)) >> 6; mssind = (cookie & (3 << 6)) >> 6;
if (ctx->ipv4) { if (ctx->ipv4)
if (mssind > ARRAY_SIZE(msstab4))
goto err;
ctx->attrs.mss = msstab4[mssind]; ctx->attrs.mss = msstab4[mssind];
} else { else
if (mssind > ARRAY_SIZE(msstab6))
goto err;
ctx->attrs.mss = msstab6[mssind]; ctx->attrs.mss = msstab6[mssind];
}
ctx->attrs.snd_wscale = cookie & BPF_SYNCOOKIE_WSCALE_MASK; ctx->attrs.snd_wscale = cookie & BPF_SYNCOOKIE_WSCALE_MASK;
ctx->attrs.rcv_wscale = ctx->attrs.snd_wscale; ctx->attrs.rcv_wscale = ctx->attrs.snd_wscale;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment