Skip to content

Commit 2f18f62

Browse files
4astborkmann
authored andcommitted
bpf: improve verifier liveness marks
registers with pointers filled from stack were missing live_written marks which caused liveness propagation to unnecessary mark more registers as live_read and miss state pruning opportunities later on. before after bpf_lb-DLB_L3.o 2285 2270 bpf_lb-DLB_L4.o 3723 3682 bpf_lb-DUNKNOWN.o 1110 1110 bpf_lxc-DDROP_ALL.o 27954 27876 bpf_lxc-DUNKNOWN.o 38954 38780 bpf_netdev.o 16943 16937 bpf_overlay.o 7929 7929 Signed-off-by: Alexei Starovoitov <[email protected]> Acked-by: John Fastabend <[email protected]> Acked-by: Daniel Borkmann <[email protected]> Signed-off-by: Daniel Borkmann <[email protected]>
1 parent 19ceb41 commit 2f18f62

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

kernel/bpf/verifier.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -795,6 +795,11 @@ static int check_stack_read(struct bpf_verifier_env *env,
795795
if (value_regno >= 0) {
796796
/* restore register state from stack */
797797
state->regs[value_regno] = state->stack[spi].spilled_ptr;
798+
/* mark reg as written since spilled pointer state likely
799+
* has its liveness marks cleared by is_state_visited()
800+
* which resets stack/reg liveness for state transitions
801+
*/
802+
state->regs[value_regno].live |= REG_LIVE_WRITTEN;
798803
mark_stack_slot_read(state, spi);
799804
}
800805
return 0;

0 commit comments

Comments
 (0)