[PATCH v2] tpm: Cleanup class for tpm_buf
Jarkko Sakkinen
jarkko at kernel.org
Thu Jun 26 22:35:57 UTC 2025
On Thu, Jun 26, 2025 at 09:11:05PM +0300, Jarkko Sakkinen wrote:
> On Thu, Jun 26, 2025 at 10:50:22AM -0400, James Bottomley wrote:
> > On Thu, 2025-06-26 at 13:19 +0300, Jarkko Sakkinen wrote:
> > > From: Jarkko Sakkinen <jarkko.sakkinen at opinsys.com>
> > >
> > > Create a cleanup class for struct tpm_buf using DEFINE_CLASS(), which
> > > will guarantee that the heap allocated memory will be freed
> > > automatically for the transient instances of this structure, when
> > > they go out of scope.
> > >
> > > Wrap this all into help macro CLASS_TPM_BUF().
> > >
> > > A TPM buffer can now be declared trivially:
> > >
> > > CLASS_TPM_BUF(buf, buf_size);
> >
> > Well, that's not all ... you're also adding a size to the API that we
> > didn't have before, which should at least be documented in the commit
> > message and probably be a separate patch.
> >
> > What is the reason for this, though? The reason we currently use a
> > page is that it's easy for the OS to manage (no slab fragmentation
> > issues). The TCG reference platform defines this to be just under 4k
> > (actually 4096-0x80) precisely because TPM implementations don't do
> > scatter gather, so they don't want it going over an ARM page, so
> > there's no danger of us ever needing more than a page.
>
> Thanks for the valuable feedback.
>
> I can drop "buf_size" parameter. It is not a priority, and I also
> agree with your comments.
I also noticed that I had changed one log message in tpm2-sessions.c. It
was unintended i.e. a spurious change. I'll revert that one too.
I'll split this into more reasonable portions for next version so these
should be easier to review then.
BR, Jarkko
More information about the Linux-security-module-archive
mailing list