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
345 .gpl_only = true,345 .gpl_only = true,
346 .ret_type = RET_INTEGER,346 .ret_type = RET_INTEGER,
347 .arg1_type = ARG_ANYTHING,347 .arg1_type = ARG_ANYTHING,
348 .arg2_type = ARG_PTR_TO_MEM,348 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
349 .arg3_type = ARG_CONST_SIZE,349 .arg3_type = ARG_CONST_SIZE,
350};350};
351 351
@@ -394,7 +394,7 @@ static const struct bpf_func_proto bpf_trace_printk_proto = { · 42 unmodified lines
394 .func = bpf_trace_printk,394 .func = bpf_trace_printk,
395 .gpl_only = true,395 .gpl_only = true,
396 .ret_type = RET_INTEGER,396 .ret_type = RET_INTEGER,
397 .arg1_type = ARG_PTR_TO_MEM,397 .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
398 .arg2_type = ARG_CONST_SIZE,398 .arg2_type = ARG_CONST_SIZE,
399};399};
400 400
@@ -450,9 +450,9 @@ static const struct bpf_func_proto bpf_trace_vprintk_proto = { · 49 unmodified lines
450 .func = bpf_trace_vprintk,450 .func = bpf_trace_vprintk,
451 .gpl_only = true,451 .gpl_only = true,
452 .ret_type = RET_INTEGER,452 .ret_type = RET_INTEGER,
453 .arg1_type = ARG_PTR_TO_MEM,453 .arg1_type = ARG_PTR_TO_MEM | MEM_RDONLY,
454 .arg2_type = ARG_CONST_SIZE,454 .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,
456 .arg4_type = ARG_CONST_SIZE_OR_ZERO,456 .arg4_type = ARG_CONST_SIZE_OR_ZERO,
457};457};
458 458
@@ -492,9 +492,9 @@ static const struct bpf_func_proto bpf_seq_printf_proto = { · 33 unmodified lines
492 .ret_type = RET_INTEGER,492 .ret_type = RET_INTEGER,
493 .arg1_type = ARG_PTR_TO_BTF_ID,493 .arg1_type = ARG_PTR_TO_BTF_ID,
494 .arg1_btf_id = &btf_seq_file_ids[0],494 .arg1_btf_id = &btf_seq_file_ids[0],
495 .arg2_type = ARG_PTR_TO_MEM,495 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
496 .arg3_type = ARG_CONST_SIZE,496 .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,
498 .arg5_type = ARG_CONST_SIZE_OR_ZERO,498 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
499};499};
500 500
@@ -509,7 +509,7 @@ static const struct bpf_func_proto bpf_seq_write_proto = { · 8 unmodified lines
509 .ret_type = RET_INTEGER,509 .ret_type = RET_INTEGER,
510 .arg1_type = ARG_PTR_TO_BTF_ID,510 .arg1_type = ARG_PTR_TO_BTF_ID,
511 .arg1_btf_id = &btf_seq_file_ids[0],511 .arg1_btf_id = &btf_seq_file_ids[0],
512 .arg2_type = ARG_PTR_TO_MEM,512 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
513 .arg3_type = ARG_CONST_SIZE_OR_ZERO,513 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
514};514};
515 515
@@ -533,7 +533,7 @@ static const struct bpf_func_proto bpf_seq_printf_btf_proto = { · 17 unmodified lines
533 .ret_type = RET_INTEGER,533 .ret_type = RET_INTEGER,
534 .arg1_type = ARG_PTR_TO_BTF_ID,534 .arg1_type = ARG_PTR_TO_BTF_ID,
535 .arg1_btf_id = &btf_seq_file_ids[0],535 .arg1_btf_id = &btf_seq_file_ids[0],
536 .arg2_type = ARG_PTR_TO_MEM,536 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
537 .arg3_type = ARG_CONST_SIZE_OR_ZERO,537 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
538 .arg4_type = ARG_ANYTHING,538 .arg4_type = ARG_ANYTHING,
539};539};
@@ -694,7 +694,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto = { · 154 unmodified lines
694 .arg1_type = ARG_PTR_TO_CTX,694 .arg1_type = ARG_PTR_TO_CTX,
695 .arg2_type = ARG_CONST_MAP_PTR,695 .arg2_type = ARG_CONST_MAP_PTR,
696 .arg3_type = ARG_ANYTHING,696 .arg3_type = ARG_ANYTHING,
697 .arg4_type = ARG_PTR_TO_MEM,697 .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
698 .arg5_type = ARG_CONST_SIZE_OR_ZERO,698 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
699};699};
700 700
@@ -1004,7 +1004,7 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = { · 303 unmodified lines
1004 .ret_type = RET_INTEGER,1004 .ret_type = RET_INTEGER,
1005 .arg1_type = ARG_PTR_TO_MEM,1005 .arg1_type = ARG_PTR_TO_MEM,
1006 .arg2_type = ARG_CONST_SIZE,1006 .arg2_type = ARG_CONST_SIZE,
1007 .arg3_type = ARG_PTR_TO_MEM,1007 .arg3_type = ARG_PTR_TO_MEM | MEM_RDONLY,
1008 .arg4_type = ARG_CONST_SIZE,1008 .arg4_type = ARG_CONST_SIZE,
1009 .arg5_type = ARG_ANYTHING,1009 .arg5_type = ARG_ANYTHING,
1010};1010};
@@ -1012,7 +1012,7 @@ const struct bpf_func_proto bpf_snprintf_btf_proto = { · 1 unmodified line
1012BPF_CALL_1(bpf_get_func_ip_tracing, void *, ctx)1012BPF_CALL_1(bpf_get_func_ip_tracing, void *, ctx)
1013{1013{
1014 /* This helper call is inlined by verifier. */1014 /* This helper call is inlined by verifier. */
1015 return ((u64 *)ctx)[-1];1015 return ((u64 *)ctx)[-2];
1016}1016}
1017 1017
1018static const struct bpf_func_proto bpf_get_func_ip_proto_tracing = {1018static 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
1091 .arg2_type = ARG_CONST_SIZE_OR_ZERO,1091 .arg2_type = ARG_CONST_SIZE_OR_ZERO,
1092};1092};
1093 1093
1094BPF_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
1105static 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
1113BPF_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
1122static 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
1129BPF_CALL_1(get_func_arg_cnt, void *, ctx)
1130{
1131 /* This helper call is inlined by verifier. */
1132 return ((u64 *)ctx)[-1];
1133}
1134
1135static 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
1094static const struct bpf_func_proto *1141static const struct bpf_func_proto *
1095bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)1142bpf_tracing_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog)
1096{1143{
@@ -1287,7 +1334,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto_tp = { · 190 unmodified lines
1287 .arg1_type = ARG_PTR_TO_CTX,1334 .arg1_type = ARG_PTR_TO_CTX,
1288 .arg2_type = ARG_CONST_MAP_PTR,1335 .arg2_type = ARG_CONST_MAP_PTR,
1289 .arg3_type = ARG_ANYTHING,1336 .arg3_type = ARG_ANYTHING,
1290 .arg4_type = ARG_PTR_TO_MEM,1337 .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
1291 .arg5_type = ARG_CONST_SIZE_OR_ZERO,1338 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
1292};1339};
1293 1340
@@ -1509,7 +1556,7 @@ static const struct bpf_func_proto bpf_perf_event_output_proto_raw_tp = { · 215 unmodified lines
1509 .arg1_type = ARG_PTR_TO_CTX,1556 .arg1_type = ARG_PTR_TO_CTX,
1510 .arg2_type = ARG_CONST_MAP_PTR,1557 .arg2_type = ARG_CONST_MAP_PTR,
1511 .arg3_type = ARG_ANYTHING,1558 .arg3_type = ARG_ANYTHING,
1512 .arg4_type = ARG_PTR_TO_MEM,1559 .arg4_type = ARG_PTR_TO_MEM | MEM_RDONLY,
1513 .arg5_type = ARG_CONST_SIZE_OR_ZERO,1560 .arg5_type = ARG_CONST_SIZE_OR_ZERO,
1514};1561};
1515 1562
@@ -1563,7 +1610,7 @@ static const struct bpf_func_proto bpf_get_stack_proto_raw_tp = { · 47 unmodified lines
1563 .gpl_only = true,1610 .gpl_only = true,
1564 .ret_type = RET_INTEGER,1611 .ret_type = RET_INTEGER,
1565 .arg1_type = ARG_PTR_TO_CTX,1612 .arg1_type = ARG_PTR_TO_CTX,
1566 .arg2_type = ARG_PTR_TO_MEM,1613 .arg2_type = ARG_PTR_TO_MEM | MEM_RDONLY,
1567 .arg3_type = ARG_CONST_SIZE_OR_ZERO,1614 .arg3_type = ARG_CONST_SIZE_OR_ZERO,
1568 .arg4_type = ARG_ANYTHING,1615 .arg4_type = ARG_ANYTHING,
1569};1616};
@@ -1629,6 +1676,12 @@ tracing_prog_func_proto(enum bpf_func_id func_id, const struct bpf_prog *prog) · 59 unmodified lines
1629 NULL;1676 NULL;
1630 case BPF_FUNC_d_path:1677 case BPF_FUNC_d_path:
1631 return &bpf_d_path_proto;1678 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;
1632 default:1685 default:
1633 fn = raw_tp_prog_func_proto(func_id, prog);1686 fn = raw_tp_prog_func_proto(func_id, prog);
1634 if (!fn && prog->expected_attach_type == BPF_TRACE_ITER)1687 if (!fn && prog->expected_attach_type == BPF_TRACE_ITER)
kernel/trace/trace_kprobe.c+1−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
7 */7 */
8#define pr_fmt(fmt) "trace_kprobe: " fmt8#define pr_fmt(fmt) "trace_kprobe: " fmt
9 9
10#include <linux/bpf-cgroup.h>
10#include <linux/security.h>11#include <linux/security.h>
11#include <linux/module.h>12#include <linux/module.h>
12#include <linux/uaccess.h>13#include <linux/uaccess.h>
kernel/trace/trace_uprobe.c+1−0
@@ -7,6 +7,7 @@ · 6 unmodified lines
7 */7 */
8#define pr_fmt(fmt) "trace_uprobe: " fmt8#define pr_fmt(fmt) "trace_uprobe: " fmt
9 9
10#include <linux/bpf-cgroup.h>
10#include <linux/security.h>11#include <linux/security.h>
11#include <linux/ctype.h>12#include <linux/ctype.h>
12#include <linux/module.h>13#include <linux/module.h>