Skip to content

Commit e0bf462

Browse files
anakryikoAlexei Starovoitov
authored andcommitted
bpf: mark relevant stack slots scratched for register read instructions
When handling instructions that read register slots, mark relevant stack slots as scratched so that verifier log would contain those slots' states, in addition to currently emitted registers with stack slot offsets. Signed-off-by: Andrii Nakryiko <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Alexei Starovoitov <[email protected]>
1 parent 5956f30 commit e0bf462

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4109,6 +4109,7 @@ static void mark_reg_stack_read(struct bpf_verifier_env *env,
41094109
for (i = min_off; i < max_off; i++) {
41104110
slot = -i - 1;
41114111
spi = slot / BPF_REG_SIZE;
4112+
mark_stack_slot_scratched(env, spi);
41124113
stype = ptr_state->stack[spi].slot_type;
41134114
if (stype[slot % BPF_REG_SIZE] != STACK_ZERO)
41144115
break;
@@ -4160,6 +4161,8 @@ static int check_stack_read_fixed_off(struct bpf_verifier_env *env,
41604161
stype = reg_state->stack[spi].slot_type;
41614162
reg = &reg_state->stack[spi].spilled_ptr;
41624163

4164+
mark_stack_slot_scratched(env, spi);
4165+
41634166
if (is_spilled_reg(&reg_state->stack[spi])) {
41644167
u8 spill_size = 1;
41654168

0 commit comments

Comments
 (0)