Skip to content

Commit fc1ca95

Browse files
fmaurer-rhAlexei Starovoitov
authored andcommitted
selftests: bpf: Less strict size check in sockopt_sk
Originally, the kernel strictly checked the size of the optval in getsockopt(TCP_ZEROCOPY_RECEIVE) to be equal to sizeof(struct tcp_zerocopy_receive). With c8856c0, this was changed to allow optvals of different sizes. The bpf code in the sockopt_sk test was still performing the strict size check. This fix adapts the kernel behavior from c8856c0 in the selftest, i.e., just check if the required fields are there. Fixes: 9cacf81 ("bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE") Signed-off-by: Felix Maurer <[email protected]> Reviewed-by: Stanislav Fomichev <[email protected]> Link: https://lore.kernel.org/r/6f569cca2e45473f9a724d54d03fdfb45f29e35f.1643129402.git.fmaurer@redhat.com Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 451c426 commit fc1ca95

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ int _getsockopt(struct bpf_sockopt *ctx)
7272
* reasons.
7373
*/
7474

75-
if (optval + sizeof(struct tcp_zerocopy_receive) > optval_end)
75+
/* Check that optval contains address (__u64) */
76+
if (optval + sizeof(__u64) > optval_end)
7677
return 0; /* bounds check */
7778

7879
if (((struct tcp_zerocopy_receive *)optval)->address != 0)

0 commit comments

Comments
 (0)