Skip to content

eBPF-based security platform

testing: cover kprobe.multi and kretprobe.multi upatches

Jiri Olsad8485af15f44
diff --git a/Documentation/contribute/testing/test-coverage.rst b/Documentation/contribute/testing/test-coverage.rst
index 3aabc9d8..51cf302c 100644
--- a/Documentation/contribute/testing/test-coverage.rst
+++ b/Documentation/contribute/testing/test-coverage.rst
@@ -428,7 +428,8 @@ signed config image.
* - ``t6118-foreign-entries``
- Entries root brings into sealed directories
* - ``t6119-perf-attach``
- - ``PERF_EVENT_IOC_SET_BPF``
+ - ``PERF_EVENT_IOC_SET_BPF``, and a kprobe multi link of root's own
+ for a loaded upatch's program
* - ``t6120-umount-above``
- Unmounts above the bpffs, by subtree and by propagation
* - ``t6121-bpffs-entries``
diff --git a/testing/fixtures/kprobe-multi-missing.bpf.c b/testing/fixtures/kprobe-multi-missing.bpf.c
new file mode 100644
index 00000000..2d1d8a66
--- /dev/null
+++ b/testing/fixtures/kprobe-multi-missing.bpf.c
@@ -0,0 +1,11 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+
+char _license[] SEC("license") = "Dual BSD/GPL";
+
+SEC("kprobe.multi/vfs_read,shirudo_no_such_function")
+int km_missing(struct pt_regs *ctx)
+{
+ return 0;
+}
diff --git a/testing/fixtures/kprobe-multi.bpf.c b/testing/fixtures/kprobe-multi.bpf.c
new file mode 100644
index 00000000..104ef40f
--- /dev/null
+++ b/testing/fixtures/kprobe-multi.bpf.c
@@ -0,0 +1,40 @@
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+
+char _license[] SEC("license") = "Dual BSD/GPL";
+
+enum {
+ HIT_ENTRY,
+ HIT_RETURN,
+ NR_HITS,
+};
+
+struct {
+ __uint(type, BPF_MAP_TYPE_ARRAY);
+ __uint(max_entries, NR_HITS);
+ __type(key, __u32);
+ __type(value, __u64);
+} hits SEC(".maps");
+
+static __always_inline void count_hit(__u32 slot)
+{
+ __u64 *value = bpf_map_lookup_elem(&hits, &slot);
+
+ if (value)
+ __sync_fetch_and_add(value, 1);
+}
+
+SEC("kprobe.multi/vfs_write,vfs_read")
+int km_entry(struct pt_regs *ctx)
+{
+ count_hit(HIT_ENTRY);
+ return 0;
+}
+
+SEC("kretprobe.multi/vfs_read,vfs_write")
+int km_return(struct pt_regs *ctx)
+{
+ count_hit(HIT_RETURN);
+ return 0;
+}
diff --git a/testing/functional/tamperproof/t6119-perf-attach.sh b/testing/functional/tamperproof/t6119-perf-attach.sh
index 7c722415..9a084a31 100755
--- a/testing/functional/tamperproof/t6119-perf-attach.sh
+++ b/testing/functional/tamperproof/t6119-perf-attach.sh
@@ -7,7 +7,10 @@
# root's to reach by id, and the ioctl would bind it to a perf event of
# root's own, a probe where its signer never meant it to run. The
# file_ioctl hook keeps the ioctl to shirudo, counted as PerfAttach; the
-# upatch's own link is untouched. Needs the uprobe PMU, not kprobes.
+# upatch's own link is untouched. Needs the uprobe PMU.
+# A kprobe multi link of root's own for such a program goes through
+# bpf(), where the same kind of attach is refused and counted as
+# ProgAttach; that case needs CONFIG_FPROBE, which the test kernel has.
cd "$(dirname "$0")/../.."
. ./integration-lib.sh
@@ -25,10 +28,22 @@ UNLOAD="$FIXTURES/$NAME.unload.upatch"
TARGET="$FIXTURES/shirudo-test-uprobe-target"
RUNTIME=/tmp/shirudo-test-uprobe-target
PIN="/run/shirudo/bpffs/upatches/$NAME/link"
-for f in "$LOAD" "$UNLOAD" "$TARGET"; do
- [ -s "$f" ] || test_skip_all "missing uprobe fixture $f"
+KM_NAME=shirudo-test-kprobe-multi
+KM_LOAD="$FIXTURES/$KM_NAME.upatch"
+KM_UNLOAD="$FIXTURES/$KM_NAME.unload.upatch"
+KM_DIR="/run/shirudo/bpffs/upatches/$KM_NAME"
+for f in "$LOAD" "$UNLOAD" "$TARGET" "$KM_LOAD" "$KM_UNLOAD"; do
+ [ -s "$f" ] || test_skip_all "missing fixture $f"
done
-trap 'if [ -e "$PIN" ]; then "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true; fi' EXIT
+cleanup() {
+ if [ -e "$PIN" ]; then
+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true
+ fi
+ if [ -e "$KM_DIR/link_0" ]; then
+ "$SHIRUDO_BIN" upatch unload "$KM_UNLOAD" --no-precheck >/dev/null 2>&1 || true
+ fi
+}
+trap cleanup EXIT
# The counter $1 from status --json.
counter() {
@@ -49,4 +64,21 @@ test_expect_success 'root cannot bind the loaded program to a perf event of its
[ -e "$PIN" ]
'
+test_expect_success 'the kprobe multi upatch loads' '
+ "$SHIRUDO_BIN" upatch load "$KM_LOAD" --no-precheck >/dev/null &&
+ [ -e "$KM_DIR/link_0" ]
+'
+
+test_expect_success 'root cannot create a kprobe multi link for a loaded program' '
+ before=$(counter ProgAttach) &&
+ [ "$(./$H --kprobe-multi km_entry)" = "errno=13" ] &&
+ [ "$(counter ProgAttach)" -gt "$before" ] &&
+ [ -e "$KM_DIR/link_0" ]
+'
+
+test_expect_success 'the kprobe multi upatch unloads' '
+ "$SHIRUDO_BIN" upatch unload "$KM_UNLOAD" --no-precheck >/dev/null &&
+ [ ! -e "$KM_DIR/link_0" ]
+'
+
test_done
diff --git a/testing/functional/upatch/t3013-kprobe-multi-metadata.sh b/testing/functional/upatch/t3013-kprobe-multi-metadata.sh
new file mode 100755
index 00000000..41278998
--- /dev/null
+++ b/testing/functional/upatch/t3013-kprobe-multi-metadata.sh
@@ -0,0 +1,131 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# t3013 -- kprobe.multi and kretprobe.multi sections record their exact
+# function list, sorted, in the signed attach metadata, and anything else
+# is refused at build time.
+
+cd "$(dirname "$0")/../.."
+. ./test-lib.sh
+
+SHB=../tools/shirudo-build/shirudo-build
+CHECK=helper/test-upatch-prog-metadata
+
+command -v cc >/dev/null 2>&1 || test_skip_all "no C compiler"
+command -v clang >/dev/null 2>&1 || test_skip_all "no clang"
+command -v openssl >/dev/null 2>&1 || test_skip_all "no openssl"
+[ -x "$SHB" ] || test_skip_all "shirudo-build not built (make shirudo-build)"
+[ -x "$CHECK" ] || test_skip_all "metadata helper not built"
+[ -e ../vendor/linux/vmlinux.h ] || test_skip_all "no vendor/linux/vmlinux.h (build the tree)"
+[ -e ../vendor/libbpf/bpf/bpf_helpers.h ] || test_skip_all "no vendored bpf headers"
+
+WORK=$(mktemp -d)
+trap 'rm -rf "$WORK"' EXIT
+
+# shirudo signs with ML-DSA-87 only (needs OpenSSL >= 3.5 to mint it).
+openssl req -x509 -newkey ML-DSA-87 -nodes -keyout "$WORK/k.pem" \
+ -outform DER -out "$WORK/c.der" -days 1 -subj "/CN=t3013" \
+ >/dev/null 2>&1 || test_skip_all "openssl ML-DSA keygen failed (needs OpenSSL >= 3.5)"
+
+case "$SHB" in
+/*) B="$SHB" ;;
+*) B="$(pwd)/$SHB" ;;
+esac
+
+# Builds SEC("$1") into $WORK/probe.upatch; the build log is $WORK/log.
+build_section() {
+ cat > "$WORK/probe.bpf.c" <<EOF
+// SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+#include "vmlinux.h"
+#include <bpf/bpf_helpers.h>
+
+char _license[] SEC("license") = "Dual BSD/GPL";
+
+SEC("$1")
+int probe(struct pt_regs *ctx)
+{
+ return 0;
+}
+EOF
+ ( cd .. && "$B" "$WORK/probe.bpf.c" -o "$WORK/probe.upatch" \
+ --vmlinux vendor/linux/vmlinux.h --name kprobe-multi-test \
+ --key "$WORK/k.pem" --cert "$WORK/c.der" ) >"$WORK/log" 2>&1
+}
+
+test_expect_success 'kprobe.multi signs its names sorted' '
+ build_section "kprobe.multi/vfs_write,vfs_read,ksys_read" &&
+ "$CHECK" "$WORK/probe.upatch" kprobe-multi ksys_read,vfs_read,vfs_write
+'
+
+test_expect_success 'a uprobe beside a kprobe.multi keeps both target blocks' '
+ cat > "$WORK/target.c" <<-\EOF &&
+ __attribute__((noinline, used)) int fooFunc(int value) { return value + 1; }
+ int main(void) { return fooFunc(1); }
+ EOF
+ cc -O0 -g -Wl,--build-id=sha1 -o "$WORK/target" "$WORK/target.c" &&
+ cat > "$WORK/mixed.bpf.c" <<-EOF &&
+ // SPDX-License-Identifier: GPL-2.0 OR BSD-2-Clause
+ #include "vmlinux.h"
+ #include <bpf/bpf_helpers.h>
+
+ char _license[] SEC("license") = "Dual BSD/GPL";
+
+ SEC("uprobe/$WORK/target:fooFunc")
+ int user_probe(struct pt_regs *ctx)
+ {
+ return 0;
+ }
+
+ SEC("kprobe.multi/vfs_write,vfs_read")
+ int kernel_probe(struct pt_regs *ctx)
+ {
+ return 0;
+ }
+ EOF
+ ( cd .. && "$B" "$WORK/mixed.bpf.c" -o "$WORK/mixed.upatch" \
+ --vmlinux vendor/linux/vmlinux.h --name kprobe-multi-mixed \
+ --key "$WORK/k.pem" --cert "$WORK/c.der" ) >"$WORK/log" 2>&1 &&
+ "$CHECK" "$WORK/mixed.upatch" uprobe-kprobe-multi "$WORK/target" \
+ vfs_read,vfs_write
+'
+
+test_expect_success 'kretprobe.multi records the return kind' '
+ build_section "kretprobe.multi/vfs_read" &&
+ "$CHECK" "$WORK/probe.upatch" kretprobe-multi vfs_read
+'
+
+test_expect_success 'a section without a list is refused' '
+ ! build_section "kprobe.multi" &&
+ grep -q "unsupported kprobe section" "$WORK/log" &&
+ ! build_section "kretprobe.multi/" &&
+ grep -q "unsupported kprobe section" "$WORK/log"
+'
+
+test_expect_success 'a glob is refused with an actionable error' '
+ ! build_section "kprobe.multi/vfs_*" &&
+ grep -q "globs are unsupported" "$WORK/log"
+'
+
+test_expect_success 'a function named twice is refused' '
+ ! build_section "kprobe.multi/vfs_read,vfs_read" &&
+ grep -q "named twice" "$WORK/log"
+'
+
+test_expect_success 'an empty list element is refused' '
+ ! build_section "kprobe.multi/vfs_read,,vfs_write" &&
+ grep -q "invalid kprobe multi section" "$WORK/log"
+'
+
+test_expect_success 'a name of KSYM_NAME_LEN bytes is refused' '
+ long=$(printf "%512s" "" | tr " " a) &&
+ ! build_section "kprobe.multi/$long" &&
+ grep -q "invalid kprobe multi section" "$WORK/log"
+'
+
+test_expect_success 'kprobe.session stays refused' '
+ ! build_section "kprobe.session/vfs_read" &&
+ grep -q "unsupported section" "$WORK/log"
+'
+
+test_done
diff --git a/testing/functional/upatch/t3113-kprobe-multi.sh b/testing/functional/upatch/t3113-kprobe-multi.sh
new file mode 100755
index 00000000..dbefe90b
--- /dev/null
+++ b/testing/functional/upatch/t3113-kprobe-multi.sh
@@ -0,0 +1,75 @@
+#!/bin/sh
+# SPDX-License-Identifier: BSD-2-Clause
+# Copyright (c) 2026 Authors of shirudo
+#
+# t3113 -- live kprobe.multi and kretprobe.multi: both links attach,
+# status names them, both programs run, an unload detaches them, and a
+# name the kernel does not know fails the whole link.
+
+cd "$(dirname "$0")/../.."
+. ./integration-lib.sh
+target_guard
+
+command -v python3 >/dev/null 2>&1 || test_skip_all "no python3"
+FIXTURES=${SHIRUDO_TEST_FIXTURES_DIR:?target fixture directory is not set}
+NAME=shirudo-test-kprobe-multi
+LOAD="$FIXTURES/$NAME.upatch"
+UNLOAD="$FIXTURES/$NAME.unload.upatch"
+MISSING="$FIXTURES/shirudo-test-kprobe-multi-missing.upatch"
+DIR="/run/shirudo/bpffs/upatches/$NAME"
+WORK=$(mktemp -d)
+trap 'if [ -e "$DIR/link_0" ]; then "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 || true; fi; rm -rf "$WORK"' EXIT
+
+for fixture in "$LOAD" "$UNLOAD" "$MISSING"; do
+ [ -s "$fixture" ] || test_skip_all "missing kprobe multi fixture: $fixture"
+done
+
+"$SHIRUDO_BIN" upatch load "$LOAD" --no-precheck >"$WORK/load.log" 2>&1 ||
+ test_skip_all "kernel does not support this kprobe.multi load"
+
+test_expect_success 'both links are pinned' '
+ [ -e "$DIR/link_0" ] && [ -e "$DIR/link_1" ]
+'
+
+test_expect_success 'status reports the kind and the function count' '
+ "$SHIRUDO_BIN" upatch get "$NAME" --json >"$WORK/get.json" &&
+ python3 - "$WORK/get.json" <<'PY'
+import json
+import sys
+doc = json.load(open(sys.argv[1], encoding="utf-8"))
+assert doc["upatch"]["location"] == "kprobe.multi (2 funcs)", doc
+PY
+'
+
+test_expect_success 'entry and return programs both run' '
+ cat /proc/version >/dev/null &&
+ echo x >"$WORK/out" &&
+ "$SHIRUDO_BIN" upatch get "$NAME" --json >"$WORK/get.json" &&
+ python3 - "$WORK/get.json" <<'PY'
+import json
+import sys
+doc = json.load(open(sys.argv[1], encoding="utf-8"))
+maps = doc["upatch"]["maps"]
+hits = next(map_data for map_data in maps if map_data["name"] == "hits")
+values = [entry["value"] for entry in hits["entries"]]
+assert len(values) == 2, doc
+for value in values:
+ assert int(str(value), 0) > 0, doc
+PY
+'
+
+test_expect_success 'unload removes the links' '
+ "$SHIRUDO_BIN" upatch unload "$UNLOAD" --no-precheck >/dev/null 2>&1 &&
+ [ ! -e "$DIR/link_0" ] && [ ! -e "$DIR/link_1" ]
+'
+
+test_expect_success 'a name the kernel lacks fails the link as a missing target' '
+ status=0 &&
+ { "$SHIRUDO_BIN" upatch load "$MISSING" --no-precheck \
+ --report="$WORK/report.json" >/dev/null 2>&1 || status=$?; } &&
+ [ "$status" = 2 ] &&
+ [ "$(report_field category <"$WORK/report.json")" = attach_target_missing ] &&
+ [ ! -e /run/shirudo/bpffs/upatches/shirudo-test-kprobe-multi-missing/link ]
+'
+
+test_done
diff --git a/testing/helper/test-perf-attach.c b/testing/helper/test-perf-attach.c
index 07d582dc..21e46625 100644
--- a/testing/helper/test-perf-attach.c
+++ b/testing/helper/test-perf-attach.c
@@ -6,6 +6,7 @@
* own through PERF_EVENT_IOC_SET_BPF, the legacy attach path that
* never passes through bpf(). The event is a uprobe on this executable,
* which needs no kprobe support; whether it fires is beside the point.
+ * With --kprobe-multi, create a kprobe multi link for the program instead.
* Prints "attached" or "errno=<n>". No libbpf.
*/
@@ -101,6 +102,31 @@ static int find_prog(const char *want, __u32 *id_out)
}
}
+static int link_kprobe_multi(const char *want)
+{
+ const char *sym = "vfs_read";
+ union bpf_attr attr = {};
+ __u32 id = 0;
+ int prog_fd, link_fd;
+
+ prog_fd = find_prog(want, &id);
+ if (prog_fd < 0) {
+ fprintf(stderr, "no loaded kprobe-type program\n");
+ return 2;
+ }
+ attr.link_create.prog_fd = (__u32)prog_fd;
+ attr.link_create.attach_type = BPF_TRACE_KPROBE_MULTI;
+ attr.link_create.kprobe_multi.syms = (__u64)(size_t)&sym;
+ attr.link_create.kprobe_multi.cnt = 1;
+ link_fd = (int)bpf(BPF_LINK_CREATE, &attr);
+ if (link_fd >= 0) {
+ printf("attached prog_id=%u\n", id);
+ return 0;
+ }
+ printf("errno=%d\n", errno);
+ return 0;
+}
+
int main(int argc, char **argv)
{
struct perf_event_attr pe;
@@ -110,6 +136,8 @@ int main(int argc, char **argv)
long off;
int type, prog_fd, perf_fd;
+ if (argc == 3 && !strcmp(argv[1], "--kprobe-multi"))
+ return link_kprobe_multi(argv[2]);
type = uprobe_type();
if (type < 0) {
fprintf(stderr, "no uprobe PMU\n");
diff --git a/testing/helper/test-upatch-prog-metadata.c b/testing/helper/test-upatch-prog-metadata.c
index 01d6fddf..45616652 100644
--- a/testing/helper/test-upatch-prog-metadata.c
+++ b/testing/helper/test-upatch-prog-metadata.c
@@ -168,6 +168,104 @@ static int expect_uprobe(const struct upatch *u, __u32 kind,
return cursor == end ? 0 : fail("trailing uprobe metadata");
}
+/* names is the expected list in signed order, joined by commas. */
+static int expect_kprobe_multi(const struct upatch *u, __u32 kind, const char *names)
+{
+ struct upatch_kprobe_targets targets;
+ struct upatch_kprobe_target record;
+ struct upatch_prog_metadata md;
+ struct upatch_prog_entry prog;
+ size_t names_len = strlen(names) + 1;
+ const __u8 *raw, *cursor;
+ __u32 nr_syms = 1, len;
+ size_t i;
+
+ if (u->hdr.nr_progs != 1)
+ return fail("unexpected metadata prog count");
+ raw = upatch_signed_attach(u, &len);
+ if (!raw || len != sizeof(md) + sizeof(prog) + sizeof(targets) + sizeof(record) + names_len)
+ return fail("kprobe multi metadata length mismatch");
+ memcpy(&md, raw, sizeof(md));
+ memcpy(&prog, raw + sizeof(md), sizeof(prog));
+ if (le32_to_cpu(prog.role) != UPATCH_PROG_ROLE_ATTACH ||
+ le32_to_cpu(prog.kind) != kind || prog.offset || prog.target[0])
+ return fail("kprobe multi program entry mismatch");
+ cursor = raw + sizeof(md) + sizeof(prog);
+ memcpy(&targets, cursor, sizeof(targets));
+ cursor += sizeof(targets);
+ if (le32_to_cpu(targets.magic) != UPATCH_KPROBE_TARGET_MAGIC ||
+ le32_to_cpu(targets.version) != UPATCH_KPROBE_TARGET_VERSION ||
+ le32_to_cpu(targets.nr_targets) != 1 || targets.reserved)
+ return fail("kprobe multi target header mismatch");
+ memcpy(&record, cursor, sizeof(record));
+ cursor += sizeof(record);
+ for (i = 0; names[i]; i++)
+ nr_syms += names[i] == ',';
+ if (le32_to_cpu(record.prog_idx) != 0 || le32_to_cpu(record.nr_syms) != nr_syms ||
+ le32_to_cpu(record.syms_len) != names_len)
+ return fail("kprobe multi target record mismatch");
+ for (i = 0; i < names_len; i++) {
+ char want = names[i] == ',' ? '\0' : names[i];
+
+ if ((char)cursor[i] != want)
+ return fail("kprobe multi names mismatch");
+ }
+ return 0;
+}
+
+/* names is the expected list in sorted order, joined by commas. */
+static bool kprobe_names_match(const struct prog_spec *s, const char *names)
+{
+ const char *want = names;
+ __u32 i;
+
+ for (i = 0; i < s->nr_kprobe_syms; i++) {
+ size_t len;
+
+ if (i && *want++ != ',')
+ return false;
+ len = strlen(s->kprobe_syms[i]);
+ if (strnlen(want, len) < len || memcmp(want, s->kprobe_syms[i], len) ||
+ (want[len] && want[len] != ','))
+ return false;
+ want += len;
+ }
+ return s->nr_kprobe_syms && !*want;
+}
+
+/* Reads back an upatch of one uprobe and one kprobe multi program. */
+static int expect_uprobe_and_kprobe_multi(const struct upatch *u, const char *path,
+ const char *names)
+{
+ const struct prog_spec *uprobe = NULL, *kprobe = NULL;
+ struct prog_spec *specs = NULL;
+ const void *attach;
+ __u32 len, i;
+ int ret;
+
+ if (u->hdr.nr_progs != 2)
+ return fail("unexpected metadata prog count");
+ attach = upatch_signed_attach(u, &len);
+ if (!attach)
+ return fail("missing signed metadata");
+ if (prog_specs_parse(attach, len, u->hdr.nr_maps, u->hdr.nr_progs, &specs))
+ return fail("the reader refuses the metadata");
+ for (i = 0; i < u->hdr.nr_progs; i++) {
+ if (kind_is_uprobe_single(specs[i].kind))
+ uprobe = &specs[i];
+ else if (kind_is_kprobe_multi(specs[i].kind))
+ kprobe = &specs[i];
+ }
+ if (!uprobe || !uprobe->uprobe_path || strcmp(uprobe->uprobe_path, path))
+ ret = fail("uprobe target mismatch");
+ else if (!kprobe || !kprobe_names_match(kprobe, names))
+ ret = fail("kprobe multi names mismatch");
+ else
+ ret = 0;
+ prog_specs_free(specs, u->hdr.nr_progs);
+ return ret;
+}
+
static int expect_policy_labels(const struct upatch *u)
{
static const char *const policies[] = {
@@ -214,8 +312,8 @@ int main(int argc, char **argv)
const char *mode = "serializer";
int ret;
- if (argc != 2 && argc != 3 && argc != 4 && argc != 6)
- return fail("usage: test-upatch-prog-metadata <file.upatch> [mode [path pattern count]]");
+ if (argc < 2 || argc > 6)
+ return fail("usage: test-upatch-prog-metadata <file.upatch> [mode [names | path names | path pattern count]]");
if (argc >= 3)
mode = argv[2];
@@ -283,6 +381,12 @@ int main(int argc, char **argv)
ret = expect_uprobe(&u, kind, argv[3], argv[4], entry_offset, 1, &first);
if (!ret)
printf("%llu\n", first);
+ } else if (strcmp(mode, "kprobe-multi") == 0 && argc == 4) {
+ ret = expect_kprobe_multi(&u, UPATCH_ATTACH_KPROBE_MULTI, argv[3]);
+ } else if (strcmp(mode, "kretprobe-multi") == 0 && argc == 4) {
+ ret = expect_kprobe_multi(&u, UPATCH_ATTACH_KRETPROBE_MULTI, argv[3]);
+ } else if (strcmp(mode, "uprobe-kprobe-multi") == 0 && argc == 5) {
+ ret = expect_uprobe_and_kprobe_multi(&u, argv[3], argv[4]);
} else if (strcmp(mode, "policy-labels") == 0 && argc == 3) {
ret = expect_policy_labels(&u);
} else {
diff --git a/testing/vm/build-bundle-payload.sh b/testing/vm/build-bundle-payload.sh
index 7308cb1b..00a882d0 100755
--- a/testing/vm/build-bundle-payload.sh
+++ b/testing/vm/build-bundle-payload.sh
@@ -747,6 +747,8 @@ queue_fixture build_fixture uretprobe-multi.bpf.c shirudo-test-uretprobe-multi "
queue_fixture build_fixture uprobe-multi-sleepable.bpf.c shirudo-test-uprobe-multi-sleepable "$FIXTURE_WORK/trusted"
queue_fixture build_fixture uprobe.bpf.c shirudo-test-uprobe "$FIXTURE_WORK/trusted"
queue_fixture build_fixture uretprobe.bpf.c shirudo-test-uretprobe "$FIXTURE_WORK/trusted"
+queue_fixture build_fixture kprobe-multi.bpf.c shirudo-test-kprobe-multi "$FIXTURE_WORK/trusted"
+queue_fixture build_fixture kprobe-multi-missing.bpf.c shirudo-test-kprobe-multi-missing "$FIXTURE_WORK/trusted"
queue_fixture build_fixture scope-netfilter.bpf.c shirudo-test-scope-netfilter "$FIXTURE_WORK/trusted"
queue_fixture build_fixture scope-cgroup.bpf.c shirudo-test-scope-cgroup "$FIXTURE_WORK/trusted"
queue_fixture build_fixture scope-kprobe.bpf.c shirudo-test-scope-kprobe "$FIXTURE_WORK/trusted"
@@ -793,6 +795,9 @@ uprobe_single_payload="$($REPO_ROOT/shirudo upatch info \
uretprobe_single_payload="$($REPO_ROOT/shirudo upatch info \
"$TMP_DIR/fixtures/shirudo-test-uretprobe.upatch" --json |
python3 -c 'import json,sys; print(json.load(sys.stdin)["payload_sha256"])')"
+kprobe_multi_payload="$($REPO_ROOT/shirudo upatch info \
+ "$TMP_DIR/fixtures/shirudo-test-kprobe-multi.upatch" --json |
+ python3 -c 'import json,sys; print(json.load(sys.stdin)["payload_sha256"])')"
otel_backend_payload="$($REPO_ROOT/shirudo upatch info \
"$TMP_DIR/fixtures/shirudo-test-otel-backend.upatch" --json |
python3 -c 'import json,sys; print(json.load(sys.stdin)["payload_sha256"])')"
@@ -863,6 +868,7 @@ shirudo-test-uretprobe-multi $uretprobe_payload shirudo-test-uretprobe-multi.unl
shirudo-test-uprobe-multi-sleepable $uprobe_sleepable_payload shirudo-test-uprobe-multi-sleepable.unload.upatch
shirudo-test-uprobe $uprobe_single_payload shirudo-test-uprobe.unload.upatch
shirudo-test-uretprobe $uretprobe_single_payload shirudo-test-uretprobe.unload.upatch
+shirudo-test-kprobe-multi $kprobe_multi_payload shirudo-test-kprobe-multi.unload.upatch
EOF
wait_fixture_jobs
diff --git a/testing/vm/build-kernel.sh b/testing/vm/build-kernel.sh
index 2440be92..b8e4364d 100755
--- a/testing/vm/build-kernel.sh
+++ b/testing/vm/build-kernel.sh
@@ -369,6 +369,7 @@ CONFIG_FTRACE_SYSCALLS=y
CONFIG_FUNCTION_TRACER=y
CONFIG_DYNAMIC_FTRACE=y
CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS=y
+CONFIG_FPROBE=y
CONFIG_UPROBES=y
CONFIG_SECCOMP=y
CONFIG_SECCOMP_FILTER=y
@@ -558,6 +559,7 @@ require_config CONFIG_CGROUP_BPF y
require_config CONFIG_FUNCTION_TRACER y
require_config CONFIG_DYNAMIC_FTRACE y
require_config CONFIG_DYNAMIC_FTRACE_WITH_DIRECT_CALLS y
+require_config CONFIG_FPROBE y
require_config CONFIG_DEBUG_INFO_BTF y
require_config CONFIG_TCG_TPM y
require_config CONFIG_TCG_TIS_CORE y