From: sashiko-bot@kernel.org
Cc: linux-security-module@vger.kernel.org
Subject: Re: [PATCH v3] keys/trusted/tpm2: Validate TPM2_Create object sizes separately
Date: Sat, 26 Sep 2026 18:51:30 +0000 [thread overview]
Message-ID: <20260926185130.887231F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260926184203.479203-1-ssrish@linux.ibm.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] cleanup: mixing goto-based error handling with scope-based cleanup
--
commit 6bc711f0f487069cc2bd8437493ff78b9ed1f263
Author: Srish Srinivasan <ssrish@linux.ibm.com>
keys/trusted/tpm2: Validate TPM2_Create object sizes separately
This commit updates trusted key creation to validate TPM2_Create object
sizes separately from the complete response area. It also adopts scope-based
cleanup to simplify resource management.
> diff --git a/security/keys/trusted-keys/trusted_tpm2.c b/security/keys/trusted-keys/trusted_tpm2.c
> index c2a69bcf381d7..eae9d81fed0ff 100644
> --- a/security/keys/trusted-keys/trusted_tpm2.c
> +++ b/security/keys/trusted-keys/trusted_tpm2.c
[ ... ]
> @@ -340,10 +345,11 @@ int tpm2_seal_trusted(struct tpm_chip *chip,
> goto out;
>
> blob_len = tpm_buf_read_u32(buf, &offset);
> - if (blob_len > MAX_BLOB_SIZE || buf->flags & TPM_BUF_INVALID) {
> + if (buf->flags & TPM_BUF_INVALID) {
> rc = -E2BIG;
> goto out;
> }
> +
> if (buf->length - offset < blob_len) {
> rc = -EFAULT;
> goto out;
[Severity: Low]
Does this function mix goto-based error handling with scope-based cleanup?
Looking at tpm2_seal_trusted() in security/keys/trusted-keys/trusted_tpm2.c,
it defines resources using scope-based cleanup:
struct tpm_buf *buf __free(kfree) = NULL;
struct tpm_buf *sized __free(kfree) = NULL;
But the function still uses goto labels for TPM operations cleanup:
out:
if (!rc)
payload->blob_len = blob_len;
out_put:
tpm_put_ops(chip);
return tpm_ret_to_err(rc);
The cleanup subsystem guidelines expect that usage of goto and cleanup
helpers are never mixed in the same function.
Could the remaining goto labels in tpm2_seal_trusted() be converted to
scope-based cleanup to avoid mixing paradigms?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260926184203.479203-1-ssrish@linux.ibm.com?part=1
next prev parent reply other threads:[~2026-09-26 18:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 18:42 [PATCH v3] keys/trusted/tpm2: Validate TPM2_Create object sizes separately Srish Srinivasan
2026-09-26 18:51 ` sashiko-bot [this message]
2026-09-29 21:15 ` Jarkko Sakkinen
2026-09-30 5:52 ` Srish Srinivasan
2026-10-02 3:24 ` 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=20260926185130.887231F000FF@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.