[PATCH] KEYS: Reduce smp_mb() calls in key_put()
David Howells
dhowells at redhat.com
Sat May 3 22:19:21 UTC 2025
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.
Possibly we only need smp_mb() in the IN_QUOTA branch in key_put().
David
More information about the Linux-security-module-archive
mailing list