From patchwork Tue Oct 15 09:10:46 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiri Olsa X-Patchwork-Id: 13835981 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 132D61D6DA1 for ; Tue, 15 Oct 2024 09:12:51 +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=1728983572; cv=none; b=NSaanmNK+4nbvznkgXMOHG/vqjW3C7oeIvBDFUO37qtjAC1wbIhK4LdBlV7veQAvAfekKKi4J0BARhVQsffqotyp8W27WwJv6Dv1U2/k8XOHyBpo31win4gzy/CGxa2k8J2PsXLi1Pb+W0DdxTm2qxeG8QAObnIBdim9AK2hj+k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728983572; c=relaxed/simple; bh=vWoH7hbVui+QQQvKzVGIAPGWJG2xt/YhgttiE1WizNY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=VWcKmXDpyH7xt2358zaz89qC3k4rHdg2jpyOyYdl4LcSdPuXZSthtAmbbZL/KYKe2Me9nU83UeM1khEMrqYTF+5MkWF4Zra4BAAl14aEvWHsog5IfKsclB2/s96Vg2DrGz1IboUA5FbNR+bMFZ+O2FtBnebeC/aPbq7S4XTX94M= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=H+synOH2; 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="H+synOH2" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 751A0C4CEC6; Tue, 15 Oct 2024 09:12:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1728983571; bh=vWoH7hbVui+QQQvKzVGIAPGWJG2xt/YhgttiE1WizNY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H+synOH2GfsJEXoDVEGu97uFVP246nGNC1WnNR+3sBiKkggIwtY2x1l+UajOTVgZ1 WM6s6Qq1re1cEzDOlD3VmPiVdf2SMHO9FPKW7hKwnr1qPeniX9vpVffB7mNVgmwE2/ FsvWbFQS9mpYVB694CI3wk7FQvdxgKCU4Gg51qQVkr8KJPsYXlcHfTkoOeb3EFtHXV Dsf0D60yetkiJ5Hq/tPUuvnHAmAi43Nm0Jh0PL8uSg3obaXYS+xznDCEQNgdYKZ5r/ X7SvAtdOZSglZU+xnsA1gi63pifI2c1MzHH23QWr1SlNXurbC3a0/UDi9H14JZGXtk vb7feUHsg3mJg== From: Jiri Olsa To: 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 Subject: [PATCHv7 bpf-next 11/15] selftests/bpf: Add uprobe session verifier test for return value Date: Tue, 15 Oct 2024 11:10:46 +0200 Message-ID: <20241015091050.3731669-12-jolsa@kernel.org> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241015091050.3731669-1-jolsa@kernel.org> References: <20241015091050.3731669-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. Acked-by: Andrii Nakryiko 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; +}