On Wed, Dec 13, 2023 at 06:08:54PM +0000, Alan Maguire wrote: > On 13/12/2023 14:12, Jiri Olsa wrote: > > We fail to create uprobe if we pass negative offset, > > adding test for that. > > > > Signed-off-by: Jiri Olsa <jolsa@xxxxxxxxxx> > > Reviewed-by: Alan Maguire <alan.maguire@xxxxxxxxxx> > > small suggestion below.. > > > --- > > .../bpf/prog_tests/uprobe_multi_test.c | 27 +++++++++++++++++++ > > 1 file changed, 27 insertions(+) > > > > 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 ece260cf2c0b..aebfa7e6bfd6 100644 > > --- a/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c > > +++ b/tools/testing/selftests/bpf/prog_tests/uprobe_multi_test.c > > @@ -326,6 +326,31 @@ void test_link_api(void) > > __test_link_api(child); > > } > > > > +static void test_attach_api_fails(void) > > +{ > > + LIBBPF_OPTS(bpf_link_create_opts, opts); > > + const char *path = "/proc/self/exe"; > > + struct uprobe_multi *skel = NULL; > > + int prog_fd, link_fd; > > + long offset = -1; > > + > > + skel = uprobe_multi__open_and_load(); > > + if (!ASSERT_OK_PTR(skel, "uprobe_multi__open_and_load")) > > + return; > > + > > + /* fail_1 - attach on negative offset */ > > + opts.uprobe_multi.path = path; > > + opts.uprobe_multi.offsets = (unsigned long *) &offset; > > + opts.uprobe_multi.cnt = 1; > > + > > + prog_fd = bpf_program__fd(skel->progs.uprobe_extra); > > + link_fd = bpf_link_create(prog_fd, 0, BPF_TRACE_UPROBE_MULTI, &opts); > > + if (!ASSERT_EQ(link_fd, -EINVAL, "link_fd")) > > + close(link_fd); > > + > > would it be worth exercising a few additional error cases here? not > specifying offsets/cnt triggers an EINVAL too. yes, I think we can add more tests in here, will check thanks, jirka