From nobody Sat Sep 13 10:59:44 2025 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 367A1C61DA4 for ; Fri, 3 Feb 2023 03:18:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232369AbjBCDSr (ORCPT ); Thu, 2 Feb 2023 22:18:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46204 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232365AbjBCDSn (ORCPT ); Thu, 2 Feb 2023 22:18:43 -0500 Received: from mail-pj1-x1041.google.com (mail-pj1-x1041.google.com [IPv6:2607:f8b0:4864:20::1041]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2B24A53B31; Thu, 2 Feb 2023 19:18:42 -0800 (PST) Received: by mail-pj1-x1041.google.com with SMTP id on9-20020a17090b1d0900b002300a96b358so3754304pjb.1; Thu, 02 Feb 2023 19:18:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=z8T4GxvH3ecLMhoa7M3nY3X271thDzk3OTlhfr3JaAo=; b=P2kniv+c+Jjutwu7YxBz3n1H/q/DaWJXjCH5FnGUXyQ3JHM7nd8fNOeFFMuJ68dyB1 srltCs8oOu67F1U31W2arJf/DzqZ5e2IUHm95hod36+Wz8wSnlml/LA2PhvEzJ8LTl77 +ukxMFCprDtQ61Zxnr9+1p0nQlpYoK2AGRfj/577H29pKSRd5ctZNy/32W97GDnPKDVi mHI70Rd53/cwkv3xLrZ2nmlkRBH+9X3xNuFjrzZaEsiqg6kRd748FzIZQFqkK4yGm20K 8evuF1MbB4jANMspENTD39RHQUHJnfdgymHSQqrB11BSTByxFF1yHkURSRP2eRyhHkiy IJmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=z8T4GxvH3ecLMhoa7M3nY3X271thDzk3OTlhfr3JaAo=; b=7rccsrJoJNz+RpoxUanHTttAyJHDSNS2O4x2LRXC6dc7gxaiAefrbtw1YkYcMeZDqt cxjuoqX/SKki9chTErppID72WksHt9T7chZpBpGKMsd2sq2LVXLmR4afS77Iatu5TY/i hUGGg8NDd+eq7Gft6ZaPyW38U464SjmQKFCIXtLoxJn97u4IsFq7QTiy+ta0DJpxRM7k jDkyIcgmzJKC4fOwRsB2KuF/R3p1Doalrw/ObuHvgZDmRFuZit6b8749kaQjnhdJNht1 YwJN/LzYZsMdNtZESFmvPAVlAXKu3X09txstgGUKebqskd9TWTB7t85HW1ELaW5Q2J72 PfrA== X-Gm-Message-State: AO0yUKWPAKSzWs13V9tQVSUCnFU9D/46snEzbG5IHgUPzJviu1j8AEKC t6ujOAOQKB3fEuylVzxIWrU= X-Google-Smtp-Source: AK7set8hxFh78t84Wu3vvyZhpeFeVBfycuBPgxdA4MmDzd3t0um/NAueLlybWvLLbhMWrjVolYcSRw== X-Received: by 2002:a17:902:f2c5:b0:196:8437:1b38 with SMTP id h5-20020a170902f2c500b0019684371b38mr7166029plc.58.1675394321590; Thu, 02 Feb 2023 19:18:41 -0800 (PST) Received: from localhost.localdomain ([203.205.141.16]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ee8900b001899c2a0ae0sm416009pld.40.2023.02.02.19.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 19:18:41 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: andrii.nakryiko@gmail.com, alan.maguire@oracle.com Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH bpf-next 1/2] libbpf: add support to set kprobe/uprobe attach mode Date: Fri, 3 Feb 2023 11:17:41 +0800 Message-Id: <20230203031742.1730761-2-imagedong@tencent.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203031742.1730761-1-imagedong@tencent.com> References: <20230203031742.1730761-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong By default, libbpf will attach the kprobe/uprobe eBPF program in the latest mode that supported by kernel. In this patch, we add the support to let users manually attach kprobe/uprobe in legacy or perf mode. There are 3 mode that supported by the kernel to attach kprobe/uprobe: LEGACY: create perf event in legacy way and don't use bpf_link PERF: create perf event with perf_event_open() and don't use bpf_link LINK: create perf event with perf_event_open() and use bpf_link Users now can manually choose the mode with bpf_program__attach_uprobe_opts()/bpf_program__attach_kprobe_opts(). Link: https://lore.kernel.org/bpf/20230113093427.1666466-1-imagedong@tencen= t.com/ Signed-off-by: Menglong Dong --- tools/lib/bpf/libbpf.c | 26 +++++++++++++++++++++++++- tools/lib/bpf/libbpf.h | 19 ++++++++++++++++--- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/tools/lib/bpf/libbpf.c b/tools/lib/bpf/libbpf.c index eed5cec6f510..0d20bf1ee301 100644 --- a/tools/lib/bpf/libbpf.c +++ b/tools/lib/bpf/libbpf.c @@ -9784,7 +9784,7 @@ struct bpf_link *bpf_program__attach_perf_event_opts(= const struct bpf_program *p link->link.dealloc =3D &bpf_link_perf_dealloc; link->perf_event_fd =3D pfd; =20 - if (kernel_supports(prog->obj, FEAT_PERF_LINK)) { + if (kernel_supports(prog->obj, FEAT_PERF_LINK) && !opts->no_link) { DECLARE_LIBBPF_OPTS(bpf_link_create_opts, link_opts, .perf_event.bpf_cookie =3D OPTS_GET(opts, bpf_cookie, 0)); =20 @@ -10148,16 +10148,28 @@ bpf_program__attach_kprobe_opts(const struct bpf_= program *prog, struct bpf_link *link; size_t offset; bool retprobe, legacy; + enum probe_mode mode; int pfd, err; =20 if (!OPTS_VALID(opts, bpf_kprobe_opts)) return libbpf_err_ptr(-EINVAL); =20 + mode =3D OPTS_GET(opts, mode, PROBE_MODE_DEFAULT); retprobe =3D OPTS_GET(opts, retprobe, false); offset =3D OPTS_GET(opts, offset, 0); pe_opts.bpf_cookie =3D OPTS_GET(opts, bpf_cookie, 0); =20 legacy =3D determine_kprobe_perf_type() < 0; + switch (mode) { + case PROBE_MODE_LEGACY: + legacy =3D true; + case PROBE_MODE_PERF: + pe_opts.no_link =3D true; + break; + default: + break; + } + if (!legacy) { pfd =3D perf_event_open_probe(false /* uprobe */, retprobe, func_name, offset, @@ -10817,10 +10829,12 @@ bpf_program__attach_uprobe_opts(const struct bpf_= program *prog, pid_t pid, int pfd, err; bool retprobe, legacy; const char *func_name; + enum probe_mode mode; =20 if (!OPTS_VALID(opts, bpf_uprobe_opts)) return libbpf_err_ptr(-EINVAL); =20 + mode =3D OPTS_GET(opts, mode, PROBE_MODE_DEFAULT); retprobe =3D OPTS_GET(opts, retprobe, false); ref_ctr_off =3D OPTS_GET(opts, ref_ctr_offset, 0); pe_opts.bpf_cookie =3D OPTS_GET(opts, bpf_cookie, 0); @@ -10849,6 +10863,16 @@ bpf_program__attach_uprobe_opts(const struct bpf_p= rogram *prog, pid_t pid, } =20 legacy =3D determine_uprobe_perf_type() < 0; + switch (mode) { + case PROBE_MODE_LEGACY: + legacy =3D true; + case PROBE_MODE_PERF: + pe_opts.no_link =3D true; + break; + default: + break; + } + if (!legacy) { pfd =3D perf_event_open_probe(true /* uprobe */, retprobe, binary_path, func_offset, pid, ref_ctr_off); diff --git a/tools/lib/bpf/libbpf.h b/tools/lib/bpf/libbpf.h index 8777ff21ea1d..7fb474e036a3 100644 --- a/tools/lib/bpf/libbpf.h +++ b/tools/lib/bpf/libbpf.h @@ -451,8 +451,10 @@ struct bpf_perf_event_opts { size_t sz; /* custom user-provided value fetchable through bpf_get_attach_cookie() */ __u64 bpf_cookie; + /* don't use bpf_link when attach eBPF pprogram */ + bool no_link; }; -#define bpf_perf_event_opts__last_field bpf_cookie +#define bpf_perf_event_opts__last_field no_link =20 LIBBPF_API struct bpf_link * bpf_program__attach_perf_event(const struct bpf_program *prog, int pfd); @@ -461,6 +463,13 @@ LIBBPF_API struct bpf_link * bpf_program__attach_perf_event_opts(const struct bpf_program *prog, int pf= d, const struct bpf_perf_event_opts *opts); =20 +enum probe_mode { + PROBE_MODE_DEFAULT =3D 0, /* latest supported by kernel */ + PROBE_MODE_LEGACY, + PROBE_MODE_PERF, + PROBE_MODE_LINK, +}; + struct bpf_kprobe_opts { /* size of this struct, for forward/backward compatiblity */ size_t sz; @@ -470,9 +479,11 @@ struct bpf_kprobe_opts { size_t offset; /* kprobe is return probe */ bool retprobe; + /* kprobe attach mode */ + enum probe_mode mode; size_t :0; }; -#define bpf_kprobe_opts__last_field retprobe +#define bpf_kprobe_opts__last_field mode =20 LIBBPF_API struct bpf_link * bpf_program__attach_kprobe(const struct bpf_program *prog, bool retprobe, @@ -570,9 +581,11 @@ struct bpf_uprobe_opts { * binary_path. */ const char *func_name; + /* uprobe attach mode */ + enum probe_mode mode; size_t :0; }; -#define bpf_uprobe_opts__last_field func_name +#define bpf_uprobe_opts__last_field mode =20 /** * @brief **bpf_program__attach_uprobe()** attaches a BPF program --=20 2.39.0 From nobody Sat Sep 13 10:59:44 2025 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 03F47C636CC for ; Fri, 3 Feb 2023 03:19:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232424AbjBCDTB (ORCPT ); Thu, 2 Feb 2023 22:19:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46512 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232272AbjBCDS4 (ORCPT ); Thu, 2 Feb 2023 22:18:56 -0500 Received: from mail-pl1-x644.google.com (mail-pl1-x644.google.com [IPv6:2607:f8b0:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06B2C530DC; Thu, 2 Feb 2023 19:18:46 -0800 (PST) Received: by mail-pl1-x644.google.com with SMTP id n13so3969771plf.11; Thu, 02 Feb 2023 19:18:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=EoGM7XRz0NZ0b6mw+q1l4grA9yKTex8169ZS160dcgc=; b=LAYoO2jHuYh9BSeeauAsVBpKHu3MDRm6RHxQMurlHAQknWS6gvHda8E9DnSvxHbqZ5 kR2HddgphBX7H8unFVpIRIYHhvscbjlLVZRTmZEsw+CTJbyQjnxGFVdVxxu/MqHcMxte pPGbeSjP39vX0dlIBIivxysmr0xdXFrLtLPLxQgvvRIZT96iZgiflgG7ao3nGzu8xszE z/mTipwcKnLswdz9LN+39Q8Qrvq8EUVForGIX8vYyeNDAl8r9O7PCh7R0zKD20peFV7A dkEd9rjpXr/M+1hPJKTKncrdcxA33vzKuDsGtJWQY6MJgKgEFQxLh/H7vx1GwrneZzQ4 CnVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EoGM7XRz0NZ0b6mw+q1l4grA9yKTex8169ZS160dcgc=; b=iPqz/RmfoeOHHINvnmqLNtRXz9zOlWFd5Yy4l8N6oYcKFrW78oRj3rKMpAhl3o/I+w DfTN8EAU3DEkfbfOdKVDJpDLTV/CWmKfwNo+XnlB0ANUeXFifAKp/kY6zTAsvabGx5Xu aI/LoksNFUz0Vp7To8XRJDw3J+AUuLJPzHxtM037IkIoG9UdcXXCHrh8ept+cALw9tJ9 /Ylp3I4Ejhi0sHIAALNfqkppoXJw+E7hrMUaKi8pG0O1D+UNnb8Y6+IVy6Z6P1uai8px MPGI0mVv5twgwQFL41W0SUNrb49QraTo2RUT6tFxWD4AtuiN0NqHRAIDag8i5Qp+y731 1C9g== X-Gm-Message-State: AO0yUKXGxVNdtd+OiEdo0IRWSemcXyiZAPoRvFn3MqdgEllXOqddUtdj tbQelr9TuETs56GtEeuUsd4= X-Google-Smtp-Source: AK7set+fh9niTzV6bNDk2mIMsd5eSjfHj1yS6Gdv/GTiSy5CKm/sFxd6l/89OtbIJEajFZp+tG36Cg== X-Received: by 2002:a17:902:e888:b0:196:2949:3ca7 with SMTP id w8-20020a170902e88800b0019629493ca7mr10454960plg.7.1675394325544; Thu, 02 Feb 2023 19:18:45 -0800 (PST) Received: from localhost.localdomain ([203.205.141.16]) by smtp.gmail.com with ESMTPSA id a9-20020a170902ee8900b001899c2a0ae0sm416009pld.40.2023.02.02.19.18.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 19:18:45 -0800 (PST) From: menglong8.dong@gmail.com X-Google-Original-From: imagedong@tencent.com To: andrii.nakryiko@gmail.com, alan.maguire@oracle.com Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org, martin.lau@linux.dev, song@kernel.org, yhs@fb.com, john.fastabend@gmail.com, kpsingh@kernel.org, sdf@google.com, haoluo@google.com, jolsa@kernel.org, bpf@vger.kernel.org, linux-kernel@vger.kernel.org, Menglong Dong Subject: [PATCH bpf-next 2/2] selftests/bpf: add test for legacy/perf kprobe/uprobe attach mode Date: Fri, 3 Feb 2023 11:17:42 +0800 Message-Id: <20230203031742.1730761-3-imagedong@tencent.com> X-Mailer: git-send-email 2.39.0 In-Reply-To: <20230203031742.1730761-1-imagedong@tencent.com> References: <20230203031742.1730761-1-imagedong@tencent.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Menglong Dong Add the testing for kprobe/uprobe attaching in legacy and perf mode. And the testing passed: ./test_progs -t attach_probe $5 attach_probe:OK Summary: 1/0 PASSED, 0 SKIPPED, 0 FAILED Signed-off-by: Menglong Dong --- .../selftests/bpf/prog_tests/attach_probe.c | 61 ++++++++++++++++++- .../selftests/bpf/progs/test_attach_probe.c | 32 ++++++++++ 2 files changed, 92 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/prog_tests/attach_probe.c b/tools/= testing/selftests/bpf/prog_tests/attach_probe.c index 9566d9d2f6ee..5f6212ac0b6d 100644 --- a/tools/testing/selftests/bpf/prog_tests/attach_probe.c +++ b/tools/testing/selftests/bpf/prog_tests/attach_probe.c @@ -23,15 +23,22 @@ static noinline void trigger_func3(void) asm volatile (""); } =20 +/* attach point for legacy uprobe */ +static noinline void trigger_func4(void) +{ + asm volatile (""); +} + static char test_data[] =3D "test_data"; =20 void test_attach_probe(void) { + ssize_t uprobe_offset, uprobe4_offset, ref_ctr_offset; DECLARE_LIBBPF_OPTS(bpf_uprobe_opts, uprobe_opts); struct bpf_link *kprobe_link, *kretprobe_link; struct bpf_link *uprobe_link, *uretprobe_link; + DECLARE_LIBBPF_OPTS(bpf_kprobe_opts, opts); struct test_attach_probe* skel; - ssize_t uprobe_offset, ref_ctr_offset; struct bpf_link *uprobe_err_link; bool legacy; char *mem; @@ -86,6 +93,25 @@ void test_attach_probe(void) goto cleanup; skel->links.handle_kretprobe =3D kretprobe_link; =20 + /* manual-attach kprobe in legacy mode */ + opts.retprobe =3D false; + opts.mode =3D PROBE_MODE_LEGACY; + kprobe_link =3D bpf_program__attach_kprobe_opts(skel->progs.handle_kprobe= _legacy, + SYS_NANOSLEEP_KPROBE_NAME, + &opts); + if (!ASSERT_OK_PTR(kprobe_link, "attach_kprobe_legacy")) + goto cleanup; + skel->links.handle_kprobe_legacy =3D kprobe_link; + + /* manual-attach kprobe in perf mode */ + opts.mode =3D PROBE_MODE_PERF; + kprobe_link =3D bpf_program__attach_kprobe_opts(skel->progs.handle_kprobe= _perf, + SYS_NANOSLEEP_KPROBE_NAME, + &opts); + if (!ASSERT_OK_PTR(kprobe_link, "attach_kprobe_perf")) + goto cleanup; + skel->links.handle_kprobe_perf =3D kprobe_link; + /* auto-attachable kprobe and kretprobe */ skel->links.handle_kprobe_auto =3D bpf_program__attach(skel->progs.handle= _kprobe_auto); ASSERT_OK_PTR(skel->links.handle_kprobe_auto, "attach_kprobe_auto"); @@ -110,6 +136,32 @@ void test_attach_probe(void) if (!legacy) ASSERT_GT(uprobe_ref_ctr, 0, "uprobe_ref_ctr_after"); =20 + uprobe4_offset =3D get_uprobe_offset(&trigger_func4); + if (!ASSERT_GE(uprobe4_offset, 0, "uprobe4_offset")) + goto cleanup; + + uprobe_opts.mode =3D PROBE_MODE_LEGACY; + uprobe_opts.ref_ctr_offset =3D 0; + uprobe_link =3D bpf_program__attach_uprobe_opts(skel->progs.handle_uprobe= _legacy, + 0 /* self pid */, + "/proc/self/exe", + uprobe4_offset, + &uprobe_opts); + if (!ASSERT_OK_PTR(uprobe_link, "attach_uprobe_legacy")) + goto cleanup; + skel->links.handle_uprobe_legacy =3D uprobe_link; + + uprobe_opts.mode =3D PROBE_MODE_PERF; + uprobe_opts.ref_ctr_offset =3D legacy ? 0 : ref_ctr_offset; + uprobe_link =3D bpf_program__attach_uprobe_opts(skel->progs.handle_uprobe= _perf, + 0 /* self pid */, + "/proc/self/exe", + uprobe_offset, + &uprobe_opts); + if (!ASSERT_OK_PTR(uprobe_link, "attach_uprobe_perf")) + goto cleanup; + skel->links.handle_uprobe_perf =3D uprobe_link; + /* if uprobe uses ref_ctr, uretprobe has to use ref_ctr as well */ uprobe_opts.retprobe =3D true; uprobe_opts.ref_ctr_offset =3D legacy ? 0 : ref_ctr_offset; @@ -207,11 +259,18 @@ void test_attach_probe(void) /* trigger & validate sleepable uprobe attached by name */ trigger_func3(); =20 + /* trigger & validate uprobe in legacy mode */ + trigger_func4(); + ASSERT_EQ(skel->bss->kprobe_res, 1, "check_kprobe_res"); ASSERT_EQ(skel->bss->kprobe2_res, 11, "check_kprobe_auto_res"); + ASSERT_EQ(skel->bss->kprobe3_res, 3, "check_kprobe_legacy_res"); + ASSERT_EQ(skel->bss->kprobe4_res, 4, "check_kprobe_perf_res"); ASSERT_EQ(skel->bss->kretprobe_res, 2, "check_kretprobe_res"); ASSERT_EQ(skel->bss->kretprobe2_res, 22, "check_kretprobe_auto_res"); ASSERT_EQ(skel->bss->uprobe_res, 3, "check_uprobe_res"); + ASSERT_EQ(skel->bss->uprobe2_res, 4, "check_uprobe_legacy_res"); + ASSERT_EQ(skel->bss->uprobe3_res, 5, "check_uprobe_perf_res"); ASSERT_EQ(skel->bss->uretprobe_res, 4, "check_uretprobe_res"); ASSERT_EQ(skel->bss->uprobe_byname_res, 5, "check_uprobe_byname_res"); ASSERT_EQ(skel->bss->uretprobe_byname_res, 6, "check_uretprobe_byname_res= "); diff --git a/tools/testing/selftests/bpf/progs/test_attach_probe.c b/tools/= testing/selftests/bpf/progs/test_attach_probe.c index a1e45fec8938..6674deea5686 100644 --- a/tools/testing/selftests/bpf/progs/test_attach_probe.c +++ b/tools/testing/selftests/bpf/progs/test_attach_probe.c @@ -9,9 +9,13 @@ =20 int kprobe_res =3D 0; int kprobe2_res =3D 0; +int kprobe3_res =3D 0; +int kprobe4_res =3D 0; int kretprobe_res =3D 0; int kretprobe2_res =3D 0; int uprobe_res =3D 0; +int uprobe2_res =3D 0; +int uprobe3_res =3D 0; int uretprobe_res =3D 0; int uprobe_byname_res =3D 0; int uretprobe_byname_res =3D 0; @@ -30,6 +34,20 @@ int handle_kprobe(struct pt_regs *ctx) return 0; } =20 +SEC("kprobe") +int handle_kprobe_legacy(struct pt_regs *ctx) +{ + kprobe3_res =3D 3; + return 0; +} + +SEC("kprobe") +int handle_kprobe_perf(struct pt_regs *ctx) +{ + kprobe4_res =3D 4; + return 0; +} + SEC("ksyscall/nanosleep") int BPF_KSYSCALL(handle_kprobe_auto, struct __kernel_timespec *req, struct= __kernel_timespec *rem) { @@ -69,6 +87,20 @@ int handle_uprobe(struct pt_regs *ctx) return 0; } =20 +SEC("uprobe") +int handle_uprobe_legacy(struct pt_regs *ctx) +{ + uprobe2_res =3D 4; + return 0; +} + +SEC("uprobe") +int handle_uprobe_perf(struct pt_regs *ctx) +{ + uprobe3_res =3D 5; + return 0; +} + SEC("uretprobe") int handle_uretprobe(struct pt_regs *ctx) { --=20 2.39.0