All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Alan Maguire <alan.maguire@oracle.com>
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	bpf@vger.kernel.org, Martin KaFai Lau <kafai@fb.com>,
	Song Liu <songliubraving@fb.com>, Yonghong Song <yhs@fb.com>,
	John Fastabend <john.fastabend@gmail.com>,
	KP Singh <kpsingh@chromium.org>,
	Stanislav Fomichev <sdf@google.com>, Hao Luo <haoluo@google.com>,
	Oleg Nesterov <oleg@redhat.com>
Subject: Re: [RFC bpf-next 2/2] selftests/bpf: Add uprobe multi fail test
Date: Thu, 14 Dec 2023 10:15:35 +0100	[thread overview]
Message-ID: <ZXrHtwUQZHlXMP_D@krava> (raw)
In-Reply-To: <838a8857-505b-1dc1-cc7e-c8c0960e666a@oracle.com>

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@kernel.org>
> 
> Reviewed-by: Alan Maguire <alan.maguire@oracle.com>
> 
> 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

  reply	other threads:[~2023-12-14  9:15 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-12-13 14:12 [RFC bpf-next 1/2] bpf: Fail uprobe multi link with negative offset Jiri Olsa
2023-12-13 14:12 ` [RFC bpf-next 2/2] selftests/bpf: Add uprobe multi fail test Jiri Olsa
2023-12-13 18:08   ` Alan Maguire
2023-12-14  9:15     ` Jiri Olsa [this message]
2023-12-13 17:51 ` [RFC bpf-next 1/2] bpf: Fail uprobe multi link with negative offset Alan Maguire
2023-12-13 23:35 ` Song Liu
2023-12-14  9:22   ` Jiri Olsa
2023-12-13 23:43 ` Andrii Nakryiko
2023-12-14  9:07   ` Jiri Olsa
2023-12-14 23:28     ` Andrii Nakryiko

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=ZXrHtwUQZHlXMP_D@krava \
    --to=olsajiri@gmail.com \
    --cc=alan.maguire@oracle.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=haoluo@google.com \
    --cc=john.fastabend@gmail.com \
    --cc=kafai@fb.com \
    --cc=kpsingh@chromium.org \
    --cc=oleg@redhat.com \
    --cc=sdf@google.com \
    --cc=songliubraving@fb.com \
    --cc=yhs@fb.com \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.