From: "Serge E. Hallyn" <serge@hallyn.com>
To: Jarkko Sakkinen <jarkko@kernel.org>
Cc: David Howells <dhowells@redhat.com>,
keyrings@vger.kernel.org, Jann Horn <jannh@google.com>,
linux-kernel@vger.kernel.org,
linux-security-module@vger.kernel.org,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>
Subject: Re: [RFC PATCH 0/2] keys: Address lookup_user_key() mutability
Date: Thu, 8 Oct 2026 10:25:48 -0500 [thread overview]
Message-ID: <ase1/CnbnqL24SOQ@hallyn.com> (raw)
In-Reply-To: <aseoJvcBh0RZ31Uo@kernel.org>
On Thu, Oct 08, 2026 at 05:26:46PM +0300, Jarkko Sakkinen wrote:
> On Tue, Oct 06, 2026 at 01:52:28PM -0500, Serge Hallyn (AMD) wrote:
> > On Mon, Oct 05, 2026 at 09:46:41PM +0300, Jarkko Sakkinen wrote:
> > > On Mon, Oct 05, 2026 at 08:09:24AM -0500, Serge E. Hallyn wrote:
> > > > On Sun, Oct 04, 2026 at 08:54:06PM +0300, Jarkko Sakkinen wrote:
> > > > > On Thu, Sep 24, 2026 at 08:55:16AM +0300, Jarkko Sakkinen wrote:
> > > > > > The main objective in these patches is to remove to unneeded mutability
> > > > > > from key look ups. It does harm and brings no value so it is pretty obvious
> > > > > > to me that addressing this harmful behaviour is what we should do.
> > > > > >
> > > > > > I based the first patch on what Jann suggested in [1]. Nothing too clever here
> > > > > > and I'm ofc open for further suggestions.
> > > > > >
> > > > > > [1] https://lore.kernel.org/keyrings/CAG48ez0XjVSR=M--UBauTm8sJuc+ZbhKzaPa3a6wrSVHyoKevw@mail.gmail.com/
> > > > > >
> > > > > > Jarkko Sakkinen (2):
> > > > > > keys: Return user session keyring on lookup
> > > > > > keys: Reject keyring creation with overridden credentials
> > > > > >
> > > > > > Documentation/security/keys/core.rst | 7 ++-
> > > > > > security/keys/process_keys.c | 65 +++++++++++++++-------------
> > > > > > 2 files changed, 40 insertions(+), 32 deletions(-)
> > > > > >
> > > > > > --
> > > > > > 2.47.3
> > > > > >
> > > > >
> > > > > So.. should I move forward to with non-RFC v2?
> > > >
> > > > Patch 2 absolutely makes sense, "doc, it hurts when I do this", "don't do
> > > > that then."
> > > >
> > > > Regarding patch 1, that seems like quite a change in behavior, right? I
> > > > don't see any docs or comments that promise the current behavior, but
> > > > has any userspace or subsystem come to depend on it? I guess that, if so,
> > > > then it just has to create a link to the user session keyring like pam
> > > > (according to what I've read) does?
> > >
> > > Thanks a lot of responding.
> > >
> > > I fully agree with you but I'd need help for evaluating things further.
> > >
> > > 1/2 based on Jann's email about the topic and my interpretation of the
> > > suggestion. I neither used brains nor AI for this and consider the patch
> > > merely as a conversation starter (and what a great success it was on doing
> > > that) :-)
> >
> > :)
> >
> > > All feedback is good feedback at this point. I need supporting code to
> > > remember/recall later on so at least this serves that purpose.
> > >
> > > Br, Jarkko
> >
> > I've been staring at the before and after code for a bit now.
> > It does even more than I was thinking :) But I was trying to
> > detail the changed behavior (from userspace's pov), and after
> > several attempts, it seems maybe there actually isn't any.
> >
> > Q: is there any path whereby the
> >
> > ```
> > else if (test_bit(KEY_FLAG_UID_KEYRING,
> > &ctx.cred->session_keyring->flags) &&
> > lflags & KEY_LOOKUP_CREATE) {
> > ```
> >
> > case can still happen? Or was this the only place where we installed
> > the user_session keyring as session keyring, so that we can drop this
> > branch?
>
> Right, so *I think* that it is not useful and e.g., PAM uses NULL.
>
> At the same time it is harmless. We could remove it but it would be
> also uapi change (for granted, useless branch).
There's
https://sources.debian.org/src/e2fsprogs/1.47.4-1/misc/e4crypt.c?hl=568#L568
which bemoans that:
* The fact that the keyctl system call and the add_key system
* call treats KEY_SPEC_SESSION_KEYRING differently when a
* session keyring does not exist is very unfortunate and
* confusing, but so it goes...
Near as I can tell, add_key just always uses KEY_LOOKUP_CREATE?
And https://sources.debian.org/src/krb5/1.22.1-3/src/lib/krb5/ccache/cc_keyring.c?hl=307#L307
I'm not sure whether previous kernels did that, or whether the authors
mixed up testing with and without KEY_LOOKUP_CREATE.
> I could do it but not without any feedback from David.
>
> Br, Jarkko
next prev parent reply other threads:[~2026-10-08 15:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-24 5:55 [RFC PATCH 0/2] keys: Address lookup_user_key() mutability Jarkko Sakkinen
2026-09-24 5:55 ` [RFC PATCH 1/2] keys: Return user session keyring on lookup Jarkko Sakkinen
2026-09-24 6:01 ` sashiko-bot
2026-09-24 5:55 ` [RFC PATCH 2/2] keys: Reject keyring creation with overridden credentials Jarkko Sakkinen
2026-09-24 6:03 ` sashiko-bot
2026-10-04 17:54 ` [RFC PATCH 0/2] keys: Address lookup_user_key() mutability Jarkko Sakkinen
2026-10-05 13:09 ` Serge E. Hallyn
2026-10-05 18:46 ` Jarkko Sakkinen
2026-10-06 18:52 ` Serge Hallyn (AMD)
2026-10-08 14:26 ` Jarkko Sakkinen
2026-10-08 15:25 ` Serge E. Hallyn [this message]
2026-10-08 20:00 ` Jarkko Sakkinen
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=ase1/CnbnqL24SOQ@hallyn.com \
--to=serge@hallyn.com \
--cc=dhowells@redhat.com \
--cc=jannh@google.com \
--cc=jarkko@kernel.org \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.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