Re: [RFC bpf-next 01/10] uprobe: Add session callbacks to uprobe_consumer

From: Oleg Nesterov
Date: Wed Jun 05 2024 - 12:03:10 EST


On 06/05, Oleg Nesterov wrote:
>
> > +/*
> > + * Make sure all the uprobe consumers have only one type of entry
> > + * callback registered (either handler or handler_session) due to
> > + * different return value actions.
> > + */
> > +static int consumer_check(struct uprobe_consumer *curr, struct uprobe_consumer *uc)
> > +{
> > + if (!curr)
> > + return 0;
> > + if (curr->handler_session || uc->handler_session)
> > + return -EBUSY;
> > + return 0;
> > +}
>
> Hmm, I don't understand this code, it doesn't match the comment...
>
> The comment says "all the uprobe consumers have only one type" but
> consumer_check() will always fail if the the 1st or 2nd consumer has
> ->handler_session != NULL ?
>
> Perhaps you meant
>
> if (!!curr->handler != !!uc->handler)
> return -EBUSY;
>
> ?

OK, the changelog says

Which means that there can be only single user of a uprobe (inode +
offset) when session consumer is registered to it.

so the code is correct. But I still think the comment is misleading.

Oleg.