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 8A54CC38A2D for ; Tue, 25 Oct 2022 13:43:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230294AbiJYNnN (ORCPT ); Tue, 25 Oct 2022 09:43:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44644 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232404AbiJYNnN (ORCPT ); Tue, 25 Oct 2022 09:43:13 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 82B22183D83 for ; Tue, 25 Oct 2022 06:43:12 -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 36570B81D3E for ; Tue, 25 Oct 2022 13:43:11 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8202DC433C1; Tue, 25 Oct 2022 13:43:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1666705389; bh=5ntUDp/6Up6cYJCfHl9XG8Bio8zzPLtnVfgJMeHZuYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SaivMYgMC0Qw3QHjqITG2k0QcWfmN7lBAoi+FZ8AM50FKG0pUbqrFTi1qUJrLfoMS rhBTjk7tVcbtrxEUUrGpjnZjsOaFUxaIReP+BSUGoTZsTVISJ193BykQmFCVQ7jgMx yaT9m6qfhQLfS8x9SaN+2J1wIn22l5krh+P3R4g/0Um5kkuvmKO090OpFspAoRbmc4 PHjDhBv4l+4nZxShy+M3K69Ox9SFgLSYMTECMN2LNLEGvuHIlihGunAB1Ar3kV/vsI lz7plHajY94EHqEeNExUS8aBlt/vxvuqVGJQbt1OXNg6+HIhVT/AgK4aAr5ceEZvCY z1ajDu2N5IXyA== From: Jiri Olsa To: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Cc: Song Liu , 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: [PATCHv3 bpf-next 7/8] selftests/bpf: Add kprobe_multi check to module attach test Date: Tue, 25 Oct 2022 15:41:47 +0200 Message-Id: <20221025134148.3300700-8-jolsa@kernel.org> X-Mailer: git-send-email 2.37.3 In-Reply-To: <20221025134148.3300700-1-jolsa@kernel.org> References: <20221025134148.3300700-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. Acked-by: Song Liu 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