public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Yonghong Song <yonghong.song@linux.dev>, bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Andrii Nakryiko <andrii@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	kernel-team@fb.com, Martin KaFai Lau <martin.lau@kernel.org>
Subject: Re: [PATCH bpf-next v3 2/2] selftests/bpf: Add tests with stack ptr register in conditional jmp
Date: Wed, 21 May 2025 12:02:14 -0700	[thread overview]
Message-ID: <6dd9752a-4bec-423d-8936-8757251f2b50@gmail.com> (raw)
In-Reply-To: <20250521170414.2773034-1-yonghong.song@linux.dev>


On 2025-05-21 10:04, Yonghong Song wrote:

[...]

> @@ -178,4 +178,57 @@ __naked int state_loop_first_last_equal(void)
>   	);
>   }
>   
> +__used __naked static void __bpf_cond_op_r10(void)
> +{
> +	asm volatile (
> +	"r2 = 2314885393468386424 ll;"
> +	"goto +0;"
> +	"if r2 <= r10 goto +3;"
> +	"if r1 >= -1835016 goto +0;"
> +	"if r2 <= 8 goto +0;"
> +	"if r3 <= 0 goto +0;"
> +	"exit;"
> +	::: __clobber_all);
> +}
> +
> +SEC("?raw_tp")
> +__success __log_level(2)
> +__msg("8: (bd) if r2 <= r10 goto pc+3")
> +__msg("9: (35) if r1 >= 0xffe3fff8 goto pc+0")
> +__msg("10: (b5) if r2 <= 0x8 goto pc+0")
> +__msg("mark_precise: frame1: last_idx 10 first_idx 0 subseq_idx -1")
> +__msg("mark_precise: frame1: regs=r2 stack= before 9: (35) if r1 >= 0xffe3fff8 goto pc+0")
> +__msg("mark_precise: frame1: regs=r2 stack= before 8: (bd) if r2 <= r10 goto pc+3")
> +__msg("mark_precise: frame1: regs=r2 stack= before 7: (05) goto pc+0")
> +__naked void bpf_cond_op_r10(void)
> +{
> +	asm volatile (
> +	"r3 = 0 ll;"
> +	"call __bpf_cond_op_r10;"
> +	"r0 = 0;"
> +	"exit;"
> +	::: __clobber_all);
> +}

This was probably a part of the repro, but I'm not sure
this test adds much compared to test below.
The changes do not interact with subprogram calls handling.

> +
> +SEC("?raw_tp")
> +__success __log_level(2)
> +__msg("3: (bf) r3 = r10")
> +__msg("4: (bd) if r3 <= r2 goto pc+1")
> +__msg("5: (b5) if r2 <= 0x8 goto pc+2")
> +__msg("mark_precise: frame0: last_idx 5 first_idx 0 subseq_idx -1")
> +__msg("mark_precise: frame0: regs=r2 stack= before 4: (bd) if r3 <= r2 goto pc+1")
> +__msg("mark_precise: frame0: regs=r2 stack= before 3: (bf) r3 = r10")
> +__naked void bpf_cond_op_not_r10(void)
> +{
> +	asm volatile (
> +	"r0 = 0;"
> +	"r2 = 2314885393468386424 ll;"
> +	"r3 = r10;"
> +	"if r3 <= r2 goto +1;"
> +	"if r2 <= 8 goto +2;"

I think it would be good to add two more cases here:
- dst register is pointer to stack
- both src and dst registers are pointers to stack

> +	"r0 = 2 ll;"
> +	"exit;"
> +	::: __clobber_all);
> +}
> +
>   char _license[] SEC("license") = "GPL";

  reply	other threads:[~2025-05-21 19:02 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-05-21 17:04 [PATCH bpf-next v3 1/2] bpf: Do not include stack ptr register in precision backtracking bookkeeping Yonghong Song
2025-05-21 17:04 ` [PATCH bpf-next v3 2/2] selftests/bpf: Add tests with stack ptr register in conditional jmp Yonghong Song
2025-05-21 19:02   ` Eduard Zingerman [this message]
2025-05-21 20:57     ` Yonghong Song
2025-05-21 21:03       ` Eduard Zingerman
2025-05-21 18:55 ` [PATCH bpf-next v3 1/2] bpf: Do not include stack ptr register in precision backtracking bookkeeping Eduard Zingerman
2025-05-21 20:34   ` Yonghong Song
2025-05-21 20:58     ` Eduard Zingerman
2025-05-21 21:35       ` Yonghong Song
2025-05-21 21:59         ` Eduard Zingerman
2025-05-21 22:04           ` Eduard Zingerman
2025-05-21 22:38     ` Andrii Nakryiko
2025-05-21 22:49       ` Eduard Zingerman
2025-05-22  2:53         ` Yonghong Song
2025-05-22 20:05         ` Andrii Nakryiko

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=6dd9752a-4bec-423d-8936-8757251f2b50@gmail.com \
    --to=eddyz87@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=kernel-team@fb.com \
    --cc=martin.lau@kernel.org \
    --cc=yonghong.song@linux.dev \
    /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