bpf, x86: No bpf_arch_text_poke() for kernel text
Subsystems (3)
PATCH 1/1 bpf, x86: No bpf_arch_text_poke() for kernel text
kernel function replies on ftrace to poke kernel functions.
--- arch/x86/net/bpf_jit_comp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)
arch/x86/net/bpf_jit_comp.c +6 -4
@@ -643,10 +643,12 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,int bpf_arch_text_poke (void *ip,enum bpf_text_poke_type t,void *old_addr,void *new_addr) { -if (!is_kernel_text ((long )ip) && - !is_bpf_text_address ((long )ip)) -/* BPF poking in modules is not supported */ -return -EINVAL ; +if (!is_bpf_text_address ((long )ip)) +/* Only poking bpf text is supported. Since kernel function +* entry is set up by ftrace, we reply on ftrace to poke kernel +* functions. BPF poking in modules is not supported. +*/ +return -ENOTSUPP ;/* * See emit_prologue(), for IBT builds the trampoline hook is preceded
Signature · 1 line
2.34.1
Quoted 15 lines · Vincent Li
kernel function replies on ftrace to poke kernel functions.
Signed-off-by Vincent Li <[email protected]>--- arch/x86/net/bpf_jit_comp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)arch/x86/net/bpf_jit_comp.c +0
-0@@ -643,10 +643,12 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,int bpf_arch_text_poke (void *ip,enum bpf_text_poke_type t,void *old_addr,void *new_addr)
arch/x86/net/bpf_jit_comp.c static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t, · line 650
Quoted 10 lines
arch/x86/net/bpf_jit_comp.c +5
-4{ -if (!is_kernel_text ((long )ip) && - !is_bpf_text_address ((long )ip)) -/* BPF poking in modules is not supported */ -return -EINVAL ; +if (!is_bpf_text_address ((long )ip)) +/* Only poking bpf text is supported. Since kernel function +* entry is set up by ftrace, we reply on ftrace to poke kernel +* functions. BPF poking in modules is not supported. +*/
Not true. Pls study kernel/bpf/trampoline.c and how it's used.
pw-bot: cr
Quoted 21 lines · Alexei Starovoitov
Quoted 19 lines · Vincent Li
kernel function replies on ftrace to poke kernel functions.
Signed-off-by Vincent Li <[email protected]>--- arch/x86/net/bpf_jit_comp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)arch/x86/net/bpf_jit_comp.c +0
-3@@ -643,10 +643,12 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,int bpf_arch_text_poke (void *ip,enum bpf_text_poke_type t,void *old_addr,void *new_addr) { -if (!is_kernel_text ((long )ip) && - !is_bpf_text_address ((long )ip)) -/* BPF poking in modules is not supported */
Quoted 9 lines
arch/x86/net/bpf_jit_comp.c static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t, · line 650
Quoted 6 lines
arch/x86/net/bpf_jit_comp.c +5
-1-return -EINVAL ; +if (!is_bpf_text_address ((long )ip)) +/* Only poking bpf text is supported. Since kernel function +* entry is set up by ftrace, we reply on ftrace to poke kernel +* functions. BPF poking in modules is not supported. +*/ Not true. Pls study
kernel/bpf/trampoline.cand how it's used.
oops :). I copied and pasted from arm64 arch/arm64/net/bpf_jit_comp.c and thought it applies to x86 too, sorry about that.
if (!__bpf_address_lookup((unsigned long)ip, &size, &offset, namebuf))
/* Only poking bpf text is supported. Since kernel function
* entry is set up by ftrace, we reply on ftrace to poke kernel
* functions.
*/
return -ENOTSUPP;
Quoted 1 line
pw-bot: cr
Quoted 33 lines · Vincent Li
Quoted 21 lines · Alexei Starovoitov
Quoted 19 lines · Vincent Li
kernel function replies on ftrace to poke kernel functions.
Signed-off-by Vincent Li <[email protected]>--- arch/x86/net/bpf_jit_comp.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-)arch/x86/net/bpf_jit_comp.c +0
-3@@ -643,10 +643,12 @@ static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,int bpf_arch_text_poke (void *ip,enum bpf_text_poke_type t,void *old_addr,void *new_addr) { -if (!is_kernel_text ((long )ip) && - !is_bpf_text_address ((long )ip)) -/* BPF poking in modules is not supported */ Quoted 9 lines
arch/x86/net/bpf_jit_comp.c static int __bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t, · line 650
Quoted 6 lines
arch/x86/net/bpf_jit_comp.c +5
-1-return -EINVAL ; +if (!is_bpf_text_address ((long )ip)) +/* Only poking bpf text is supported. Since kernel function +* entry is set up by ftrace, we reply on ftrace to poke kernel +* functions. BPF poking in modules is not supported. +*/ Not true. Pls study
kernel/bpf/trampoline.cand how it's used.
Quoted 3 lines
oops :). I copied and pasted from arm64
arch/arm64/net/bpf_jit_comp.cand thought it applies to x86 too, sorry about that.
arm64 is different, since it has hw restriction on how far the jump can reach. It has to do a very special dance.