Linux Modules
 help / color / mirror / Atom feed
From: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
To: "Paul E. McKenney" <paulmck@kernel.org>
Cc: Petr Pavlu <petr.pavlu@suse.com>,
	Luis Chamberlain <mcgrof@kernel.org>,
	Daniel Gomez <da.gomez@kernel.org>,
	Sami Tolvanen <samitolvanen@google.com>,
	Aaron Tomlin <atomlin@atomlin.com>,
	linux-modules@vger.kernel.org
Subject: Re: [PATCH net v2] ppp: defer channel free to an RCU grace period to fix pppol2tp RX UAF
Date: Wed, 15 Jul 2026 10:25:18 +0200	[thread overview]
Message-ID: <20260715082518.3z_iDNrR@linutronix.de> (raw)
In-Reply-To: <b7b5a7f1-7d09-4181-9257-ea9272325ef2@paulmck-laptop>

On 2026-07-14 10:47:58 [-0700], Paul E. McKenney wrote:
> On Tue, Jul 14, 2026 at 06:01:04PM +0200, Sebastian Andrzej Siewior wrote:
> > On 2026-07-08 12:22:58 [-0700], Paul E. McKenney wrote:
> > > The RCU-callback ordering guarantees are quite weak:
> > …
> > So this is not working.
> > 
> > > What you maybe *could* do is to have the two RCU callbacks communicate,
> > > so that the last one to be invoked did the work of both of them.  For
> > > example, use a shared variable initialized to 2, then have each callback
> > > do atomic_dec_and_test(), with the "winner" doing the work.
> > > 
> > > Would that do the trick?
> > 
> > This would work but we would have to fix each one or make it slower for
> > everyone in the common case. So I think adding a rcu_barrier() to module
> > unload wouldn't be that bad and Petr did not say "get out" so ;)
> 
> I am not opposed to rcu_barrier() in module unload.
> 
> But just to fill out the other similar situations...
> 
> In addition to call_rcu(), there is call_srcu(), call_rcu_tasks(),
> and call_rcu_tasks_rude().  I think that we can rule out call_srcu()
> as ridiculous because there could have been an arbitrarily large number
> of srcu_struct structures passed to call_srcu() along with callback
> functions defined within this module.  For their parts, call_rcu_tasks()
> and call_rcu_tasks_rude() are special-purpose functions that are rarely
> used and could therefore be ignored.

Regarding srcu, module unload should have cleanup_srcu_struct() which
would flush pending item, no?

> But what about things like timers and hrtimers?  Or are people already
> doing the right thing for such things?

Right. What people often did wrong with timers is that they enqueued a
timer then forgot about it and released the memory with the timer
active. Then someone who got all the timer bugs assigned came up with
debugobjects.

This checks only that the memory is not released while the object is
active. It does not verify the callback.

I think it depends on what we want to achieve. We could iterate over all
RCU callbacks checking if it belongs to the memory that we intend to
free. The same could be done for timers, too. They should be caught by
debugbjects unless they leak the memory…

The rcu_barrier() before module_exit() would ensure the callbacks are
done before a possible kmem_cache_free() where the cache is removed in
the exit function. Now I see that for !SLUB_TINY there is a barrier if
the cache has sheaves (kmem_cache_destroy() ->
kvfree_rcu_barrier_on_cache()). Buh…

> 							Thanx, Paul

Sebastian

      reply	other threads:[~2026-07-15  8:25 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <D9C0245B-608B-4884-8A09-F55BA4A9F948@doyensec.com>
     [not found] ` <de2616b3-6edf-4255-ba77-0674e225ab27@linux.dev>
     [not found]   ` <akfjpBVML_1RFF91@gmail.com>
     [not found]     ` <87111f02-5b7a-4185-8364-2faba650578b@linux.dev>
2026-07-06  9:29       ` [PATCH net v2] ppp: defer channel free to an RCU grace period to fix pppol2tp RX UAF Sebastian Andrzej Siewior
2026-07-07 15:32         ` Petr Pavlu
2026-07-07 16:39           ` Paul E. McKenney
2026-07-08  9:11             ` Sebastian Andrzej Siewior
2026-07-08 14:01               ` Paul E. McKenney
2026-07-08  7:49           ` Sebastian Andrzej Siewior
2026-07-08 13:04             ` Petr Pavlu
2026-07-08 13:56               ` Sebastian Andrzej Siewior
2026-07-08 19:00                 ` Sebastian Andrzej Siewior
2026-07-08 19:22                   ` Paul E. McKenney
2026-07-14 16:01                     ` Sebastian Andrzej Siewior
2026-07-14 17:47                       ` Paul E. McKenney
2026-07-15  8:25                         ` Sebastian Andrzej Siewior [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260715082518.3z_iDNrR@linutronix.de \
    --to=bigeasy@linutronix.de \
    --cc=atomlin@atomlin.com \
    --cc=da.gomez@kernel.org \
    --cc=linux-modules@vger.kernel.org \
    --cc=mcgrof@kernel.org \
    --cc=paulmck@kernel.org \
    --cc=petr.pavlu@suse.com \
    --cc=samitolvanen@google.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox