From: sdf@google.com
To: Felix Maurer <fmaurer@redhat.com>
Cc: bpf@vger.kernel.org, ast@kernel.org, andrii@kernel.org,
kafai@fb.com, yauheni.kaliuta@redhat.com, zhuyifei@google.com,
jbenc@redhat.com
Subject: Re: [PATCH bpf-next] selftests: bpf: Less strict size check in sockopt_sk
Date: Tue, 25 Jan 2022 09:14:50 -0800 [thread overview]
Message-ID: <YfAwCh+uA30Ji8wE@google.com> (raw)
In-Reply-To: <6f569cca2e45473f9a724d54d03fdfb45f29e35f.1643129402.git.fmaurer@redhat.com>
On 01/25, Felix Maurer wrote:
> 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.
Looks good, thank you!
Reviewed-by: Stanislav Fomichev <sdf@google.com>
> 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
prev parent reply other threads:[~2022-01-25 17:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
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=YfAwCh+uA30Ji8wE@google.com \
--to=sdf@google.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=fmaurer@redhat.com \
--cc=jbenc@redhat.com \
--cc=kafai@fb.com \
--cc=yauheni.kaliuta@redhat.com \
--cc=zhuyifei@google.com \
/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 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.