From: "Emil Tsalapatis" <emil@etsalapatis.com>
To: "Xu Kuohai" <xukuohai@huaweicloud.com>, <bpf@vger.kernel.org>,
<linux-kernel@vger.kernel.org>
Cc: "Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Stanislav Fomichev" <sdf@fomichev.me>,
"YiFei Zhu" <zhuyifei@google.com>,
"Matt Bobrowski" <mattbobrowski@google.com>,
"Quan Sun" <2022090917019@std.uestc.edu.cn>
Subject: Re: [PATCH bpf v3 2/3] selftests/bpf: Fix cgroup bpf tests broken by bpf_set_retval validation
Date: Mon, 01 Jun 2026 01:45:33 -0400 [thread overview]
Message-ID: <DIXH3R3D33MX.125DN9V9BR7QX@etsalapatis.com> (raw)
In-Reply-To: <20260530101239.590395-3-xukuohai@huaweicloud.com>
On Sat May 30, 2026 at 6:12 AM EDT, Xu Kuohai wrote:
> From: Xu Kuohai <xukuohai@huawei.com>
>
> Add explicit return value checks for cgroup bpf progs rejected by the
> bpf_set_retval validation.
>
> Signed-off-by: Xu Kuohai <xukuohai@huawei.com>
Since these tests are breaking with patch 1 you should put this patch
before them to avoid the breakage in the first place.
> ---
> .../selftests/bpf/progs/cgroup_getset_retval_hooks.c | 6 +++++-
> tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c | 2 ++
> 2 files changed, 7 insertions(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/bpf/progs/cgroup_getset_retval_hooks.c b/tools/testing/selftests/bpf/progs/cgroup_getset_retval_hooks.c
> index 13dfb4bbfd28..c0bfa2d12dc7 100644
> --- a/tools/testing/selftests/bpf/progs/cgroup_getset_retval_hooks.c
> +++ b/tools/testing/selftests/bpf/progs/cgroup_getset_retval_hooks.c
> @@ -2,12 +2,16 @@
>
> #include <linux/bpf.h>
> #include <bpf/bpf_helpers.h>
> +#include <errno.h>
> +#include "err.h"
>
> #define BPF_RETVAL_HOOK(name, section, ctx, expected_err) \
> __attribute__((__section__("?" section))) \
> int name(struct ctx *_ctx) \
> { \
> - bpf_set_retval(bpf_get_retval()); \
> + int val = bpf_get_retval(); \
> + set_if_not_errno_or_zero(val, -EFAULT); \
> + bpf_set_retval(val); \
> return 1; \
> }
>
> diff --git a/tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c b/tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
> index 09a00d11ffcc..bae5283fca6b 100644
> --- a/tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
> +++ b/tools/testing/selftests/bpf/progs/sk_bypass_prot_mem.c
> @@ -5,6 +5,7 @@
> #include <bpf/bpf_helpers.h>
> #include <bpf/bpf_tracing.h>
> #include <errno.h>
> +#include "err.h"
>
> extern int tcp_memory_per_cpu_fw_alloc __ksym;
> extern int udp_memory_per_cpu_fw_alloc __ksym;
> @@ -97,6 +98,7 @@ int sock_create(struct bpf_sock *ctx)
> return 1;
>
> err:
> + set_if_not_errno_or_zero(err, -EFAULT);
> bpf_set_retval(err);
> return 0;
> }
next prev parent reply other threads:[~2026-06-01 5:45 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-30 10:12 [PATCH bpf 0/3] Add validation for bpf_set_retval helper Xu Kuohai
2026-05-30 10:12 ` [PATCH bpf v3 1/3] bpf: Add validation for bpf_set_retval argument Xu Kuohai
2026-05-30 10:12 ` [PATCH bpf v3 2/3] selftests/bpf: Fix cgroup bpf tests broken by bpf_set_retval validation Xu Kuohai
2026-05-30 11:11 ` bot+bpf-ci
2026-06-01 5:45 ` Emil Tsalapatis [this message]
2026-06-01 13:05 ` Xu Kuohai
2026-05-30 10:12 ` [PATCH bpf v3 3/3] selftests/bpf: Add tests for " Xu Kuohai
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=DIXH3R3D33MX.125DN9V9BR7QX@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=2022090917019@std.uestc.edu.cn \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=mattbobrowski@google.com \
--cc=memxor@gmail.com \
--cc=sdf@fomichev.me \
--cc=xukuohai@huaweicloud.com \
--cc=yonghong.song@linux.dev \
--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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®