linux-integrity.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: David Howells <dhowells@redhat.com>
Cc: keyrings@vger.kernel.org, Lukas Wunner <lukas@wunner.de>,
	Ignat Korchagin <ignat@cloudflare.com>,
	Herbert Xu <herbert@gondor.apana.org.au>,
	"David S. Miller" <davem@davemloft.net>,
	Peter Huewe <peterhuewe@gmx.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	James Bottomley <James.Bottomley@hansenpartnership.com>,
	Mimi Zohar <zohar@linux.ibm.com>,
	linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-integrity@vger.kernel.org,
	linux-security-module@vger.kernel.org
Subject: Re: [PATCH] KEYS: Reduce smp_mb() calls in key_put()
Date: Sun, 4 May 2025 19:42:09 +0300	[thread overview]
Message-ID: <aBeY4d3eC2aOthx-@kernel.org> (raw)
In-Reply-To: <1121543.1746310761@warthog.procyon.org.uk>

On Sat, May 03, 2025 at 11:19:21PM +0100, David Howells wrote:
> Jarkko Sakkinen <jarkko@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

      parent reply	other threads:[~2025-05-04 16:42 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-04-30 15:25 [PATCH] KEYS: Reduce smp_mb() calls in key_put() Jarkko Sakkinen
2025-05-03 14:39 ` Jarkko Sakkinen
2025-05-03 15:02   ` Herbert Xu
2025-05-04 16:55     ` Jarkko Sakkinen
2025-05-03 22:19 ` David Howells
2025-05-04  0:35   ` Herbert Xu
2025-05-04  5:36     ` [PATCH] KEYS: Invert FINAL_PUT bit Herbert Xu
2025-05-04  7:44     ` David Howells
2025-05-04  7:52       ` [v2 PATCH] " Herbert Xu
2025-05-09  9:34         ` kernel test robot
2025-05-09  9:45           ` [v3 " Herbert Xu
2025-05-12  9:19           ` David Howells
2025-05-12 11:42             ` Jarkko Sakkinen
2025-05-12 12:01             ` David Howells
2025-05-12 12:07               ` Herbert Xu
2025-05-04 16:42   ` Jarkko Sakkinen [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=aBeY4d3eC2aOthx-@kernel.org \
    --to=jarkko@kernel.org \
    --cc=James.Bottomley@hansenpartnership.com \
    --cc=davem@davemloft.net \
    --cc=dhowells@redhat.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=ignat@cloudflare.com \
    --cc=jgg@ziepe.ca \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-crypto@vger.kernel.org \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=paul@paul-moore.com \
    --cc=peterhuewe@gmx.de \
    --cc=serge@hallyn.com \
    --cc=zohar@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).