mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jarkko Sakkinen <jarkko@kernel.org>
To: Karl Mehltretter <kmehltretter@gmail.com>
Cc: David Howells <dhowells@redhat.com>,
	Paul Moore <paul@paul-moore.com>,
	James Morris <jmorris@namei.org>,
	"Serge E. Hallyn" <serge@hallyn.com>,
	keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] keys: finalize persistent keyring timeout after link attempt
Date: Thu, 10 Sep 2026 00:17:52 +0300	[thread overview]
Message-ID: <aqHNAKKsc8yD_pgm@kernel.org> (raw)
In-Reply-To: <aphkt2PpqUFcTvun@gmail.com>

On Wed, Sep 02, 2026 at 08:04:30PM +0200, Karl Mehltretter wrote:
> On Wed, Sep 02, 2026 at 02:00:56AM +0100, Jarkko Sakkinen wrote:
> > > +		*persistent_ref = find_key_to_update(reg_ref, index_key);
> > > +		if (*persistent_ref)
> > > +			return 1;
> > 
> > I'd return -ENOENT here instead and not make return value tristate.
> > 
> 
> I don't think using an error to mean "found" is safe. keyring_alloc()
> can return -ENOENT through security_key_alloc(). A BPF LSM key_alloc
> hook can return any errno.
> 
> I checked this in QEMU with a BPF LSM hook returning -ENOENT.
> keyring_alloc(".persistent_register") returned -ENOENT and
> KEYCTL_GET_PERSISTENT failed with ENOENT.
> 
> So -ENOENT would be ambiguous. I also considered +EEXIST instead of 1,
> but that seems a bit too clever. I'd rather keep 0/1/<0.

Fair enough.

Let's tweak documentation then:

 * Return 0 if a keyring was created, 1 if an existing keyring was found, or a
 * negative error.  On a nonnegative return, persistent_ref holds a reference
 * to the keyring.

How about being here a bit less convoluted and replace the text with:

 * Returns a boolean value on success case, which tell whether a new
 * keyring was created or not.

This is imho quite well in the ballpark with detail/clarity.


> 
> Thanks,
> Karl

BR, Jarkko

      reply	other threads:[~2026-09-09 21:17 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 19:17 Karl Mehltretter
2026-09-01 23:00 ` Jarkko Sakkinen
2026-09-02 18:04   ` Karl Mehltretter
2026-09-09 21:17     ` 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=aqHNAKKsc8yD_pgm@kernel.org \
    --to=jarkko@kernel.org \
    --cc=dhowells@redhat.com \
    --cc=jmorris@namei.org \
    --cc=keyrings@vger.kernel.org \
    --cc=kmehltretter@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-security-module@vger.kernel.org \
    --cc=paul@paul-moore.com \
    --cc=serge@hallyn.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

all inboxes | Powered by JetHome®