From: Eduard Zingerman <eddyz87@gmail.com>
To: Paul Chaignon <paul.chaignon@gmail.com>, bpf@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>
Subject: Re: [PATCH bpf 3/3] selftest/bpf: Test accesses to ctx padding
Date: Tue, 16 Sep 2025 15:59:36 -0700 [thread overview]
Message-ID: <5546d7d1074c1441a2fa0924eef0cf6eed5b98fc.camel@gmail.com> (raw)
In-Reply-To: <6efe1666f4747c2c0da87467cf1c61910f64a687.1758032885.git.paul.chaignon@gmail.com>
On Tue, 2025-09-16 at 17:19 +0200, Paul Chaignon wrote:
> This patch adds tests covering the various paddings in ctx structures.
> In case of sk_lookup BPF programs, the behavior is a bit different
> because accesses to the padding are explicitly allowed. Other cases
> result in a clear reject from the verifier.
>
> Signed-off-by: Paul Chaignon <paul.chaignon@gmail.com>
> ---
Acked-by: Eduard Zingerman <eddyz87@gmail.com>
[...]
> +#define padding_access(type, ctx, prev_field, sz) \
> + SEC(type) \
> + __description("access on " #ctx " padding after " #prev_field) \
> + __naked void padding_ctx_access_##ctx(void) \
> + { \
> + asm volatile (" \
> + r1 = *(u%[size] *)(r1 + %[off]); \
> + r0 = 0; \
> + exit;" \
> + : \
> + : __imm_const(size, sz * 8), \
^^^^^^
Surprised this works, but nice.
> + __imm_const(off, offsetofend(struct ctx, prev_field)) \
> + : __clobber_all); \
> + }
[...]
next prev parent reply other threads:[~2025-09-16 22:59 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-16 15:17 [PATCH bpf 1/3] bpf: Explicitly check accesses to bpf_sock_addr Paul Chaignon
2025-09-16 15:18 ` [PATCH bpf 2/3] selftests/bpf: Move macros to bpf_misc.h Paul Chaignon
2025-09-16 22:53 ` Eduard Zingerman
2025-09-16 15:19 ` [PATCH bpf 3/3] selftest/bpf: Test accesses to ctx padding Paul Chaignon
2025-09-16 22:59 ` Eduard Zingerman [this message]
2025-09-16 19:44 ` [PATCH bpf 1/3] bpf: Explicitly check accesses to bpf_sock_addr Daniel Borkmann
2025-09-17 7:51 ` Paul Chaignon
2025-09-16 22:45 ` Eduard Zingerman
2025-09-17 8:02 ` Paul Chaignon
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=5546d7d1074c1441a2fa0924eef0cf6eed5b98fc.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=martin.lau@linux.dev \
--cc=paul.chaignon@gmail.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.