From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 35D2DC433FE for ; Sun, 9 Oct 2022 22:01:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230202AbiJIWBJ (ORCPT ); Sun, 9 Oct 2022 18:01:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33972 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230207AbiJIWBI (ORCPT ); Sun, 9 Oct 2022 18:01:08 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CEC751FCD4 for ; Sun, 9 Oct 2022 15:01:07 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ams.source.kernel.org (Postfix) with ESMTPS id 6694BB80DC9 for ; Sun, 9 Oct 2022 22:01:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id A48DEC433D6; Sun, 9 Oct 2022 22:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665352865; bh=9FjKoXq0ArIIWS0btfWvX1mMzxjB3N06Q3t889Z+luM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WeEYW6mHBVuYeTx6080Euid3qZYfG0TJ8Zu4gczF1Cx/6ikVJxIRjoULXx20ga8yc Ti0JrYxENgAPeFvDJ2dmqr8UyzaKHSyVTCMziJjA/b/Iz3a4q7R4hQEiEY6B68XHLS nZbL5RmKHm9uOM9qxmT4hMwP5QCDFN0y/JADHvBtBzggyhGXAn5om+w1BBlpqGEQn1 HrBy2K+IjqO3wTW2tF28dPRd1vgXbIcRDMSzVu8AWr5nb9JV9JPgZgPl1B2CX4c8AW 2tnj/X2HwCGEHWSSGO3FHDgpXUUrAOytou1mHJ3cRf7eroGh5cVvJAizMWqe7yQeCy tFcGnPTxKSklQ== 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 , Christoph Hellwig , Masami Hiramatsu , Martynas Pumputis Subject: [PATCH bpf-next 8/8] selftests/bpf: Add kprobe_multi check to module attach test Date: Sun, 9 Oct 2022 23:59:26 +0200 Message-Id: <20221009215926.970164-9-jolsa@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221009215926.970164-1-jolsa@kernel.org> References: <20221009215926.970164-1-jolsa@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org Adding test that makes sure the kernel module won't be removed if there's kprobe multi link defined on top of it. Signed-off-by: Jiri Olsa --- tools/testing/selftests/bpf/prog_tests/module_attach.c | 7 +++++++ tools/testing/selftests/bpf/progs/test_module_attach.c | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/module_attach.c b/tools/testing/selftests/bpf/prog_tests/module_attach.c index 6d0e50dcf47c..7fc01ff490db 100644 --- a/tools/testing/selftests/bpf/prog_tests/module_attach.c +++ b/tools/testing/selftests/bpf/prog_tests/module_attach.c @@ -103,6 +103,13 @@ void test_module_attach(void) ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module"); bpf_link__destroy(link); + link = bpf_program__attach(skel->progs.kprobe_multi); + if (!ASSERT_OK_PTR(link, "attach_kprobe_multi")) + goto cleanup; + + ASSERT_ERR(delete_module("bpf_testmod", 0), "delete_module"); + bpf_link__destroy(link); + cleanup: test_module_attach__destroy(skel); } diff --git a/tools/testing/selftests/bpf/progs/test_module_attach.c b/tools/testing/selftests/bpf/progs/test_module_attach.c index 08628afedb77..8a1b50f3a002 100644 --- a/tools/testing/selftests/bpf/progs/test_module_attach.c +++ b/tools/testing/selftests/bpf/progs/test_module_attach.c @@ -110,4 +110,10 @@ int BPF_PROG(handle_fmod_ret, return 0; /* don't override the exit code */ } +SEC("kprobe.multi/bpf_testmod_test_read") +int BPF_PROG(kprobe_multi) +{ + return 0; +} + char _license[] SEC("license") = "GPL"; -- 2.37.3