[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1a06e28dbac24d32168a7362a903d6076fafdc34.camel@kernel.org>
Date: Mon, 06 Nov 2023 05:25:15 +0200
From: Jarkko Sakkinen <jarkko@...nel.org>
To: James Bottomley <James.Bottomley@...senPartnership.com>,
linux-integrity@...r.kernel.org
Cc: keyrings@...r.kernel.org,
William Roberts <bill.c.roberts@...il.com>,
Stefan Berger <stefanb@...ux.ibm.com>,
David Howells <dhowells@...hat.com>,
Jason Gunthorpe <jgg@...pe.ca>,
Mimi Zohar <zohar@...ux.ibm.com>,
Peter Huewe <peterhuewe@....de>,
Paul Moore <paul@...l-moore.com>,
James Morris <jmorris@...ei.org>,
"Serge E. Hallyn" <serge@...lyn.com>,
Jerry Snitselaar <jsnitsel@...hat.com>,
Mario Limonciello <mario.limonciello@....com>,
Julien Gomes <julien@...sta.com>,
open list <linux-kernel@...r.kernel.org>,
"open list:SECURITY SUBSYSTEM"
<linux-security-module@...r.kernel.org>
Subject: Re: [PATCH v3 4/6] tpm: Support TPM2 sized buffers (TPM2B)
On Fri, 2023-10-27 at 08:32 -0400, James Bottomley wrote:
> On Tue, 2023-10-24 at 04:15 +0300, Jarkko Sakkinen wrote:
> > +++ b/drivers/char/tpm/tpm-buf.c
> > @@ -7,22 +7,32 @@
> > #include <linux/tpm.h>
> >
> > /**
> > - * tpm_buf_init() - Initialize from the heap
> > + * tpm_buf_init() - Initialize a TPM buffer
> > * @buf: A @tpm_buf
> > + * @sized: Represent a sized buffer (TPM2B)
> > + * @alloc: Allocate from the heap
> > *
> > * Initialize all structure fields to zero, allocate a page from the
> > heap, and
> > * zero the bytes that the buffer headers will consume.
> > *
> > * Return: 0 or -ENOMEM
> > */
> > -int tpm_buf_init(struct tpm_buf *buf)
> > +int tpm_buf_init(struct tpm_buf *buf, bool alloc, bool sized)
>
> I think it creates a phenomenally confusing interface to use multiple
> booleans because, unlike flags, it's not self describing at point of
> use. The confusion is enormously heightened here by having the doc
> book arguments be the reverse of the actual function prototype (I just
> tripped over this).
>
> The alloc flag is particularly counter intuitive: if you pass in an
> allocated buffer, you expect to be responsible for freeing it again,
> but that's not how you use it; you really use it like a reset not an
> alloc, which looks odd because you already created a separate
> tpm_buf_reset function which can't be used in this case.
>
> Why not replace the alloc flags with two reset functions: one for TPM2B
> buffers and one for command buffers?
>
> James
Or you can make that as internal (__tpm_buf_init()) and add two
wrappers.
BR, Jarkko
Powered by blists - more mailing lists