]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
bpf: Rename sanitize_stack_spill to nospec_result
authorLuis Gerhorst <luis.gerhorst@fau.de>
Tue, 3 Jun 2025 21:20:24 +0000 (23:20 +0200)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 10 Jun 2025 03:11:10 +0000 (20:11 -0700)
This is made to clarify that this flag will cause a nospec to be added
after this insn and can therefore be relied upon to reduce speculative
path analysis.

Signed-off-by: Luis Gerhorst <luis.gerhorst@fau.de>
Acked-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
Cc: Henriette Herzog <henriette.herzog@rub.de>
Cc: Maximilian Ott <ott@cs.fau.de>
Cc: Milan Stephan <milan.stephan@fau.de>
Link: https://lore.kernel.org/r/20250603212024.338154-1-luis.gerhorst@fau.de
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
include/linux/bpf_verifier.h
kernel/bpf/verifier.c

index 256274acb1d86e679f04b4e5764fcd23e94a44b7..2b095420222618851d007388615915d42177ee44 100644 (file)
@@ -580,7 +580,7 @@ struct bpf_insn_aux_data {
        u64 map_key_state; /* constant (32 bit) key tracking for maps */
        int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
        u32 seen; /* this insn was processed by the verifier at env->pass_cnt */
-       bool sanitize_stack_spill; /* subject to Spectre v4 sanitation */
+       bool nospec_result; /* result is unsafe under speculation, nospec must follow */
        bool zext_dst; /* this insn zero extends dst reg */
        bool needs_zext; /* alu op needs to clear upper bits */
        bool storage_get_func_atomic; /* bpf_*_storage_get() with atomic memory alloc */
index 04465e317f1008b64cc8268593186d66b9c3483e..79ae0ee395b04ea6530c484266c2808fa09423f8 100644 (file)
@@ -5027,7 +5027,7 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env,
                }
 
                if (sanitize)
-                       env->insn_aux_data[insn_idx].sanitize_stack_spill = true;
+                       env->insn_aux_data[insn_idx].nospec_result = true;
        }
 
        err = destroy_if_dynptr_stack_slot(env, state, spi);
@@ -20930,7 +20930,7 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env)
                }
 
                if (type == BPF_WRITE &&
-                   env->insn_aux_data[i + delta].sanitize_stack_spill) {
+                   env->insn_aux_data[i + delta].nospec_result) {
                        struct bpf_insn patch[] = {
                                *insn,
                                BPF_ST_NOSPEC(),