diff options
author | Jean-Philippe Brucker <jean-philippe@linaro.org> | 2020-07-28 17:21:26 +0200 |
---|---|---|
committer | Daniel Borkmann <daniel@iogearbox.net> | 2020-07-31 00:43:40 +0200 |
commit | 800834285361dcf8e98b018e891df876472a4fac (patch) | |
tree | 3d71922e36f8eea73368d4cd821143bab2b9b6ad /arch/arm64/mm/extable.c | |
parent | 310ad7970a0dec847563dc6dba9e7e587d545622 (diff) | |
download | lwn-800834285361dcf8e98b018e891df876472a4fac.tar.gz lwn-800834285361dcf8e98b018e891df876472a4fac.zip |
bpf, arm64: Add BPF exception tables
When a tracing BPF program attempts to read memory without using the
bpf_probe_read() helper, the verifier marks the load instruction with
the BPF_PROBE_MEM flag. Since the arm64 JIT does not currently recognize
this flag it falls back to the interpreter.
Add support for BPF_PROBE_MEM, by appending an exception table to the
BPF program. If the load instruction causes a data abort, the fixup
infrastructure finds the exception table and fixes up the fault, by
clearing the destination register and jumping over the faulting
instruction.
To keep the compact exception table entry format, inspect the pc in
fixup_exception(). A more generic solution would add a "handler" field
to the table entry, like on x86 and s390.
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
Acked-by: Song Liu <songliubraving@fb.com>
Link: https://lore.kernel.org/bpf/20200728152122.1292756-2-jean-philippe@linaro.org
Diffstat (limited to 'arch/arm64/mm/extable.c')
-rw-r--r-- | arch/arm64/mm/extable.c | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/arch/arm64/mm/extable.c b/arch/arm64/mm/extable.c index 81e694af5f8c..eee1732ab6cd 100644 --- a/arch/arm64/mm/extable.c +++ b/arch/arm64/mm/extable.c @@ -11,8 +11,14 @@ int fixup_exception(struct pt_regs *regs) const struct exception_table_entry *fixup; fixup = search_exception_tables(instruction_pointer(regs)); - if (fixup) - regs->pc = (unsigned long)&fixup->fixup + fixup->fixup; + if (!fixup) + return 0; - return fixup != NULL; + if (IS_ENABLED(CONFIG_BPF_JIT) && + regs->pc >= BPF_JIT_REGION_START && + regs->pc < BPF_JIT_REGION_END) + return arm64_bpf_fixup_exception(fixup, regs); + + regs->pc = (unsigned long)&fixup->fixup + fixup->fixup; + return 1; } |