From: Mimi Zohar <zohar@linux.ibm.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>,
Sughosh Ganu <sughosh.ganu@linaro.org>
Cc: linux-integrity@vger.kernel.org
Subject: Re: Question on loading trusted key with keyctl command
Date: Tue, 20 Dec 2022 10:40:48 -0500 [thread overview]
Message-ID: <3690af5fa39078b8e542940cf5db50c0b6663aa3.camel@linux.ibm.com> (raw)
In-Reply-To: <89ed5619ff41ea8a3651e3388ff7309b13646896.camel@HansenPartnership.com>
On Tue, 2022-12-20 at 09:23 -0500, James Bottomley wrote:
> On Tue, 2022-12-20 at 09:13 -0500, Mimi Zohar wrote:
> > On Tue, 2022-12-20 at 09:03 -0500, James Bottomley wrote:
> > > On Tue, 2022-12-20 at 08:54 -0500, Mimi Zohar wrote:
> > > > On Tue, 2022-12-20 at 07:50 -0500, James Bottomley wrote:
> > > > > On Tue, 2022-12-20 at 12:03 +0530, Sughosh Ganu wrote:
> > > [...]
> > > > > > I was able to load the key after clearing the keyring. Thanks
> > > > > > James and Mimi for your pointers.
> > > > >
> > > > > Actually, I think this is a bug in trusted keys. Add on
> > > > > existing key is supposed to go through the update path. If the
> > > > > path doesn't exist it returns -EEXIST. Trusted keys have an
> > > > > update path but they return - EINVAL if the trusted key command
> > > > > is anything but update (which is used to reseal a key).
> > > > > Obviously this is incorrect and the code should be returning -
> > > > > EEXIST for a key we refuse to update to match every other key
> > > > > type.
> > > >
> > > > Re-loading an existing key was previously permitted. Obviously
> > > > this changed at some point. Any "fixes" should point out when
> > > > it changed.
> > >
> > > Git history doesn't think so. It thinks when you added trusted
> > > keys with d00a1c72f7f4661212299e6cb132dfa58030bcdb the update path
> > > already had the -EINVAL return, so reload has always failed this
> > > way unless we were doing a reseal update. We could certainly
> > > permit overwriting an existing key with load, but that would be a
> > > more extensive change.
> >
> > Replacing existing keys/keyrings was part of the infrastructure. I
> > don't think this change has anything to do with trusted type keys.
> > The ability of replacing keys/keyrings was one of the main reasons
> > for trusted keyrings (dot prefixed keyrings).
>
> Keys can only be replaced by calling the ->update() helper for the key
> type. If that doesn't exist keyctl add will return -EEXIST (behaviour
> for at least the last 12 years). Most key type update routines do
> unconditionally update, so the error they return is the same error they
> would have returned for an add of a non existent key (EINVAL if the
> payload is too large, for instance). The trusted keys ->update()
> helper (trusted_update()) only allows update if the trusted operation
> is update, so they've always failed a load with EINVAL going back to
> the original commit I quoted. At no time that I can find has there
> ever been a modification to this supporting updating trusted keys with
> anything other than an update trusted operation. So they've supported
> changing the sealing parameters (PCR values) but not changing the
> payload. This contrasts with user keys where add of a new payload on
> an existing key changes the payload.
Yes, my mistake. With your change, it's now returning "add_key: File
exists".
Reviewed-by: Mimi Zohar <zohar@linux.ibm.com>
--
thanks,
Mimi
prev parent reply other threads:[~2022-12-20 15:41 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-19 10:20 Question on loading trusted key with keyctl command Sughosh Ganu
2022-12-19 11:43 ` Mimi Zohar
2022-12-19 12:50 ` James Bottomley
2022-12-20 6:33 ` Sughosh Ganu
2022-12-20 12:50 ` James Bottomley
2022-12-20 13:54 ` Mimi Zohar
2022-12-20 14:03 ` James Bottomley
2022-12-20 14:13 ` Mimi Zohar
2022-12-20 14:23 ` James Bottomley
2022-12-20 15:40 ` Mimi Zohar [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=3690af5fa39078b8e542940cf5db50c0b6663aa3.camel@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=linux-integrity@vger.kernel.org \
--cc=sughosh.ganu@linaro.org \
/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