[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aCH5r9yuyKT1yKMS@redhat.com>
Date: Mon, 12 May 2025 15:37:51 +0200
From: Oleg Nesterov <oleg@...hat.com>
To: Jiri Olsa <olsajiri@...il.com>
Cc: Peter Zijlstra <peterz@...radead.org>,
Andrii Nakryiko <andrii@...nel.org>, bpf@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-trace-kernel@...r.kernel.org,
x86@...nel.org, Song Liu <songliubraving@...com>,
Yonghong Song <yhs@...com>,
John Fastabend <john.fastabend@...il.com>,
Hao Luo <haoluo@...gle.com>, Steven Rostedt <rostedt@...dmis.org>,
Masami Hiramatsu <mhiramat@...nel.org>,
Alan Maguire <alan.maguire@...cle.com>,
David Laight <David.Laight@...lab.com>,
Thomas Weißschuh <thomas@...ch.de>,
Ingo Molnar <mingo@...nel.org>
Subject: Re: [PATCH perf/core 03/22] uprobes: Move ref_ctr_offset update out
of uprobe_write_opcode
I am still traveling, will actually read your email when I get back...
On 05/09, Jiri Olsa wrote:
>
> On Tue, May 06, 2025 at 04:01:45PM +0200, Oleg Nesterov wrote:
> >
> > - uprobe_unregister() is called again and this time it succeeds. In this case
> > ref_ctr is changed from 0 to -1. IIRC, we even have some warning for this
> > case.
>
> AFAICS that should not happen, there's check below in __update_ref_ctr:
>
> if (unlikely(*ptr + d < 0)) {
> pr_warn("ref_ctr going negative. vaddr: 0x%lx, "
> "curr val: %d, delta: %d\n", vaddr, *ptr, d);
> ret = -EINVAL;
> goto out;
> }
OK,
> few things first..
>
> - how do you make uprobe_unregister fail after succesful uprobe_register?
> I had to instrument the code to do that for me
I guess _unregister() should not fail "in practice" after
get_user_page + verify_opcode, yet I think we should not rely on this, if possible.
But I won't argue if you think we can ignore this "impossible" failures, just
this should be documented. Same for update_ref_ctr(), iirc it should "never"
fail if ref_offset is correct.
> --- a/kernel/events/uprobes.c
> +++ b/kernel/events/uprobes.c
> @@ -589,8 +589,8 @@ int uprobe_write_opcode(struct arch_uprobe *auprobe, struct vm_area_struct *vma,
>
> out:
> /* Revert back reference counter if instruction update failed. */
> - if (ret < 0 && is_register && ref_ctr_updated)
> - update_ref_ctr(uprobe, mm, -1);
> + if (ret < 0 && ref_ctr_updated)
> + update_ref_ctr(uprobe, mm, is_register ? -1 : 1);
Yes, this is what I meant.
Oleg.
Powered by blists - more mailing lists