Re: [PATCH perf/core 03/22] uprobes: Move ref_ctr_offset update out of uprobe_write_opcode

Jiri Olsa
2025-05-06T13:12:00Z

On Mon, Apr 28, 2025 at 12:51:57PM +0200, Jiri Olsa wrote:
> On Sun, Apr 27, 2025 at 04:13:35PM +0200, Oleg Nesterov wrote:

SNIP

> >
> > -------------------------------------------------------------------------------
> > OTOH, I think that the current logic is not really correct too,
> >
> > /* Revert back reference counter if instruction update failed. */
> > if (ret < 0 && is_register && ref_ctr_updated)
> > update_ref_ctr(uprobe, mm, -1);
> >
> > I think that "Revert back reference counter" logic should not depend on
> > is_register. Otherwise we can have the unbalanced update_ref_ctr(-1) if
> > uprobe_unregister() fails, then another uprobe_register() comes at the
> > same address, and after that uprobe_unregister() succeeds.
>
> sounds good to me

actualy after closer look, I don't see how this code could be triggered
in the first place.. any hint on how to hit such case? like:

- ref_ctr_offset is updated

- we fail somehow

- "if (ret < 0 && ref_ctr_updated)" is true on the way out

thanks,
jirka