diff options
| author | Hari Bathini <[email protected]> | 2023-10-20 14:13:56 +0000 |
|---|---|---|
| committer | Michael Ellerman <[email protected]> | 2023-10-23 09:33:19 +0000 |
| commit | 033ffaf0af1f974ecf401db3f70aae6fe1a90fc5 (patch) | |
| tree | 38d47ece63167b26626246fb3531ab1ccc4247fe /arch/powerpc/net/bpf_jit_comp.c | |
| parent | powerpc/bpf: implement bpf_arch_text_copy (diff) | |
| download | kernel-033ffaf0af1f974ecf401db3f70aae6fe1a90fc5.tar.gz kernel-033ffaf0af1f974ecf401db3f70aae6fe1a90fc5.zip | |
powerpc/bpf: implement bpf_arch_text_invalidate for bpf_prog_pack
Implement bpf_arch_text_invalidate and use it to fill unused part of
the bpf_prog_pack with trap instructions when a BPF program is freed.
Signed-off-by: Hari Bathini <[email protected]>
Acked-by: Song Liu <[email protected]>
Signed-off-by: Michael Ellerman <[email protected]>
Link: https://msgid.link/[email protected]
Diffstat (limited to 'arch/powerpc/net/bpf_jit_comp.c')
| -rw-r--r-- | arch/powerpc/net/bpf_jit_comp.c | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index c21cb88b09e4..0a5a9758903a 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c @@ -292,3 +292,18 @@ void *bpf_arch_text_copy(void *dst, void *src, size_t len) return err ? ERR_PTR(err) : dst; } + +int bpf_arch_text_invalidate(void *dst, size_t len) +{ + u32 insn = BREAKPOINT_INSTRUCTION; + int ret; + + if (WARN_ON_ONCE(core_kernel_text((unsigned long)dst))) + return -EINVAL; + + mutex_lock(&text_mutex); + ret = patch_instructions(dst, &insn, len, true); + mutex_unlock(&text_mutex); + + return ret; +} |
