* [PATCH bpf-next] bpf: Fix bpf jit kallsym access
@ 2019-10-30 23:30 Alexei Starovoitov
2019-10-31 1:03 ` Daniel Borkmann
2019-10-31 10:22 ` Jiri Olsa
0 siblings, 2 replies; 3+ messages in thread
From: Alexei Starovoitov @ 2019-10-30 23:30 UTC (permalink / raw)
To: davem; +Cc: daniel, jolsa, netdev, bpf, kernel-team
Jiri reported crash when JIT is on, but net.core.bpf_jit_kallsyms is off.
bpf_prog_kallsyms_find() was skipping addr->bpf_prog resolution
logic in oops and stack traces. That's incorrect.
It should only skip addr->name resolution for 'cat /proc/kallsyms'.
That's what bpf_jit_kallsyms and bpf_jit_harden protect.
Reported-by: Jiri Olsa <jolsa@redhat.com>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Fixes: 3dec541b2e63 ("bpf: Add support for BTF pointers to x86 JIT")
---
kernel/bpf/core.c | 3 ---
1 file changed, 3 deletions(-)
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 673f5d40a93e..8d3fbc86ca5e 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -668,9 +668,6 @@ static struct bpf_prog *bpf_prog_kallsyms_find(unsigned long addr)
{
struct latch_tree_node *n;
- if (!bpf_jit_kallsyms_enabled())
- return NULL;
-
n = latch_tree_find((void *)addr, &bpf_tree, &bpf_tree_ops);
return n ?
container_of(n, struct bpf_prog_aux, ksym_tnode)->prog :
--
2.17.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix bpf jit kallsym access
2019-10-30 23:30 [PATCH bpf-next] bpf: Fix bpf jit kallsym access Alexei Starovoitov
@ 2019-10-31 1:03 ` Daniel Borkmann
2019-10-31 10:22 ` Jiri Olsa
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2019-10-31 1:03 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, jolsa, netdev, bpf, kernel-team
On Wed, Oct 30, 2019 at 04:30:19PM -0700, Alexei Starovoitov wrote:
> Jiri reported crash when JIT is on, but net.core.bpf_jit_kallsyms is off.
> bpf_prog_kallsyms_find() was skipping addr->bpf_prog resolution
> logic in oops and stack traces. That's incorrect.
> It should only skip addr->name resolution for 'cat /proc/kallsyms'.
> That's what bpf_jit_kallsyms and bpf_jit_harden protect.
>
> Reported-by: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> Fixes: 3dec541b2e63 ("bpf: Add support for BTF pointers to x86 JIT")
ACK makes sense, applied, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH bpf-next] bpf: Fix bpf jit kallsym access
2019-10-30 23:30 [PATCH bpf-next] bpf: Fix bpf jit kallsym access Alexei Starovoitov
2019-10-31 1:03 ` Daniel Borkmann
@ 2019-10-31 10:22 ` Jiri Olsa
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Olsa @ 2019-10-31 10:22 UTC (permalink / raw)
To: Alexei Starovoitov; +Cc: davem, daniel, netdev, bpf, kernel-team
On Wed, Oct 30, 2019 at 04:30:19PM -0700, Alexei Starovoitov wrote:
> Jiri reported crash when JIT is on, but net.core.bpf_jit_kallsyms is off.
> bpf_prog_kallsyms_find() was skipping addr->bpf_prog resolution
> logic in oops and stack traces. That's incorrect.
> It should only skip addr->name resolution for 'cat /proc/kallsyms'.
> That's what bpf_jit_kallsyms and bpf_jit_harden protect.
>
> Reported-by: Jiri Olsa <jolsa@redhat.com>
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
> Fixes: 3dec541b2e63 ("bpf: Add support for BTF pointers to x86 JIT")
it fixes the crash for me, thanks for quick fix
jirka
> ---
> kernel/bpf/core.c | 3 ---
> 1 file changed, 3 deletions(-)
>
> diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
> index 673f5d40a93e..8d3fbc86ca5e 100644
> --- a/kernel/bpf/core.c
> +++ b/kernel/bpf/core.c
> @@ -668,9 +668,6 @@ static struct bpf_prog *bpf_prog_kallsyms_find(unsigned long addr)
> {
> struct latch_tree_node *n;
>
> - if (!bpf_jit_kallsyms_enabled())
> - return NULL;
> -
> n = latch_tree_find((void *)addr, &bpf_tree, &bpf_tree_ops);
> return n ?
> container_of(n, struct bpf_prog_aux, ksym_tnode)->prog :
> --
> 2.17.1
>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-10-31 10:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-10-30 23:30 [PATCH bpf-next] bpf: Fix bpf jit kallsym access Alexei Starovoitov
2019-10-31 1:03 ` Daniel Borkmann
2019-10-31 10:22 ` Jiri Olsa
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.