public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
From: Eduard Zingerman <eddyz87@gmail.com>
To: Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, ast@kernel.org,  daniel@iogearbox.net,
	martin.lau@kernel.org
Cc: kernel-team@meta.com
Subject: Re: [PATCH bpf-next 5/7] bpf: preserve STACK_ZERO slots on partial reg spills
Date: Thu, 09 Nov 2023 17:20:53 +0200	[thread overview]
Message-ID: <8163041bb608879cee598cb6262c04fc18bf226f.camel@gmail.com> (raw)
In-Reply-To: <20231031050324.1107444-6-andrii@kernel.org>

On Mon, 2023-10-30 at 22:03 -0700, Andrii Nakryiko wrote:
> Instead of always forcing STACK_ZERO slots to STACK_MISC, preserve it in
> situations where this is possible. E.g., when spilling register as
> 1/2/4-byte subslots on the stack, all the remaining bytes in the stack
> slot do not automatically become unknown. If we knew they contained
> zeroes, we can preserve those STACK_ZERO markers.
> 
> Add a helper mark_stack_slot_misc(), similar to scrub_spilled_slot(),
> but that doesn't overwrite either STACK_INVALID nor STACK_ZERO. Note
> that we need to take into account possibility of being in unprivileged
> mode, in which case STACK_INVALID is forced to STACK_MISC for correctness,
> as treating STACK_INVALID as equivalent STACK_MISC is only enabled in
> privileged mode.
> 
> Signed-off-by: Andrii Nakryiko <andrii@kernel.org>

Could you please add a test case?

Acked-by: Eduard Zingerman <eddyz87@gmail.com>

[...]

> @@ -1355,6 +1355,21 @@ static void scrub_spilled_slot(u8 *stype)
>  		*stype = STACK_MISC;
>  }
>  
> +/* Mark stack slot as STACK_MISC, unless it is already STACK_INVALID, in which
> + * case they are equivalent, or it's STACK_ZERO, in which case we preserve
> + * more precise STACK_ZERO.
> + * Note, in uprivileged mode leaving STACK_INVALID is wrong, so we take
> + * env->allow_ptr_leaks into account and force STACK_MISC, if necessary.
> + */
> +static void mark_stack_slot_misc(struct bpf_verifier_env *env, u8 *stype)

Nitpick: I find this name misleading, maybe something like "remove_spill_mark"?

[...]



  reply	other threads:[~2023-11-09 15:20 UTC|newest]

Thread overview: 45+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-31  5:03 [PATCH bpf-next 0/7] Complete BPF verifier precision tracking support for register spills Andrii Nakryiko
2023-10-31  5:03 ` [PATCH bpf-next 1/7] bpf: use common jump (instruction) history across all states Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman
2023-11-09 16:13     ` Alexei Starovoitov
2023-11-09 17:28       ` Andrii Nakryiko
2023-11-09 19:29         ` Alexei Starovoitov
2023-11-09 19:49           ` Andrii Nakryiko
2023-11-09 20:39             ` Andrii Nakryiko
2023-11-09 22:05               ` Alexei Starovoitov
2023-11-09 22:57                 ` Andrii Nakryiko
2023-11-11  4:29                   ` Andrii Nakryiko
2023-10-31  5:03 ` [PATCH bpf-next 2/7] bpf: support non-r10 register spill/fill to/from stack in precision tracking Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman
2023-11-09 17:20     ` Andrii Nakryiko
2023-11-09 18:20       ` Eduard Zingerman
2023-11-10  5:48         ` Andrii Nakryiko
2023-11-12  1:57           ` Andrii Nakryiko
2023-11-12 14:05             ` Eduard Zingerman
2023-10-31  5:03 ` [PATCH bpf-next 3/7] bpf: enforce precision for r0 on callback return Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman
2023-11-09 17:32     ` Andrii Nakryiko
2023-11-09 17:38       ` Eduard Zingerman
2023-11-09 17:50         ` Andrii Nakryiko
2023-11-09 17:58           ` Alexei Starovoitov
2023-11-09 18:01             ` Andrii Nakryiko
2023-11-09 18:03               ` Eduard Zingerman
2023-11-09 18:00           ` Eduard Zingerman
2023-10-31  5:03 ` [PATCH bpf-next 4/7] bpf: fix check for attempt to corrupt spilled pointer Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman
2023-10-31  5:03 ` [PATCH bpf-next 5/7] bpf: preserve STACK_ZERO slots on partial reg spills Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman [this message]
2023-11-09 17:37     ` Andrii Nakryiko
2023-11-09 17:54       ` Eduard Zingerman
2023-10-31  5:03 ` [PATCH bpf-next 6/7] bpf: preserve constant zero when doing partial register restore Andrii Nakryiko
2023-11-09 15:20   ` Eduard Zingerman
2023-11-09 17:41     ` Andrii Nakryiko
2023-11-09 19:34       ` Eduard Zingerman
2023-10-31  5:03 ` [PATCH bpf-next 7/7] bpf: track aligned STACK_ZERO cases as imprecise spilled registers Andrii Nakryiko
2023-10-31  5:22   ` Andrii Nakryiko
2023-11-01  7:56     ` Jiri Olsa
2023-11-01 16:27       ` Andrii Nakryiko
2023-11-02  9:54         ` Jiri Olsa
2023-11-09 15:21   ` Eduard Zingerman
2023-11-09 17:43     ` Andrii Nakryiko
2023-11-09 17:44       ` Eduard Zingerman

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=8163041bb608879cee598cb6262c04fc18bf226f.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=kernel-team@meta.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