BPF List
 help / color / mirror / Atom feed
From: Yonghong Song <yonghong.song@linux.dev>
To: Eduard Zingerman <eddyz87@gmail.com>, 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>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Martin KaFai Lau <kafai@fb.com>
Subject: Re: [PATCH bpf-next v3 1/2] bpf: Track aligned st store as imprecise spilled registers
Date: Tue, 9 Jan 2024 10:45:50 -0800	[thread overview]
Message-ID: <4bc16abf-6f3e-41bc-8787-826c1f50d35b@linux.dev> (raw)
In-Reply-To: <de8dd3773d84b4c07fbba2776d52bf2114ca5414.camel@gmail.com>


On 1/9/24 10:02 AM, Eduard Zingerman wrote:
> On Mon, 2024-01-08 at 20:05 -0800, Yonghong Song wrote:
> [...]
>> @@ -4640,7 +4641,18 @@ static int check_stack_write_var_off(struct bpf_verifier_env *env,
>>   			return -EINVAL;
>>   		}
>>   
>> -		/* Erase all spilled pointers. */
>> +		/* If writing_zero and the the spi slot contains a spill of value 0,
>> +		 * maintain the spill type.
>> +		 */
>> +		if (writing_zero && is_spilled_scalar_reg(&state->stack[spi])) {
> As discussed on offlist today, this should probably look as follows:
>
> -               if (writing_zero && is_spilled_scalar_reg(&state->stack[spi])) {
> +               if (writing_zero && *stype == STACK_SPILL && is_spilled_scalar_reg(&state->stack[spi])) {
>
> In order to handle cases like "mmmmSSSS" for slot types.

Thanks Eduard for pointing this out. I did handle this in v2 but missed it in v3.
I will wait a little bit just in case there are some other comments before posting v4
to fix this issue.

>
>> +			spill_reg = &state->stack[spi].spilled_ptr;
>> +			if (tnum_is_const(spill_reg->var_off) && spill_reg->var_off.value == 0) {
>> +				zero_used = true;
>> +				continue;
>> +			}
>> +		}
>> +
>> +		/* Erase all other spilled pointers. */
>>   		state->stack[spi].spilled_ptr.type = NOT_INIT;
>>   
>>   		/* Update the slot type. */
> [...]

  reply	other threads:[~2024-01-09 18:45 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-01-09  4:05 [PATCH bpf-next v3 1/2] bpf: Track aligned st store as imprecise spilled registers Yonghong Song
2024-01-09  4:05 ` [PATCH bpf-next v3 2/2] selftests/bpf: Add a selftest with not-8-byte aligned BPF_ST Yonghong Song
2024-01-09 22:47   ` Andrii Nakryiko
2024-01-10  4:29     ` Yonghong Song
2024-01-09  5:14 ` [PATCH bpf-next v3 1/2] bpf: Track aligned st store as imprecise spilled registers Kuniyuki Iwashima
2024-01-09 18:02 ` Eduard Zingerman
2024-01-09 18:45   ` Yonghong Song [this message]
2024-01-09 22:38 ` Andrii Nakryiko
2024-01-10  4:19   ` Yonghong Song

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=4bc16abf-6f3e-41bc-8787-826c1f50d35b@linux.dev \
    --to=yonghong.song@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=kafai@fb.com \
    --cc=kernel-team@fb.com \
    --cc=kuniyu@amazon.com \
    --cc=martin.lau@kernel.org \
    /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