From: Daniel Borkmann <daniel@iogearbox.net>
To: bpf@vger.kernel.org
Cc: shung-hsi.yu@suse.com, andrii@kernel.org, ast@kernel.org,
kongln9170@gmail.com, Daniel Borkmann <daniel@iogearbox.net>
Subject: [PATCH bpf-next v2 4/6] selftests/bpf: Fix ARG_PTR_TO_LONG {half-,}uninitialized test
Date: Thu, 5 Sep 2024 14:01:26 +0200 [thread overview]
Message-ID: <20240905120128.7322-4-daniel@iogearbox.net> (raw)
In-Reply-To: <20240905120128.7322-1-daniel@iogearbox.net>
The assumption of 'in privileged mode reads from uninitialized stack locations
are permitted' is not quite correct since the verifier was probing for read
access rather than write access. Both tests need to be annotated as __success
for privileged and unprivileged.
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
---
tools/testing/selftests/bpf/progs/verifier_int_ptr.c | 5 +----
1 file changed, 1 insertion(+), 4 deletions(-)
diff --git a/tools/testing/selftests/bpf/progs/verifier_int_ptr.c b/tools/testing/selftests/bpf/progs/verifier_int_ptr.c
index 9fc3fae5cd83..87206803c025 100644
--- a/tools/testing/selftests/bpf/progs/verifier_int_ptr.c
+++ b/tools/testing/selftests/bpf/progs/verifier_int_ptr.c
@@ -8,7 +8,6 @@
SEC("socket")
__description("ARG_PTR_TO_LONG uninitialized")
__success
-__failure_unpriv __msg_unpriv("invalid indirect read from stack R4 off -16+0 size 8")
__naked void arg_ptr_to_long_uninitialized(void)
{
asm volatile (" \
@@ -36,9 +35,7 @@ __naked void arg_ptr_to_long_uninitialized(void)
SEC("socket")
__description("ARG_PTR_TO_LONG half-uninitialized")
-/* in privileged mode reads from uninitialized stack locations are permitted */
-__success __failure_unpriv
-__msg_unpriv("invalid indirect read from stack R4 off -16+4 size 8")
+__success
__retval(0)
__naked void ptr_to_long_half_uninitialized(void)
{
--
2.43.0
next prev parent reply other threads:[~2024-09-05 12:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-05 12:01 [PATCH bpf-next v2 1/6] bpf: Fix helper writes to read-only maps Daniel Borkmann
2024-09-05 12:01 ` [PATCH bpf-next v2 2/6] bpf: Extend check_raw_mode_ok by just probing MEM_UNINIT Daniel Borkmann
2024-09-05 12:01 ` [PATCH bpf-next v2 3/6] bpf: Zero former ARG_PTR_TO_{LONG,INT} args in case of error Daniel Borkmann
2024-09-05 12:01 ` Daniel Borkmann [this message]
2024-09-05 12:01 ` [PATCH bpf-next v2 5/6] selftests/bpf: Rename ARG_PTR_TO_LONG test description Daniel Borkmann
2024-09-05 12:01 ` [PATCH bpf-next v2 6/6] selftests/bpf: Add a test case to write into .rodata Daniel Borkmann
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=20240905120128.7322-4-daniel@iogearbox.net \
--to=daniel@iogearbox.net \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=kongln9170@gmail.com \
--cc=shung-hsi.yu@suse.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