History

Merge git://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next

Alexei Starovoitov says: ==================== pull-request: bpf-next 2021-12-30 The following pull-request contains BPF updates for your *net-next* tree. We've added 72 non-merge commits during the last 20 day(s) which contain a total of 223 files changed, 3510 insertions(+), 1591 deletions(-). The main changes are: 1) Automatic setrlimit in libbpf when bpf is memcg's in the kernel, from Andrii. 2) Beautify and de-verbose verifier logs, from Christy. 3) Composable verifier types, from Hao. 4) bpf_strncmp helper, from Hou. 5) bpf.h header dependency cleanup, from Jakub. 6) get_func_[arg|ret|arg_cnt] helpers, from Jiri. 7) Sleepable local storage, from KP. 8) Extend kfunc with PTR_TO_CTX, PTR_TO_MEM argument support, from Kumar. ====================

David S. Miller committed 4 years ago

Commit e63a0232 parents ce2b6eb 9e6b19a221 files · +3506 −1591Browse files

Showing the changes to kernel/trace (3 of 221 files). Show all

Unified · Split

3 files
  1. kernel/trace/bpf_trace.c +67 −14
  2. kernel/trace/trace_kprobe.c +1 −0
  3. kernel/trace/trace_uprobe.c +1 −0
kernel/trace/bpf_trace.c+67−14
@@ -345,7 +345,7 @@ static const struct bpf_func_proto bpf_probe_write_user_proto = { · 344 unmodified lines
345345 .gpl_only = true,
346346 .ret_type = RET_INTEGER,
347347 .arg1_type = ARG_ANYTHING,
348− .arg2_type = ARG_PTR_TO_MEM,
348+ .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
349349 .arg3_type = ARG_CONST_SIZE,
350350 };
351351
@@ -394,7 +394,7 @@ static const struct bpf_func_proto bpf_trace_printk_proto = { · 42 unmodified lines
394394 .func = bpf_trace_printk,
395395 .gpl_only = true,
396396 .ret_type = RET_INTEGER,
397− .arg1_type = ARG_PTR_TO_MEM,
397+ .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
398398 .arg2_type = ARG_CONST_SIZE,
399399 };
400400
@@ -450,9 +450,9 @@ static const struct bpf_func_proto bpf_trace_vprintk_proto = { · 49 unmodified lines
450450 .func = bpf_trace_vprintk,
451451 .gpl_only = true,
452452 .ret_type = RET_INTEGER,
453− .arg1_type = ARG_PTR_TO_MEM,
453+ .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
454454 .arg2_type = ARG_CONST_SIZE,
455− .arg3_type = ARG_PTR_TO_MEM_OR_NULL,
455+ .arg3_type = ARG_PTR_TO_MEM | PTR_MAYBE_NULL | MEM_RDONLY,
456456 .arg4_type = ARG_CONST_SIZE_OR_ZERO,
457457 };
458458
@@ -492,9 +492,9 @@ static const struct bpf_func_proto bpf_seq_printf_proto = { · 33 unmodified lines
492492 .ret_type = RET_INTEGER,
493493 .arg1_type = ARG_PTR_TO_BTF_ID,
494494 .arg1_btf_id = &btf_seq_file_ids[0],
495− .arg2_type = ARG_PTR_TO_MEM,
495+ .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
496496 .arg3_type = ARG_CONST_SIZE,
497− .arg4_type = ARG_PTR_TO_MEM_OR_NULL,
497+ .arg4_type = ARG_PTR_TO_MEM | PTR_MAYBE_NULL | MEM_RDONLY,
498498 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
499499 };
500500
@@ -509,7 +509,7 @@ static const struct bpf_func_proto bpf_seq_write_proto = { · 8 unmodified lines
509509 .ret_type = RET_INTEGER,
510510 .arg1_type = ARG_PTR_TO_BTF_ID,
511511 .arg1_btf_id = &btf_seq_file_ids[0],
512− .arg2_type = ARG_PTR_TO_MEM,
512+ .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
513513 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
514514 };
515515
@@ -533,7 +533,7 @@ static const struct bpf_func_proto bpf_seq_printf_btf_proto = { · 17 unmodified lines
533533 .ret_type = RET_INTEGER,
534534 .arg1_type = ARG_PTR_TO_BTF_ID,
535535 .arg1_btf_id = &btf_seq_file_ids[0],
536− .arg2_type = ARG_PTR_TO_MEM,
536+ .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
537537 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
538538 .arg4_type = ARG_ANYTHING,
539539 };
@@ -694,7 +694,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto = { · 154 unmodified lines
694694 .arg1_type = ARG_PTR_TO_CTX,
695695 .arg2_type = ARG_CONST_MAP_PTR,
696696 .arg3_type = ARG_ANYTHING,
697− .arg4_type = ARG_PTR_TO_MEM,
697+ .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
698698 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
699699 };
700700
@@ -1004,7 +1004,7 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = { · 303 unmodified lines
10041004 .ret_type = RET_INTEGER,
10051005 .arg1_type = ARG_PTR_TO_MEM,
10061006 .arg2_type = ARG_CONST_SIZE,
1007− .arg3_type = ARG_PTR_TO_MEM,
1007+ .arg3_type = ARG_PTR_TO_MEM | MEM_RDONLY,
10081008 .arg4_type = ARG_CONST_SIZE,
10091009 .arg5_type = ARG_ANYTHING,
10101010 };
@@ -1012,7 +1012,7 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = { · 1 unmodified line
10121012 BPF_CALL_1(bpf_get_func_ip_tracing, void *, ctx)
10131013 {
10141014 /* This helper call is inlined by verifier. */
1015− return ((u64 *)ctx)[-1];
1015+ return ((u64 *)ctx)[-2];
10161016 }
10171017
10181018 static const struct bpf_func_proto bpf_get_func_ip_proto_tracing = {
@@ -1091,6 +1091,53 @@ static const struct bpf_func_proto bpf_get_branch_snapshot_proto = { · 72 unmodified lines
10911091 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
10921092 };
10931093
1094+BPF_CALL_3(get_func_arg, void *, ctx, u32, n, u64 *, value)
1095+{
1096+ /* This helper call is inlined by verifier. */
1097+ u64 nr_args = ((u64 *)ctx)[-1];
1098+
1099+ if ((u64) n >= nr_args)
1100+ return -EINVAL;
1101+ *value = ((u64 *)ctx)[n];
1102+ return 0;
1103+}
1104+
1105+static const struct bpf_func_proto bpf_get_func_arg_proto = {
1106+ .func = get_func_arg,
1107+ .ret_type = RET_INTEGER,
1108+ .arg1_type = ARG_PTR_TO_CTX,
1109+ .arg2_type = ARG_ANYTHING,
1110+ .arg3_type = ARG_PTR_TO_LONG,
1111+};
1112+
1113+BPF_CALL_2(get_func_ret, void *, ctx, u64 *, value)
1114+{
1115+ /* This helper call is inlined by verifier. */
1116+ u64 nr_args = ((u64 *)ctx)[-1];
1117+
1118+ *value = ((u64 *)ctx)[nr_args];
1119+ return 0;
1120+}
1121+
1122+static const struct bpf_func_proto bpf_get_func_ret_proto = {
1123+ .func = get_func_ret,
1124+ .ret_type = RET_INTEGER,
1125+ .arg1_type = ARG_PTR_TO_CTX,
1126+ .arg2_type = ARG_PTR_TO_LONG,
1127+};
1128+
1129+BPF_CALL_1(get_func_arg_cnt, void *, ctx)
1130+{
1131+ /* This helper call is inlined by verifier. */
1132+ return ((u64 *)ctx)[-1];
1133+}
1134+
1135+static const struct bpf_func_proto bpf_get_func_arg_cnt_proto = {
1136+ .func = get_func_arg_cnt,
1137+ .ret_type = RET_INTEGER,
1138+ .arg1_type = ARG_PTR_TO_CTX,
1139+};
1140+
10941141 static const struct bpf_func_proto *
10951142 bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
10961143 {
@@ -1287,7 +1334,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto_tp = { · 190 unmodified lines
12871334 .arg1_type = ARG_PTR_TO_CTX,
12881335 .arg2_type = ARG_CONST_MAP_PTR,
12891336 .arg3_type = ARG_ANYTHING,
1290− .arg4_type = ARG_PTR_TO_MEM,
1337+ .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
12911338 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
12921339 };
12931340
@@ -1509,7 +1556,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto_raw_tp = { · 215 unmodified lines
15091556 .arg1_type = ARG_PTR_TO_CTX,
15101557 .arg2_type = ARG_CONST_MAP_PTR,
15111558 .arg3_type = ARG_ANYTHING,
1512− .arg4_type = ARG_PTR_TO_MEM,
1559+ .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
15131560 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
15141561 };
15151562
@@ -1563,7 +1610,7 @@ static const struct bpf_func_proto bpf_get_stack_proto_raw_tp = { · 47 unmodified lines
15631610 .gpl_only = true,
15641611 .ret_type = RET_INTEGER,
15651612 .arg1_type = ARG_PTR_TO_CTX,
1566− .arg2_type = ARG_PTR_TO_MEM,
1613+ .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
15671614 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
15681615 .arg4_type = ARG_ANYTHING,
15691616 };
@@ -1629,6 +1676,12 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 59 unmodified lines
16291676 NULL;
16301677 case BPF_FUNC_d_path:
16311678 return &bpf_d_path_proto;
1679+ case BPF_FUNC_get_func_arg:
1680+ return bpf_prog_has_trampoline(prog) ? &bpf_get_func_arg_proto : NULL;
1681+ case BPF_FUNC_get_func_ret:
1682+ return bpf_prog_has_trampoline(prog) ? &bpf_get_func_ret_proto : NULL;
1683+ case BPF_FUNC_get_func_arg_cnt:
1684+ return bpf_prog_has_trampoline(prog) ? &bpf_get_func_arg_cnt_proto : NULL;
16321685 default:
16331686 fn = raw_tp_prog_func_proto(func_id, prog);
16341687 if (!fn && prog->expected_attach_type == BPF_TRACE_ITER)
kernel/trace/trace_kprobe.c+1−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 */
88 #define pr_fmt(fmt) "trace_kprobe: " fmt
99
10+#include <linux/bpf-cgroup.h>
1011 #include <linux/security.h>
1112 #include <linux/module.h>
1213 #include <linux/uaccess.h>
kernel/trace/trace_uprobe.c+1−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
77 */
88 #define pr_fmt(fmt) "trace_uprobe: " fmt
99
10+#include <linux/bpf-cgroup.h>
1011 #include <linux/security.h>
1112 #include <linux/ctype.h>
1213 #include <linux/module.h>