eBPF-based security platform
upatch: report the runs the kernel skipped of kprobe links
Jiri Olsa78f8b66b2cce
diff --git a/util/upatch_resolve.c b/util/upatch_resolve.cindex 53c256ac..fbbf6180 100644--- a/util/upatch_resolve.c+++ b/util/upatch_resolve.c@@ -345,11 +345,20 @@ int upatch_resolve_location(struct btf *vbtf, const char *name,return ret;}+static bool link_is_kprobe(const struct bpf_link_info *info)+{+ return info->type == BPF_LINK_TYPE_PERF_EVENT &&+ (info->perf_event.type == BPF_PERF_EVENT_KPROBE ||+ info->perf_event.type == BPF_PERF_EVENT_KRETPROBE);+}+bool upatch_link_counts_misses(const struct bpf_link_info *info){switch (info->type) {case BPF_LINK_TYPE_KPROBE_MULTI:return true;+ case BPF_LINK_TYPE_PERF_EVENT:+ return link_is_kprobe(info);default:return false;}@@ -359,6 +368,8 @@ __u64 upatch_link_missed(const struct bpf_link_info *info){if (info->type == BPF_LINK_TYPE_KPROBE_MULTI)return info->kprobe_multi.missed;+ if (link_is_kprobe(info))+ return info->perf_event.kprobe.missed;return 0;}diff --git a/util/upatch_resolve.h b/util/upatch_resolve.hindex a39bd855..93ad211a 100644--- a/util/upatch_resolve.h+++ b/util/upatch_resolve.h@@ -43,7 +43,7 @@ int upatch_resolve_location(struct btf *vbtf, const char *name,/** The runs the kernel skipped of one program of an upatch: the program's- * recursion_misses and what its kprobe multi link counts itself.+ * recursion_misses and what its kprobe or kprobe multi link counts itself.*/struct upatch_link_misses {char location[UPATCH_LOCATION_MAX]; /* "" when it cannot be named */@@ -52,8 +52,8 @@ struct upatch_link_misses {/** Whether the runs the kernel skips of the program behind this link are- * reported: kprobe.multi and kretprobe.multi. The kernel skips no lsm,- * xdp, cgroup_skb or netfilter run, and counts none it skips of the+ * reported: kprobe, kretprobe and their multi forms. The kernel skips no+ * lsm, xdp, cgroup_skb or netfilter run, and counts none it skips of the* uprobe kinds.*/bool upatch_link_counts_misses(const struct bpf_link_info *info);