diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index c495dc9070de..5c8626215ee6 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c @@ -7484,7 +7484,12 @@ static int check_stack_range_initialized( goto mark; } - if (bpf_is_spilled_reg(ss) && + /* + * Only the bytes marked STACK_SPILL hold the spilled register. + * The rest of a narrowly spilled slot keeps its previous type + * and must be initialized on its own. + */ + if (*stype == STACK_SPILL && (ss->spilled_ptr.type == SCALAR_VALUE || env->allow_ptr_leaks)) { if (clobber) {