From: Greg Kroah-Hartman Date: Sun, 15 Dec 2024 12:32:01 +0000 (+0100) Subject: fix up queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch X-Git-Tag: v5.4.288~43 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=5a92fc95c90cb6aa5bef87d084fb0ca63dac2ccf;p=thirdparty%2Fkernel%2Fstable-queue.git fix up queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch --- diff --git a/queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch b/queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch index 51196e89e56..83774860fda 100644 --- a/queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch +++ b/queue-6.12/bpf-augment-raw_tp-arguments-with-ptr_maybe_null.patch @@ -75,15 +75,12 @@ Link: https://lore.kernel.org/r/20241213221929.3495062-3-memxor@gmail.com Signed-off-by: Alexei Starovoitov Signed-off-by: Greg Kroah-Hartman --- - kernel/bpf/btf.c | 138 ++++++++++++++++++ - .../testing/selftests/bpf/progs/raw_tp_null.c | 19 ++- - 2 files changed, 147 insertions(+), 10 deletions(-) + kernel/bpf/btf.c | 138 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ + 1 file changed, 138 insertions(+) -diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c -index c4aa304028ce..e5a5f023cedd 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c -@@ -6439,6 +6439,101 @@ int btf_ctx_arg_offset(const struct btf *btf, const struct btf_type *func_proto, +@@ -6415,6 +6415,101 @@ int btf_ctx_arg_offset(const struct btf return off; } @@ -185,7 +182,7 @@ index c4aa304028ce..e5a5f023cedd 100644 bool btf_ctx_access(int off, int size, enum bpf_access_type type, const struct bpf_prog *prog, struct bpf_insn_access_aux *info) -@@ -6449,6 +6544,7 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, +@@ -6425,6 +6520,7 @@ bool btf_ctx_access(int off, int size, e const char *tname = prog->aux->attach_func_name; struct bpf_verifier_log *log = info->log; const struct btf_param *args; @@ -193,7 +190,7 @@ index c4aa304028ce..e5a5f023cedd 100644 const char *tag_value; u32 nr_args, arg; int i, ret; -@@ -6597,6 +6693,39 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, +@@ -6573,6 +6669,39 @@ bool btf_ctx_access(int off, int size, e if (btf_param_match_suffix(btf, &args[arg], "__nullable")) info->reg_type |= PTR_MAYBE_NULL; @@ -233,7 +230,7 @@ index c4aa304028ce..e5a5f023cedd 100644 if (tgt_prog) { enum bpf_prog_type tgt_type; -@@ -6641,6 +6770,15 @@ bool btf_ctx_access(int off, int size, enum bpf_access_type type, +@@ -6617,6 +6746,15 @@ bool btf_ctx_access(int off, int size, e bpf_log(log, "func '%s' arg%d has btf_id %d type %s '%s'\n", tname, arg, info->btf_id, btf_type_str(t), __btf_name_by_offset(btf, t->name_off)); @@ -249,43 +246,3 @@ index c4aa304028ce..e5a5f023cedd 100644 return true; } EXPORT_SYMBOL_GPL(btf_ctx_access); -diff --git a/tools/testing/selftests/bpf/progs/raw_tp_null.c b/tools/testing/selftests/bpf/progs/raw_tp_null.c -index 457f34c151e3..5927054b6dd9 100644 ---- a/tools/testing/selftests/bpf/progs/raw_tp_null.c -+++ b/tools/testing/selftests/bpf/progs/raw_tp_null.c -@@ -3,6 +3,7 @@ - - #include - #include -+#include "bpf_misc.h" - - char _license[] SEC("license") = "GPL"; - -@@ -17,16 +18,14 @@ int BPF_PROG(test_raw_tp_null, struct sk_buff *skb) - if (task->pid != tid) - return 0; - -- i = i + skb->mark + 1; -- /* The compiler may move the NULL check before this deref, which causes -- * the load to fail as deref of scalar. Prevent that by using a barrier. -+ /* If dead code elimination kicks in, the increment +=2 will be -+ * removed. For raw_tp programs attaching to tracepoints in kernel -+ * modules, we mark input arguments as PTR_MAYBE_NULL, so branch -+ * prediction should never kick in. - */ -- barrier(); -- /* If dead code elimination kicks in, the increment below will -- * be removed. For raw_tp programs, we mark input arguments as -- * PTR_MAYBE_NULL, so branch prediction should never kick in. -- */ -- if (!skb) -- i += 2; -+ asm volatile ("%[i] += 1; if %[ctx] != 0 goto +1; %[i] += 2;" -+ : [i]"+r"(i) -+ : [ctx]"r"(skb) -+ : "memory"); - return 0; - } --- -2.47.1 -