aboutsummaryrefslogtreecommitdiff
path: root/arch
diff options
context:
space:
mode:
authorSong Liu2022-02-04 10:57:39 -0800
committerAlexei Starovoitov2022-02-07 18:13:01 -0800
commitebc1415d9b4f043cef5a1fb002ec316e32167e7a (patch)
treebfa0fd9b389bc5a2718a5fafeae0ba390d74ea03 /arch
parent0e06b40371682b6b70ed0302a7baec0698ada95c (diff)
bpf: Introduce bpf_arch_text_copy
This will be used to copy JITed text to RO protected module memory. On x86, bpf_arch_text_copy is implemented with text_poke_copy. bpf_arch_text_copy returns pointer to dst on success, and ERR_PTR(errno) on errors. Signed-off-by: Song Liu <song@kernel.org> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/20220204185742.271030-7-song@kernel.org
Diffstat (limited to 'arch')
-rw-r--r--arch/x86/net/bpf_jit_comp.c7
1 files changed, 7 insertions, 0 deletions
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 36f6fc3e6e69..c13d148f7396 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -2412,3 +2412,10 @@ bool bpf_jit_supports_kfunc_call(void)
{
return true;
}
+
+void *bpf_arch_text_copy(void *dst, void *src, size_t len)
+{
+ if (text_poke_copy(dst, src, len) == NULL)
+ return ERR_PTR(-EINVAL);
+ return dst;
+}