Commit d21001cc authored by Josh Poimboeuf's avatar Josh Poimboeuf Committed by Ingo Molnar

x86/asm/bpf: Create stack frames in bpf_jit.S

bpf_jit.S has several callable non-leaf functions which don't honor
CONFIG_FRAME_POINTER, which can result in bad stack traces.

Create a stack frame before the call instructions when
CONFIG_FRAME_POINTER is enabled.
Signed-off-by: default avatarJosh Poimboeuf <jpoimboe@redhat.com>
Acked-by: default avatarAlexei Starovoitov <ast@kernel.org>
Cc: Andrew Morton <akpm@linux-foundation.org>
Cc: Andy Lutomirski <luto@amacapital.net>
Cc: Andy Lutomirski <luto@kernel.org>
Cc: Arnaldo Carvalho de Melo <acme@kernel.org>
Cc: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Brian Gerst <brgerst@gmail.com>
Cc: Chris J Arges <chris.j.arges@canonical.com>
Cc: Denys Vlasenko <dvlasenk@redhat.com>
Cc: H. Peter Anvin <hpa@zytor.com>
Cc: Jiri Slaby <jslaby@suse.cz>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Michal Marek <mmarek@suse.cz>
Cc: Namhyung Kim <namhyung@gmail.com>
Cc: Pedro Alves <palves@redhat.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Thomas Gleixner <tglx@linutronix.de>
Cc: live-patching@vger.kernel.org
Cc: netdev@vger.kernel.org
Link: http://lkml.kernel.org/r/fa4c41976b438b51954cb8021f06bceb1d1d66cc.1453405861.git.jpoimboe@redhat.comSigned-off-by: default avatarIngo Molnar <mingo@kernel.org>
parent 2d8fe90a
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* of the License. * of the License.
*/ */
#include <linux/linkage.h> #include <linux/linkage.h>
#include <asm/frame.h>
/* /*
* Calling convention : * Calling convention :
...@@ -65,16 +66,18 @@ FUNC(sk_load_byte_positive_offset) ...@@ -65,16 +66,18 @@ FUNC(sk_load_byte_positive_offset)
/* rsi contains offset and can be scratched */ /* rsi contains offset and can be scratched */
#define bpf_slow_path_common(LEN) \ #define bpf_slow_path_common(LEN) \
lea -MAX_BPF_STACK + 32(%rbp), %rdx;\
FRAME_BEGIN; \
mov %rbx, %rdi; /* arg1 == skb */ \ mov %rbx, %rdi; /* arg1 == skb */ \
push %r9; \ push %r9; \
push SKBDATA; \ push SKBDATA; \
/* rsi already has offset */ \ /* rsi already has offset */ \
mov $LEN,%ecx; /* len */ \ mov $LEN,%ecx; /* len */ \
lea - MAX_BPF_STACK + 32(%rbp),%rdx; \
call skb_copy_bits; \ call skb_copy_bits; \
test %eax,%eax; \ test %eax,%eax; \
pop SKBDATA; \ pop SKBDATA; \
pop %r9; pop %r9; \
FRAME_END
bpf_slow_path_word: bpf_slow_path_word:
...@@ -99,6 +102,7 @@ bpf_slow_path_byte: ...@@ -99,6 +102,7 @@ bpf_slow_path_byte:
ret ret
#define sk_negative_common(SIZE) \ #define sk_negative_common(SIZE) \
FRAME_BEGIN; \
mov %rbx, %rdi; /* arg1 == skb */ \ mov %rbx, %rdi; /* arg1 == skb */ \
push %r9; \ push %r9; \
push SKBDATA; \ push SKBDATA; \
...@@ -108,6 +112,7 @@ bpf_slow_path_byte: ...@@ -108,6 +112,7 @@ bpf_slow_path_byte:
test %rax,%rax; \ test %rax,%rax; \
pop SKBDATA; \ pop SKBDATA; \
pop %r9; \ pop %r9; \
FRAME_END; \
jz bpf_error jz bpf_error
bpf_slow_path_word_neg: bpf_slow_path_word_neg:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment