Thank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [Low] KEYS: trusted: changelog omits payload->private and tpm2_load_cmd() check --
commit 94f02a37d277c89d23fb05c1b5c6ea51d598832f Author: Jarkko Sakkinen <[email protected]> > KEYS: trusted: Factor out TPM2 blob loading > > Factor out TPM2 blob loading: > > 1. tpm2_key_decode() from trusted_key_options. > 2. tpm2_load_blob() and tpm2_buf_append_key_auth() from tpm2_load_cmd() > and tpm2_unseal_cmd(). > > Signed-off-by: Jarkko Sakkinen <[email protected]> > diff --git a/include/keys/trusted-type.h b/include/keys/trusted-type.h > index 3db61b57cf73d..790ffabb0d184 100644 > --- a/include/keys/trusted-type.h > +++ b/include/keys/trusted-type.h > @@ -33,6 +33,7 @@ struct trusted_key_payload { > unsigned int blob_len; > unsigned char migratable; > unsigned char old_format; > + void *private; > unsigned char key[MAX_KEY_SIZE + 1]; > unsigned char blob[MAX_BLOB_SIZE]; > }; > diff --git a/security/keys/trusted-keys/trusted_core.c > b/security/keys/trusted-keys/trusted_core.c > index 3721980ed83af..b8f980da606d1 100644 > --- a/security/keys/trusted-keys/trusted_core.c > +++ b/security/keys/trusted-keys/trusted_core.c > @@ -149,6 +149,14 @@ static struct trusted_key_payload > *trusted_payload_alloc(struct key *key) > return p; > } > > +static void trusted_payload_free(struct trusted_key_payload *p) > +{ > + if (!p) > + return; > + kfree_sensitive(p->private); > + kfree_sensitive(p); > +} > + [ ... ] > diff --git a/security/keys/trusted-keys/trusted_tpm2.c > b/security/keys/trusted-keys/trusted_tpm2.c > index 0a81608844ff6..231062fd17b6b 100644 > --- a/security/keys/trusted-keys/trusted_tpm2.c > +++ b/security/keys/trusted-keys/trusted_tpm2.c [ ... ] > @@ -527,6 +595,9 @@ static int tpm2_load_cmd(struct tpm_chip *chip, > if (private_len + 2 + public_len + 2 > blob_len) > return -E2BIG; > > + if (public_len < 8) > + return -EINVAL; > + > pub = blob + 2 + private_len + 2; > /* key attributes are always at offset 4 */ > attrs = get_unaligned_be32(pub + 4); [Severity: Low] This isn't a bug, but the commit message only mentions factoring out tpm2_key_decode(), tpm2_load_blob(), and tpm2_buf_append_key_auth(), without explaining why this refactoring is needed (to prepare for asymmetric key support in the following patch). It also omits adding payload->private and trusted_payload_free() in the core trusted keys code, as well as the new public_len < 8 bounds check before reading pub + 4 in tpm2_load_cmd(). -- Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=8
