All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next] selftests: bpf: Less strict size check in sockopt_sk
@ 2022-01-25 16:58 Felix Maurer
  2022-01-25 17:14 ` sdf
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Maurer @ 2022-01-25 16:58 UTC (permalink / raw)
  To: bpf; +Cc: ast, andrii, kafai, yauheni.kaliuta, sdf, zhuyifei, jbenc

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 c8856c0514549, 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 c8856c0514549 in the
selftest, i.e., just check if the required fields are there.

Fixes: 9cacf81f81611 ("bpf: Remove extra lock_sock for TCP_ZEROCOPY_RECEIVE")
Signed-off-by: Felix Maurer <fmaurer@redhat.com>
---
 tools/testing/selftests/bpf/progs/sockopt_sk.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/tools/testing/selftests/bpf/progs/sockopt_sk.c b/tools/testing/selftests/bpf/progs/sockopt_sk.c
index d0298dccedcd..c8d810010a94 100644
--- a/tools/testing/selftests/bpf/progs/sockopt_sk.c
+++ b/tools/testing/selftests/bpf/progs/sockopt_sk.c
@@ -72,7 +72,8 @@ int _getsockopt(struct bpf_sockopt *ctx)
 		 * reasons.
 		 */
 
-		if (optval + sizeof(struct tcp_zerocopy_receive) > optval_end)
+		/* Check that optval contains address (__u64) */
+		if (optval + sizeof(__u64) > optval_end)
 			return 0; /* bounds check */
 
 		if (((struct tcp_zerocopy_receive *)optval)->address != 0)
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-01-25 17:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-01-25 16:58 [PATCH bpf-next] selftests: bpf: Less strict size check in sockopt_sk Felix Maurer
2022-01-25 17:14 ` sdf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.