lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <CAEf4BzYc-YACW6XnHMVZLE+8_zJqkaJWBKE4iNeo3Jfj9RwaNQ@mail.gmail.com>
Date: Mon, 21 Oct 2024 10:04:43 -0700
From: Andrii Nakryiko <andrii.nakryiko@...il.com>
To: Peter Zijlstra <peterz@...radead.org>
Cc: Andrii Nakryiko <andrii@...nel.org>, linux-trace-kernel@...r.kernel.org, oleg@...hat.com, 
	rostedt@...dmis.org, mhiramat@...nel.org, mingo@...nel.org, 
	bpf@...r.kernel.org, linux-kernel@...r.kernel.org, jolsa@...nel.org, 
	paulmck@...nel.org
Subject: Re: [PATCH v2 tip/perf/core 1/2] uprobes: allow put_uprobe() from
 non-sleepable softirq context

On Mon, Oct 21, 2024 at 3:31 AM Peter Zijlstra <peterz@...radead.org> wrote:
>
> On Fri, Oct 18, 2024 at 11:22:00AM -0700, Andrii Nakryiko wrote:
> > On Fri, Oct 18, 2024 at 1:26 AM Peter Zijlstra <peterz@...radead.org> wrote:
> > >
> > > On Mon, Oct 07, 2024 at 05:25:55PM -0700, Andrii Nakryiko wrote:
> > > > Currently put_uprobe() might trigger mutex_lock()/mutex_unlock(), which
> > > > makes it unsuitable to be called from more restricted context like softirq.
> > >
> > > This is delayed_uprobe_lock, right?
> >
> > Not just delated_uprobe_lock, there is also uprobes_treelock (I forgot
> > to update the commit message to mention that). Oleg had concerns (see
> > [0]) with that being taken from the timer thread, so I just moved all
> > of the locking into deferred work callback.
> >
> >   [0] https://lore.kernel.org/linux-trace-kernel/20240915144910.GA27726@redhat.com/
>
> Right, but at least that's not a sleeping lock. He's right about it
> needing to become a softirq-safe lock though. And yeah, unfortunate
> that.
>
> > > So can't we do something like so instead?
> >
> > I'll need to look at this more thoroughly (and hopefully Oleg will get
> > a chance as well), dropping lock from delayed_ref_ctr_inc() is a bit
> > scary, but might be ok.
>
> So I figured that update_ref_ctr() is already doing the
> __update_ref_ctr() thing without holding the lock, so that lock really
> is only there to manage the list.
>
> And that list is super offensive... That really wants to be a per-mm
> rb-tree or somesuch.

Probably hard to justify to add that to mm_struct, tbh, given that
uprobe+refcnt case (which is USDT with semaphore) isn't all that
frequent, and even then it will be active on a very small subset of
processes in the system, most probably. But, even if (see below),
probably should be a separate change.

>
> AFAICT the only reason it is a mutex, is because doing unbouded list
> iteration under a spinlock is a really bad idea.
>
> > But generally speaking, what's your concern with doing deferred work
> > in put_uprobe()? It's not a hot path by any means, worst case we'll
> > have maybe thousands of uprobes attached/detached.
>
> Mostly I got offended by the level of crap in that code, and working
> around crap instead of fixing crap just ain't right.
>

Ok, so where are we at? Do you insist on the delayed_ref_ctr_inc()
rework, switching uprobe_treelock to be softirq-safe and leaving
put_uprobe() mostly as is? Or is it ok, to do a quick deferred work
change for put_uprobe()  to unblock uretprobe+SRCU and land it sooner?
What if we split this work into two independent patch sets, go with
deferred work for uretprobe + SRCU, and then work with Oleg and you on
simplifying and improving delayed_uprobe_lock-related stuff?

After all, neither deferred work nor delayed_ref_ctr_inc() change has
much practical bearing on real-world performance. WDYT?

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ