bpf: track stack depth of classic bpf programs
authorAlexei Starovoitov <ast@fb.com>
Tue, 30 May 2017 20:31:31 +0000 (13:31 -0700)
committerDavid S. Miller <davem@davemloft.net>
Wed, 31 May 2017 23:29:47 +0000 (19:29 -0400)
commit50bbfed96766acb8b9e1b299e3daae5187c3eb5a
tree2486090dff6e58fbabb5cce544219075601e0ac0
parent80a58d02559465b0ea403ff91c8bca9a733b1b0d
bpf: track stack depth of classic bpf programs

To track stack depth of classic bpf programs we only need
to analyze ST|STX instructions, since check_load_and_stores()
verifies that programs can load from stack only after write.

We also need to change the way cBPF stack slots map to eBPF stack,
since typical classic programs are using slots 0 and 1, so they
need to map to stack offsets -4 and -8 respectively in order
to take advantage of small stack interpreter and JITs.

Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Acked-by: Daniel Borkmann <daniel@iogearbox.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
net/core/filter.c