From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=100.103.45.18 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796214927; b=d3TmRZMGYlR3qTjObF+kI9b5S1OwSv7q3Rea2a6bveKOvMJA/nfD37tbVbSt+xL4+ygj hQudPBnws3rX9LbhDhoUtemZl+ovu7DnjJLoerD7e5nqkyJdwsWMlEKgmc8SHVFmjYdIW wPuMhsrKsziV6aAAxkSux3YpSLE/9ptshsMH6rNENNQQ2ak8+FlF2XZ4rBqZPtBbRPeW4 pK29l0MthefuGgb5i/0SVkiC9fz5+CBrlSskyifsQjyWM/VnXuOv7km2jr9WpQlx9vWPx 5ONeFKlHtRwAq3Xuq2djZFcbynjuk9UhEYpR7tj9M7cP8uN4kytApfSAIFIfXvyVsRw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796214927; h=Received:DKIM-Signature:From:To:Cc:Subject:Date:Message-ID:X-Mailer: In-Reply-To:References:MIME-Version:Content-Transfer-Encoding; bh=w81uNgqMMrWKkyaL7dUzyRba4DGv7FkWKGxcpbVuxCc=; b=YkFTjRfD5TDRR8lAsFj7RXtocvYoE9onwFxvsIWFJl/6f1vcDNS68An9jnXhTuUo3srd SGcAvUJq+FB81hzkwRpl+NUIIyaLyQdJOAsSP96AqS3eNz4YFssHLhiNX/2t687qPX2fg 79ddB25VLOXiELtEL50mQJCfSPFsyoYLviYcSpByyT3bWuOdegxZqdUJj2KfjKvPyCXgZ 19ZAub4FvTg/ohikNNkDeMn3jscxSG4FEeZYWJ59Id4AVc2JBrBV6n93H1ZjXL+6G/Qa6 5d8CS39Vlf6GpQd0rj82tc458vMaQuasdfJsT+YxGGsQLIDd1H//ZKDSB3jesjPtzaw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gNXg2gLE; arc=none smtp.remote-ip=100.103.45.18 Received: from smtp.kernel.org (quasi.space.kernel.org [100.103.45.18]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8B3FB606A323; Wed, 2 Dec 2026 12:35:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.a=rsa-sha256 header.s=k20260515 header.b=gNXg2gLE Received: by smtp.kernel.org (Postfix) with ESMTPSA id D11401F000C1; Wed, 2 Dec 2026 12:35:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1796214926; bh=w81uNgqMMrWKkyaL7dUzyRba4DGv7FkWKGxcpbVuxCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gNXg2gLEmJ3wrXgJNoI6gBceEUszKIoKhBTEBGMTkXW2zwMsUq9YyvQcYcN/yimbh b/Ty27XvwnW1xLy5gC4FxX1cmWLK5bI73XB2fVIbpkJvQ9gDDpgmx9u1Hn7kSQqKHp HxfXfF+zX7FbOJ8z07BK7J66k9UqDVdP3/AhJ/K8+gDsbjouAqH3Y7a+N5HfQXXLCp Sy6n2ZD8D6eFjuK9M5FieIy3vYOkUPaCIpbmej5dLmljrNVL9hK3eGtaLTEulVaGr9 +9OnB7QCYWtVK2xbXhhiXHKBbRssBzsUPx59HbMmsQYZo+eUU7YtFYgF4YbWkw99Ql 0Wz2RZeQhb+fw== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko , Masami Hiramatsu Cc: bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org, x86@kernel.org, Song Liu , Yonghong Song , Quentin Monnet , Alan Maguire Subject: [PATCH RFC bpf-next 28/31] selftests/bpf: Add kprobe multi inline strict test Date: Wed, 2 Dec 2026 13:30:32 +0100 Message-ID: <20261202123035.10335-29-jolsa@kernel.org> X-Mailer: git-send-email 2.56.1 In-Reply-To: <20261202123035.10335-1-jolsa@kernel.org> References: <20261202123035.10335-1-jolsa@kernel.org> X-Mailing-List: linux-trace-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add inline_strict test for kprobe multi link with BPF_F_KPROBE_MULTI_INLINE_STRICT flag: - the attach fails when the flag is used without BPF_F_KPROBE_MULTI_INLINE flag - the attach fails for function with inlined instance that can't be attached, and the log names the function and the instance - the attach succeeds for function with all the inlined instances attached and link's fdinfo shows no skipped instance Signed-off-by: Jiri Olsa --- .../bpf/prog_tests/kprobe_multi_test.c | 82 +++++++++++++++++++ 1 file changed, 82 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c index 761cd7fe63ac..f3eb95261c7a 100644 --- a/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/kprobe_multi_test.c @@ -1326,6 +1326,86 @@ static void test_inline_fails(void) kprobe_multi_inline__destroy(skel); } +/* With strict flag all the inlined instances need to be attached. */ +static void test_inline_strict(void) +{ + LIBBPF_OPTS(bpf_kprobe_multi_opts, opts); + LIBBPF_OPTS(bpf_link_create_opts, lopts); + const char *partial[1] = { "bpf_kprobe_multi_inline_partial" }; + const char *syms[1] = { "bpf_kprobe_multi_inline_inner" }; + struct kprobe_multi_inline *skel = NULL; + unsigned long sites[INLINE_MAX]; + int cnt, saved_error, prog_fd, link_fd; + + cnt = get_inline_sites(syms[0], sites, INLINE_MAX); + if (cnt == -ENOENT) { + test__skip(); + return; + } + if (!ASSERT_EQ(cnt, 2, "inline_sites_cnt")) + return; + + skel = kprobe_multi_inline__open_and_load(); + if (!ASSERT_OK_PTR(skel, "kprobe_multi_inline__open_and_load")) + return; + + prog_fd = bpf_program__fd(skel->progs.test_kprobe_inline); + + /* strict without inlined */ + opts.syms = syms; + opts.cnt = 1; + opts.inlined_strict = true; + + skel->links.test_kprobe_inline = + bpf_program__attach_kprobe_multi_opts(skel->progs.test_kprobe_inline, NULL, &opts); + saved_error = -errno; + if (!ASSERT_ERR_PTR(skel->links.test_kprobe_inline, "strict_no_inlined")) + goto cleanup; + ASSERT_EQ(saved_error, -EINVAL, "strict_no_inlined_error"); + + lopts.kprobe_multi.syms = syms; + lopts.kprobe_multi.cnt = 1; + lopts.kprobe_multi.flags = BPF_F_KPROBE_MULTI_INLINE_STRICT; + + if (!inline_link_fails(prog_fd, BPF_TRACE_KPROBE_MULTI, &lopts, -EINVAL, + "Strict flag needs to be used with inline flag.")) + goto cleanup; + + /* function with inlined instance that can't be attached */ + opts.syms = partial; + opts.inlined = true; + + skel->links.test_kprobe_inline = + bpf_program__attach_kprobe_multi_opts(skel->progs.test_kprobe_inline, NULL, &opts); + saved_error = -errno; + if (!ASSERT_ERR_PTR(skel->links.test_kprobe_inline, "strict_partial")) + goto cleanup; + ASSERT_EQ(saved_error, -EINVAL, "strict_partial_error"); + + lopts.kprobe_multi.syms = partial; + lopts.kprobe_multi.flags = BPF_F_KPROBE_MULTI_INLINE | BPF_F_KPROBE_MULTI_INLINE_STRICT; + + if (!inline_link_fails(prog_fd, BPF_TRACE_KPROBE_MULTI, &lopts, -EINVAL, + "Function bpf_kprobe_multi_inline_partial has inlined instance " + "that can't be attached, bpf_kprobe_multi_inline_test4+")) + goto cleanup; + + /* function with all the inlined instances attached */ + opts.syms = syms; + + skel->links.test_kprobe_inline = + bpf_program__attach_kprobe_multi_opts(skel->progs.test_kprobe_inline, NULL, &opts); + if (!ASSERT_OK_PTR(skel->links.test_kprobe_inline, "strict_attach")) + goto cleanup; + + link_fd = bpf_link__fd(skel->links.test_kprobe_inline); + ASSERT_EQ(get_fdinfo_cnt(link_fd, "kprobe_inline_cnt"), cnt, "kprobe_inline_cnt"); + ASSERT_EQ(get_fdinfo_cnt(link_fd, "kprobe_inline_skipped"), 0, "kprobe_inline_skipped"); + +cleanup: + kprobe_multi_inline__destroy(skel); +} + /* Run all the tests for attaching to inlined functions. */ static void test_inline_subtests(void) { @@ -1344,6 +1424,8 @@ static void test_inline_subtests(void) test_inline_fails(); if (test__start_subtest("inline_module")) test_inline_module(); + if (test__start_subtest("inline_strict")) + test_inline_strict(); free_inline_btf(); } -- 2.56.1