Re: [PATCH v2] tpm: Cleanup class for tpm_buf
From: Jarkko Sakkinen <jarkko@kernel.org>
Date: 2025-06-26 18:11:05
Also in:
keyrings, linux-integrity, lkml
From: Jarkko Sakkinen <jarkko@kernel.org>
Date: 2025-06-26 18:11:05
Also in:
keyrings, linux-integrity, lkml
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:quoted
From: Jarkko Sakkinen <redacted> 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.
Regards, James
BR, Jarkko