[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YRGVcaquAJiuc8bp@gmail.com>
Date: Mon, 9 Aug 2021 13:52:01 -0700
From: Eric Biggers <ebiggers@...nel.org>
To: Jarkko Sakkinen <jarkko@...nel.org>
Cc: Ahmad Fatoum <a.fatoum@...gutronix.de>,
"Theodore Y. Ts'o" <tytso@....edu>,
Jaegeuk Kim <jaegeuk@...nel.org>, kernel@...gutronix.de,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
James Bottomley <jejb@...ux.ibm.com>,
Mimi Zohar <zohar@...ux.ibm.com>,
Sumit Garg <sumit.garg@...aro.org>,
David Howells <dhowells@...hat.com>,
linux-fscrypt@...r.kernel.org, linux-crypto@...r.kernel.org,
linux-integrity@...r.kernel.org,
linux-security-module@...r.kernel.org, keyrings@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: Re: [PATCH v2] fscrypt: support trusted keys
On Mon, Aug 09, 2021 at 12:44:08PM +0300, Jarkko Sakkinen wrote:
> > @@ -577,28 +578,44 @@ static int get_keyring_key(u32 key_id, u32 type,
> > key_ref_t ref;
> > struct key *key;
> > const struct fscrypt_provisioning_key_payload *payload;
> > - int err;
> > + int err = 0;
> >
> > ref = lookup_user_key(key_id, 0, KEY_NEED_SEARCH);
> > if (IS_ERR(ref))
> > return PTR_ERR(ref);
> > key = key_ref_to_ptr(ref);
> >
> > - if (key->type != &key_type_fscrypt_provisioning)
> > - goto bad_key;
> > - payload = key->payload.data[0];
> > + if (key->type == &key_type_fscrypt_provisioning) {
>
> Why does fscrypt have own key type, and does not extend 'encrypted' with a
> new format [*]?
Are you referring to the "fscrypt-provisioning" key type? That is an existing
feature (which in most cases isn't used, but there is a use case that requires
it), not something being added by this patch. We just needed a key type where
userspace can add a raw key to the kernel and not be able to read it back (so
like the "logon" key type), but also have the kernel enforce that that key is
only used for fscrypt with a particular KDF version, and not with other random
kernel features. The "encrypted" key type wouldn't have worked for this at all;
it's a totally different thing.
> > + } else if (IS_REACHABLE(CONFIG_TRUSTED_KEYS) && key->type == &key_type_trusted) {
> > + struct trusted_key_payload *tkp;
> > +
> > + /* avoid reseal changing payload while we memcpy key */
> > + down_read(&key->sem);
> > + tkp = key->payload.data[0];
> > + if (!tkp || tkp->key_len < FSCRYPT_MIN_KEY_SIZE ||
> > + tkp->key_len > FSCRYPT_MAX_KEY_SIZE) {
> > + up_read(&key->sem);
> > + err = -EINVAL;
> > + goto out_put;
> > + }
> > +
> > + secret->size = tkp->key_len;
> > + memcpy(secret->raw, tkp->key, secret->size);
> > + up_read(&key->sem);
> > + } else {
>
>
> I don't think this is right, or at least it does not follow the pattern
> in [*]. I.e. you should rather use trusted key to seal your fscrypt key.
What's the benefit of the extra layer of indirection over just using a "trusted"
key directly? The use case for "encrypted" keys is not at all clear to me.
- Eric
Powered by blists - more mailing lists