From: Eduard Zingerman <eddyz87@gmail.com>
To: Kumar Kartikeya Dwivedi <memxor@gmail.com>, bpf@vger.kernel.org
Cc: kkd@meta.com, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Manu Bretelle <chantra@meta.com>,
kernel-team@fb.com
Subject: Re: [PATCH bpf v1 2/2] selftests/bpf: Add raw_tp tests for PTR_MAYBE_NULL marking
Date: Wed, 04 Dec 2024 12:12:07 -0800 [thread overview]
Message-ID: <f844604cb8f85688c9faf4bf0c6d5566eba5dcdb.camel@gmail.com> (raw)
In-Reply-To: <20241204024154.21386-3-memxor@gmail.com>
On Tue, 2024-12-03 at 18:41 -0800, Kumar Kartikeya Dwivedi wrote:
[...]
> +/* r2 with offset is checked, which marks r1 with off=0 as non-NULL */
> +SEC("tp_btf/bpf_testmod_test_raw_tp_null")
> +__failure
> +__msg("3: (07) r2 += 8 ; R2_w=trusted_ptr_or_null_sk_buff(id=1,off=8)")
> +__msg("4: (15) if r2 == 0x0 goto pc+2 ; R2_w=trusted_ptr_or_null_sk_buff(id=2,off=8)")
> +__msg("5: (bf) r1 = r1 ; R1_w=trusted_ptr_sk_buff()")
This looks like a bug.
'r1 != 0' does not follow from 'r2 == r1 + 8 and r2 != 0'.
> +int BPF_PROG(test_raw_tp_null_copy_check_with_off, struct sk_buff *skb)
> +{
> + asm volatile (
> + "r1 = *(u64 *)(r1 +0); \
> + r2 = r1; \
> + r3 = 0; \
> + r2 += 8; \
> + if r2 == 0 goto jmp2; \
> + r1 = r1; \
> + *(u64 *)(r3 +0) = r3; \
> + jmp2: "
> + ::
> + : __clobber_all
> + );
> + return 0;
> +}
[...]
next prev parent reply other threads:[~2024-12-04 20:12 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-04 2:41 [PATCH bpf v1 0/2] Fix for raw_tp PTR_MAYBE_NULL unmarking Kumar Kartikeya Dwivedi
2024-12-04 2:41 ` [PATCH bpf v1 1/2] bpf: Suppress warning for non-zero off raw_tp arg NULL check Kumar Kartikeya Dwivedi
2024-12-04 16:37 ` Alexei Starovoitov
2024-12-04 18:55 ` Kumar Kartikeya Dwivedi
2024-12-04 2:41 ` [PATCH bpf v1 2/2] selftests/bpf: Add raw_tp tests for PTR_MAYBE_NULL marking Kumar Kartikeya Dwivedi
2024-12-04 20:12 ` Eduard Zingerman [this message]
2024-12-04 20:19 ` Kumar Kartikeya Dwivedi
2024-12-04 20:22 ` Kumar Kartikeya Dwivedi
2024-12-04 20:40 ` Alexei Starovoitov
2024-12-04 20:48 ` Kumar Kartikeya Dwivedi
2024-12-04 21:08 ` Eduard Zingerman
2024-12-04 21:13 ` Alexei Starovoitov
2024-12-04 21:37 ` Eduard Zingerman
2024-12-04 22:08 ` Kumar Kartikeya Dwivedi
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=f844604cb8f85688c9faf4bf0c6d5566eba5dcdb.camel@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chantra@meta.com \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
--cc=memxor@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox