Commit 033ffaf0 authored by Hari Bathini's avatar Hari Bathini Committed by Michael Ellerman

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: default avatarHari Bathini <hbathini@linux.ibm.com>
Acked-by: default avatarSong Liu <song@kernel.org>
Signed-off-by: default avatarMichael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20231020141358.643575-4-hbathini@linux.ibm.com
parent 6efc1675
......@@ -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;
}
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