Re: [PATCHv2 bpf-next 1/9] uprobe: Add support for session consumer

From: Jiri Olsa
Date: Tue Jul 02 2024 - 12:11:19 EST


On Tue, Jul 02, 2024 at 03:04:08PM +0200, Peter Zijlstra wrote:
> On Mon, Jul 01, 2024 at 06:41:07PM +0200, Jiri Olsa wrote:
>
> > +static void
> > +uprobe_consumer_account(struct uprobe *uprobe, struct uprobe_consumer *uc)
> > +{
> > + static unsigned int session_id;
> > +
> > + if (uc->session) {
> > + uprobe->sessions_cnt++;
> > + uc->session_id = ++session_id ?: ++session_id;
> > + }
> > +}
>
> The way I understand this code, you create a consumer every time you do
> uprobe_register() and unregister makes it go away.
>
> Now, register one, then 4g-1 times register+unregister, then register
> again.
>
> The above seems to then result in two consumers with the same
> session_id, which leads to trouble.
>
> Hmm?

ugh true.. will make it u64 :)

I think we could store uprobe_consumer pointer+ref in session_consumer,
and that would make the unregister path more interesting.. will check

thanks,
jirka