From: Jarkko Sakkinen <jarkko@kernel.org>
To: Stefano Garzarella <sgarzare@redhat.com>
Cc: linux-integrity@vger.kernel.org, stable@vger.kernel.org,
co+6a581c4284f721d4@bugs.sh,
James Bottomley <James.Bottomley@hansenpartnership.com>,
Mimi Zohar <zohar@linux.ibm.com>,
David Howells <dhowells@redhat.com>,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
Jonathan McDowell <noodles@meta.com>,
Ross Philipson <ross.philipson@gmail.com>,
Stefan Berger <stefanb@linux.ibm.com>,
Srish Srinivasan <ssrish@linux.ibm.com>,
keyrings@vger.kernel.org, linux-security-module@vger.kernel.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] KEYS: trusted: Fix tpm2_load_cmd() boundary check
Date: Fri, 18 Sep 2026 04:43:06 +0300 [thread overview]
Message-ID: <aqyXKrC4hhFP1mEd@kernel.org> (raw)
In-Reply-To: <aqJhkjPdib-MQTCT@sgarzare-redhat>
On Thu, Sep 10, 2026 at 09:52:38AM +0200, Stefano Garzarella wrote:
> On Wed, Sep 09, 2026 at 11:59:46PM +0300, Jarkko Sakkinen wrote:
> > On Wed, Sep 02, 2026 at 11:24:16AM +0200, Stefano Garzarella wrote:
> > > On Tue, Sep 01, 2026 at 11:58:06PM +0300, Jarkko Sakkinen wrote:
> > > > tpm2_load_cmd() does boundary checks against the ASN.1 size i.e.,
> > > > payload->blob_len. Address this by passing the decoded blob size to
> > > > tpm2_load_cmd(), and use it for the boundary checks.
> > > >
> > > > Cc: stable@vger.kernel.org # v5.13+
> > > > Fixes: f2219745250f ("security: keys: trusted: use ASN.1 TPM2 key format for the blobs")
> > > > Reported-by: co+6a581c4284f721d4@bugs.sh
> > > > Closes: https://bugs.sh/b/6a581c4284f721d4/
> > > > Signed-off-by: Jarkko Sakkinen <jarkko@kernel.org>
> > > > ---
> > > > security/keys/trusted-keys/trusted_tpm2.c | 12 +++++++-----
> > > > 1 file changed, 7 insertions(+), 5 deletions(-)
> > > >
> > > > diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
> > > > index 67225dd562a9..01f18bb37047 100644
> > > > --- a/security/keys/trusted-keys/trusted_tpm2.c
> > > > +++ b/security/keys/trusted-keys/trusted_tpm2.c
> > > > @@ -99,7 +99,7 @@ struct tpm2_key_context {
> > > >
> > > > static int tpm2_key_decode(struct trusted_key_payload *payload,
> > > > struct trusted_key_options *options,
> > > > - u8 **buf)
> > > > + u8 **buf, unsigned int *blob_len)
> > > > {
> > > > int ret;
> > > > struct tpm2_key_context ctx;
> > > > @@ -120,6 +120,7 @@ static int tpm2_key_decode(struct trusted_key_payload *payload,
> > >
> > > blob = kmalloc(ctx.priv_len + ctx.pub_len + 4, GFP_KERNEL);
> > >
> > > Pre-existing, but is `+ 4` here useless?
> >
> > I checked this through in detail.
> >
> > It should not be like that given that callbacks tpm2_key_{pub,priv}
> > provide the length of TPM2B_PUBLIC and TPM2B_PRIVATE.
> >
> > Thus, it is a bug introduced by f2219745250f ("security: keys: trusted:
> > use ASN.1 TPM2 key format for the blobs")
>
> Yep, agree. Do you want me to send a fix?
Sure, go ahead.
> Thanks,
> Stefano
BR, Jarkko
next prev parent reply other threads:[~2026-09-18 1:43 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-01 20:58 [PATCH] KEYS: trusted: Fix tpm2_load_cmd() boundary check Jarkko Sakkinen
2026-09-02 9:24 ` Stefano Garzarella
2026-09-09 20:59 ` Jarkko Sakkinen
2026-09-10 7:52 ` Stefano Garzarella
2026-09-18 1:43 ` Jarkko Sakkinen [this message]
2026-09-03 9:31 ` Srish Srinivasan
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=aqyXKrC4hhFP1mEd@kernel.org \
--to=jarkko@kernel.org \
--cc=James.Bottomley@hansenpartnership.com \
--cc=co+6a581c4284f721d4@bugs.sh \
--cc=dhowells@redhat.com \
--cc=jmorris@namei.org \
--cc=keyrings@vger.kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=noodles@meta.com \
--cc=paul@paul-moore.com \
--cc=ross.philipson@gmail.com \
--cc=serge@hallyn.com \
--cc=sgarzare@redhat.com \
--cc=ssrish@linux.ibm.com \
--cc=stable@vger.kernel.org \
--cc=stefanb@linux.ibm.com \
--cc=zohar@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.