All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jiri Olsa <olsajiri@gmail.com>
To: Andrii Nakryiko <andrii.nakryiko@gmail.com>
Cc: Jiri Olsa <olsajiri@gmail.com>, Oleg Nesterov <oleg@redhat.com>,
	Peter Zijlstra <peterz@infradead.org>,
	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@fomichev.me>, Hao Luo <haoluo@google.com>,
	Steven Rostedt <rostedt@goodmis.org>,
	Masami Hiramatsu <mhiramat@kernel.org>,
	linux-kernel@vger.kernel.org, linux-trace-kernel@vger.kernel.org
Subject: Re: [PATCHv5 bpf-next 03/13] bpf: Add support for uprobe multi session attach
Date: Wed, 2 Oct 2024 15:07:02 +0200	[thread overview]
Message-ID: <Zv1FdjGzPf4KhtzP@krava> (raw)
In-Reply-To: <CAEf4BzaRrg_=scWTt1X7fvB+4wxUiiQUOCPvvtWgL4_rwr+2CQ@mail.gmail.com>

On Tue, Oct 01, 2024 at 10:11:13AM -0700, Andrii Nakryiko wrote:
> On Tue, Oct 1, 2024 at 6:17 AM Jiri Olsa <olsajiri@gmail.com> wrote:
> >
> > On Mon, Sep 30, 2024 at 02:36:08PM -0700, Andrii Nakryiko wrote:
> >
> > SNIP
> >
> > > >  struct bpf_uprobe_multi_link {
> > > > @@ -3248,9 +3260,13 @@ uprobe_multi_link_handler(struct uprobe_consumer *con, struct pt_regs *regs,
> > > >                           __u64 *data)
> > > >  {
> > > >         struct bpf_uprobe *uprobe;
> > > > +       int ret;
> > > >
> > > >         uprobe = container_of(con, struct bpf_uprobe, consumer);
> > > > -       return uprobe_prog_run(uprobe, instruction_pointer(regs), regs);
> > > > +       ret = uprobe_prog_run(uprobe, instruction_pointer(regs), regs);
> > > > +       if (uprobe->session)
> > > > +               return ret ? UPROBE_HANDLER_IGNORE : 0;
> > > > +       return ret;
> > >
> > > isn't this a bug that BPF program can return arbitrary value here and,
> > > e.g., request uprobe unregistration?
> > >
> > > Let's return 0, unless uprobe->session? (it would be good to move that
> > > into a separate patch with Fixes)
> >
> > yea there's no use case for uprobe multi user, so let's return
> > 0 as you suggest
> >
> > >
> > > >  }
> > > >
> > > >  static int
> > > > @@ -3260,6 +3276,12 @@ uprobe_multi_link_ret_handler(struct uprobe_consumer *con, unsigned long func, s
> > > >         struct bpf_uprobe *uprobe;
> > > >
> > > >         uprobe = container_of(con, struct bpf_uprobe, consumer);
> > > > +       /*
> > > > +        * There's chance we could get called with NULL data if we registered uprobe
> > > > +        * after it hit entry but before it hit return probe, just ignore it.
> > > > +        */
> > > > +       if (uprobe->session && !data)
> > > > +               return 0;
> > >
> > > why can't handle_uretprobe_chain() do this check instead? We know when
> > > we are dealing with session uprobe/uretprobe, so we can filter out
> > > these spurious calls, no?
> >
> > right, now that we decide session based on presence of both callbacks
> > we have that info in here handle_uretprobe_chain.. but let's still check
> > it for sanity and warn? like
> >
> >         if (WARN_ON_ONCE(uprobe->session && !data))
> 
> You mean to check this *additionally* in uprobe_multi_link_handler(),
> after core uprobe code already filtered that condition out? It won't
> hurt, but I'm not sure I see the point?

yes, it's cross subsytem call so just to be on safe side for future,
but I don't insist

jirka

  reply	other threads:[~2024-10-02 13:07 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-09-29 20:57 [PATCHv5 bpf-next 00/13] uprobe, bpf: Add session support Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 01/13] uprobe: Add data pointer to consumer handlers Jiri Olsa
2024-09-30  9:34   ` Oleg Nesterov
2024-09-30 21:35   ` Andrii Nakryiko
2024-09-29 20:57 ` [PATCHv5 bpf-next 02/13] uprobe: Add support for session consumer Jiri Olsa
2024-09-30  9:40   ` Oleg Nesterov
2024-09-30 11:42     ` Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:17     ` Jiri Olsa
2024-10-01 17:09       ` Andrii Nakryiko
2024-09-29 20:57 ` [PATCHv5 bpf-next 03/13] bpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:17     ` Jiri Olsa
2024-10-01 17:11       ` Andrii Nakryiko
2024-10-02 13:07         ` Jiri Olsa [this message]
2024-09-29 20:57 ` [PATCHv5 bpf-next 04/13] bpf: Add support for uprobe multi session context Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 05/13] bpf: Allow return values 0 and 1 for uprobe/kprobe session Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:18     ` Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 06/13] libbpf: Add support for uprobe multi session attach Jiri Olsa
2024-09-30 21:36   ` Andrii Nakryiko
2024-10-01 13:18     ` Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 07/13] selftests/bpf: Add uprobe session test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 08/13] selftests/bpf: Add uprobe session cookie test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 09/13] selftests/bpf: Add uprobe session recursive test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 10/13] selftests/bpf: Add uprobe session verifier test for return value Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 11/13] selftests/bpf: Add kprobe " Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 12/13] selftests/bpf: Add uprobe session single consumer test Jiri Olsa
2024-09-29 20:57 ` [PATCHv5 bpf-next 13/13] selftests/bpf: Add uprobe sessions to " Jiri Olsa

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=Zv1FdjGzPf4KhtzP@krava \
    --to=olsajiri@gmail.com \
    --cc=andrii.nakryiko@gmail.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=linux-kernel@vger.kernel.org \
    --cc=linux-trace-kernel@vger.kernel.org \
    --cc=mhiramat@kernel.org \
    --cc=oleg@redhat.com \
    --cc=peterz@infradead.org \
    --cc=rostedt@goodmis.org \
    --cc=sdf@fomichev.me \
    --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.