From: Jiri Olsa <jolsa@kernel.org>
To: stable@vger.kernel.org
Cc: Song Liu <song@kernel.org>,
bpf@vger.kernel.org, Martynas Pumputis <m@lambda.lt>
Subject: [PATCH stable 6.0 6/8] selftests/bpf: Add bpf_testmod_fentry_* functions
Date: Fri, 16 Dec 2022 13:56:26 +0100 [thread overview]
Message-ID: <20221216125628.1622505-7-jolsa@kernel.org> (raw)
In-Reply-To: <20221216125628.1622505-1-jolsa@kernel.org>
commit fee356ede980b6c2c8db612e18b25738356d6744 upstream.
Adding 3 bpf_testmod_fentry_* functions to have a way to test
kprobe multi link on kernel module. They follow bpf_fentry_test*
functions prototypes/code.
Adding equivalent functions to all bpf_fentry_test* does not
seems necessary at the moment, could be added later.
Acked-by: Song Liu <song@kernel.org>
Signed-off-by: Jiri Olsa <jolsa@kernel.org>
Link: https://lore.kernel.org/r/20221025134148.3300700-7-jolsa@kernel.org
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
---
.../selftests/bpf/bpf_testmod/bpf_testmod.c | 24 +++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
index 792cb15bac40..ac5d7c1396fb 100644
--- a/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
+++ b/tools/testing/selftests/bpf/bpf_testmod/bpf_testmod.c
@@ -88,6 +88,23 @@ __weak noinline struct file *bpf_testmod_return_ptr(int arg)
}
}
+noinline int bpf_testmod_fentry_test1(int a)
+{
+ return a + 1;
+}
+
+noinline int bpf_testmod_fentry_test2(int a, u64 b)
+{
+ return a + b;
+}
+
+noinline int bpf_testmod_fentry_test3(char a, int b, u64 c)
+{
+ return a + b + c;
+}
+
+int bpf_testmod_fentry_ok;
+
noinline ssize_t
bpf_testmod_test_read(struct file *file, struct kobject *kobj,
struct bin_attribute *bin_attr,
@@ -119,6 +136,13 @@ bpf_testmod_test_read(struct file *file, struct kobject *kobj,
return snprintf(buf, len, "%d\n", writable.val);
}
+ if (bpf_testmod_fentry_test1(1) != 2 ||
+ bpf_testmod_fentry_test2(2, 3) != 5 ||
+ bpf_testmod_fentry_test3(4, 5, 6) != 15)
+ goto out;
+
+ bpf_testmod_fentry_ok = 1;
+out:
return -EIO; /* always fail */
}
EXPORT_SYMBOL(bpf_testmod_test_read);
--
2.38.1
next prev parent reply other threads:[~2022-12-16 12:57 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-16 12:56 [PATCH stable 6.0 0/8] bpf: Fix kprobe_multi link attachment to kernel modules Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 1/8] kallsyms: Make module_kallsyms_on_each_symbol generally available Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 2/8] ftrace: Add support to resolve module symbols in ftrace_lookup_symbols Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 3/8] bpf: Rename __bpf_kprobe_multi_cookie_cmp to bpf_kprobe_multi_addrs_cmp Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 4/8] bpf: Take module reference on kprobe_multi link Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 5/8] selftests/bpf: Add load_kallsyms_refresh function Jiri Olsa
2022-12-16 12:56 ` Jiri Olsa [this message]
2022-12-16 12:56 ` [PATCH stable 6.0 7/8] selftests/bpf: Add kprobe_multi check to module attach test Jiri Olsa
2022-12-16 12:56 ` [PATCH stable 6.0 8/8] selftests/bpf: Add kprobe_multi kmod attach api tests Jiri Olsa
2022-12-19 12:24 ` [PATCH stable 6.0 0/8] bpf: Fix kprobe_multi link attachment to kernel modules Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221216125628.1622505-7-jolsa@kernel.org \
--to=jolsa@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=m@lambda.lt \
--cc=song@kernel.org \
--cc=stable@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox