aboutsummaryrefslogtreecommitdiffstats
path: root/include/linux/bpf.h
diff options
context:
space:
mode:
authorDaniel Borkmann <daniel@iogearbox.net>2019-11-24 01:39:42 +0100
committerAlexei Starovoitov <ast@kernel.org>2019-11-24 17:12:11 -0800
commitb553a6ec570044fc1ae300c6fb24f9ce204c5894 (patch)
tree6121de7c1e38050fd9d4d46480ae6fddf9d585b2 /include/linux/bpf.h
parentbpf: Introduce BPF_TRACE_x helper for the tracing tests (diff)
downloadlinux-dev-b553a6ec570044fc1ae300c6fb24f9ce204c5894.tar.xz
linux-dev-b553a6ec570044fc1ae300c6fb24f9ce204c5894.zip
bpf: Simplify __bpf_arch_text_poke poke type handling
Given that we have BPF_MOD_NOP_TO_{CALL,JUMP}, BPF_MOD_{CALL,JUMP}_TO_NOP and BPF_MOD_{CALL,JUMP}_TO_{CALL,JUMP} poke types and that we also pass in old_addr as well as new_addr, it's a bit redundant and unnecessarily complicates __bpf_arch_text_poke() itself since we can derive the same from the *_addr that were passed in. Hence simplify and use BPF_MOD_{CALL,JUMP} as types which also allows to clean up call-sites. In addition to that, __bpf_arch_text_poke() currently verifies that text matches expected old_insn before we invoke text_poke_bp(). Also add a check on new_insn and skip rewrite if it already matches. Reason why this is rather useful is that it avoids making any special casing in prog_array_map_poke_run() when old and new prog were NULL and has the benefit that also for this case we perform a check on text whether it really matches our expectations. Suggested-by: Andrii Nakryiko <andriin@fb.com> Signed-off-by: Daniel Borkmann <daniel@iogearbox.net> Signed-off-by: Alexei Starovoitov <ast@kernel.org> Link: https://lore.kernel.org/bpf/fcb00a2b0b288d6c73de4ef58116a821c8fe8f2f.1574555798.git.daniel@iogearbox.net
Diffstat (limited to 'include/linux/bpf.h')
-rw-r--r--include/linux/bpf.h10
1 files changed, 2 insertions, 8 deletions
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index c2f07fd410c1..35903f148be5 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1324,14 +1324,8 @@ static inline u32 bpf_xdp_sock_convert_ctx_access(enum bpf_access_type type,
#endif /* CONFIG_INET */
enum bpf_text_poke_type {
- /* All call-related pokes. */
- BPF_MOD_NOP_TO_CALL,
- BPF_MOD_CALL_TO_CALL,
- BPF_MOD_CALL_TO_NOP,
- /* All jump-related pokes. */
- BPF_MOD_NOP_TO_JUMP,
- BPF_MOD_JUMP_TO_JUMP,
- BPF_MOD_JUMP_TO_NOP,
+ BPF_MOD_CALL,
+ BPF_MOD_JUMP,
};
int bpf_arch_text_poke(void *ip, enum bpf_text_poke_type t,