Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
- 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;
}
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;
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;
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));
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 <vmlinux.h>
- #include <bpf/bpf_tracing.h>
-+#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
-