[PATCH] KEYS: Reduce smp_mb() calls in key_put()
Jarkko Sakkinen
jarkko at kernel.org
Sun May 4 16:42:09 UTC 2025
On Sat, May 03, 2025 at 11:19:21PM +0100, David Howells wrote:
> Jarkko Sakkinen <jarkko at kernel.org> wrote:
>
> > Oops, my bad (order swap), sorry. Should have been:
> >
> > spin_unlock_irqrestore(&key->user->lock, flags);
> > } else {
> > smp_mb(); /* key->user before FINAL_PUT set. */
> > }
> > set_bit(KEY_FLAG_FINAL_PUT, &key->flags);
> >
> > Should spin_lock()/unlock() be good enough or what good does smp_mb() do
> > in that branch? Just checking if I'm missing something before sending
> > fixed version.
>
> spin_unlock() is semi-permeable, so stuff after it can leak into the inside of
> it up as far as the spin_lock(). With your change, the garbage collector can
> no longer guarantee that key_put() will have done with accessing key->user
> when it sees KEY_FLAG_FINAL_PUT is set.
>
> So, NAK on this patch, I think. If you want a second opinion, I'd suggest
> waving it in front of Paul McKenney.
Fair enough.
If I revisit this in a way or another, I'll cc to him for comments but
for this I'll buy what you said.
>
> Possibly we only need smp_mb() in the IN_QUOTA branch in key_put().
>
> David
Thank you for the comments.
BR, Jarkko
More information about the Linux-security-module-archive
mailing list