bpf: fix liveness propagation to parent in spilled stack slots
authorDaniel Borkmann <daniel@iogearbox.net>
Thu, 17 Aug 2017 12:59:40 +0000 (14:59 +0200)
committerDavid S. Miller <davem@davemloft.net>
Thu, 17 Aug 2017 17:15:20 +0000 (10:15 -0700)
Using parent->regs[] when propagating REG_LIVE_READ for spilled regs
doesn't work since parent->regs[] denote the set of normal registers
but not spilled ones. Propagate to the correct regs.

Fixes: dc503a8ad984 ("bpf/verifier: track liveness for pruning")
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Edward Cree <ecree@solarflare.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
kernel/bpf/verifier.c

index 958ba84a99955093581a008c9296238c1a281303..40f669ddb571a3c9525098c6566de42d69de2012 100644 (file)
@@ -3460,7 +3460,7 @@ static bool do_propagate_liveness(const struct bpf_verifier_state *state,
                if (parent->spilled_regs[i].live & REG_LIVE_READ)
                        continue;
                if (state->spilled_regs[i].live == REG_LIVE_READ) {
-                       parent->regs[i].live |= REG_LIVE_READ;
+                       parent->spilled_regs[i].live |= REG_LIVE_READ;
                        touched = true;
                }
        }