Skip to content

Commit 9124a45

Browse files
luisgerhorstAlexei Starovoitov
authored andcommitted
bpf: Rename sanitize_stack_spill to nospec_result
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 <[email protected]> Acked-by: Kumar Kartikeya Dwivedi <[email protected]> Cc: Henriette Herzog <[email protected]> Cc: Maximilian Ott <[email protected]> Cc: Milan Stephan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent dff883d commit 9124a45

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

include/linux/bpf_verifier.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,7 @@ struct bpf_insn_aux_data {
580580
u64 map_key_state; /* constant (32 bit) key tracking for maps */
581581
int ctx_field_size; /* the ctx field size for load insn, maybe 0 */
582582
u32 seen; /* this insn was processed by the verifier at env->pass_cnt */
583-
bool sanitize_stack_spill; /* subject to Spectre v4 sanitation */
583+
bool nospec_result; /* result is unsafe under speculation, nospec must follow */
584584
bool zext_dst; /* this insn zero extends dst reg */
585585
bool needs_zext; /* alu op needs to clear upper bits */
586586
bool storage_get_func_atomic; /* bpf_*_storage_get() with atomic memory alloc */

kernel/bpf/verifier.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5027,7 +5027,7 @@ static int check_stack_write_fixed_off(struct bpf_verifier_env *env,
50275027
}
50285028

50295029
if (sanitize)
5030-
env->insn_aux_data[insn_idx].sanitize_stack_spill = true;
5030+
env->insn_aux_data[insn_idx].nospec_result = true;
50315031
}
50325032

50335033
err = destroy_if_dynptr_stack_slot(env, state, spi);
@@ -20930,7 +20930,7 @@ static int convert_ctx_accesses(struct bpf_verifier_env *env)
2093020930
}
2093120931

2093220932
if (type == BPF_WRITE &&
20933-
env->insn_aux_data[i + delta].sanitize_stack_spill) {
20933+
env->insn_aux_data[i + delta].nospec_result) {
2093420934
struct bpf_insn patch[] = {
2093520935
*insn,
2093620936
BPF_ST_NOSPEC(),

0 commit comments

Comments
 (0)