From patchwork Sun Sep 29 20:57:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13815236 X-Patchwork-Delegate: bpf@iogearbox.net Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 077F2178CC8; Sun, 29 Sep 2024 20:59:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727643566; cv=none; b=qyzgudQ71gX8J0OTBVere4KfSul3lB7S/JN4hfI6pMRlRYFcQspWWBydXN3+lhun3hGG1OeQwJnyG6zLf9MpLKimgn224ILUUOH1J8x5HlfeF+UBShMfbhcKkmrOTIdcOq1QEhr18hQ7FYoVYWKbtE5fEGZ2S2/XO/X4+7aU5dM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1727643566; c=relaxed/simple; bh=nDwwKIoORj0HBWMmH82W4I0Tpkb3tviaGj5oODCtCrU=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=c+yqBf0laC3aFdOFJufXungkjZH09ruw2kIr2FCrS9DoCIQ8uD/9oMxIKA/8SNlr0PrZ5TZAMqk9Z238EMcvN+W0WcRt/lWx3CiP8d9V4oy4fZO10DaSMQVSbW+y+2d5CLFz3SDVSVc1W/pMCUtrutVsTO3hml4YOEqXUqBbjNU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=grzzITYy; arc=none smtp.client-ip=10.30.226.201 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="grzzITYy" Received: by smtp.kernel.org (Postfix) with ESMTPSA id DEEF2C4CEC5; Sun, 29 Sep 2024 20:59:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1727643565; bh=nDwwKIoORj0HBWMmH82W4I0Tpkb3tviaGj5oODCtCrU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=grzzITYyIgLjmrS1FMMC+i7xZdPZ5JAlLa26JMGu2xptA7ptJoFMFFMLtV/vLKkr7 fbkSkZQuWnV1evV8hNtq3ffr99KSQihyPLCfdsz14SbOm5g7ht3n7tNuVaYJWK/tgN sDnfd09gUx7uTM7X7AOZ17sxAInygFaJ4dhhWHUpPYhYdLHkiED9C/aIT87MdgTodm XncIdM6WGWnkfgc7GHfOc/DyKB/SLpM2E5+Mcoo65DoaX8+7oUNMau4TFGAxnlbyAH z8qG9nEf++8N63H7Cjcxth5CeQpDrVzhTXx2FrlSA8a/TgYYhaia7qE7BsOwpLNflF WGKukmQQQHl4w== From: Jiri Olsa To: Oleg Nesterov , Peter Zijlstra , Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: bpf@vger.kernel.org, Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Steven Rostedt , Masami Hiramatsu , linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org Subject: [PATCHv5 bpf-next 10/13] selftests/bpf: Add uprobe session verifier test for return value Date: Sun, 29 Sep 2024 22:57:14 +0200 Message-ID: <20240929205717.3813648-11-jolsa@kernel.org> X-Mailer: git-send-email 2.46.1 In-Reply-To: <20240929205717.3813648-1-jolsa@kernel.org> References: <20240929205717.3813648-1-jolsa@kernel.org> Precedence: bulk X-Mailing-List: bpf@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Patchwork-Delegate: bpf@iogearbox.net Making sure uprobe.session program can return only [0,1] values. Signed-off-by: Jiri Olsa --- .../bpf/prog_tests/uprobe_multi_test.c | 2 ++ .../bpf/progs/uprobe_multi_verifier.c | 31 +++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c index 284cd7fce576..e693eeb1a5a5 100644 --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c @@ -11,6 +11,7 @@ #include "uprobe_multi_session.skel.h" #include "uprobe_multi_session_cookie.skel.h" #include "uprobe_multi_session_recursive.skel.h" +#include "uprobe_multi_verifier.skel.h" #include "bpf/libbpf_internal.h" #include "testing_helpers.h" #include "../sdt.h" @@ -1246,4 +1247,5 @@ void test_uprobe_multi_test(void) test_session_cookie_skel_api(); if (test__start_subtest("session_cookie_recursive")) test_session_recursive_skel_api(); + RUN_TESTS(uprobe_multi_verifier); } diff --git a/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c b/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c new file mode 100644 index 000000000000..fe49f2cb5360 --- /dev/null +++ b/tools/testing/selftests/bpf/progs/uprobe_multi_verifier.c @@ -0,0 +1,31 @@ +// SPDX-License-Identifier: GPL-2.0 +#include "vmlinux.h" +#include +#include +#include +#include "bpf_misc.h" + +char _license[] SEC("license") = "GPL"; + + +SEC("uprobe.session") +__success +int uprobe_sesison_return_0(struct pt_regs *ctx) +{ + return 0; +} + +SEC("uprobe.session") +__success +int uprobe_sesison_return_1(struct pt_regs *ctx) +{ + return 1; +} + +SEC("uprobe.session") +__failure +__msg("At program exit the register R0 has smin=2 smax=2 should have been in [0, 1]") +int uprobe_sesison_return_2(struct pt_regs *ctx) +{ + return 2; +}