public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Stefano Garzarella <sgarzare@redhat.com>,
	Claudio Carvalho <cclaudio@linux.ibm.com>,
	Tom Lendacky <thomas.lendacky@amd.com>
Cc: linux-coco@lists.linux.dev, Borislav Petkov <bp@alien8.de>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	Peter Huewe <peterhuewe@gmx.de>, "H. Peter Anvin" <hpa@zytor.com>,
	linux-integrity@vger.kernel.org, x86@kernel.org,
	Joerg Roedel <jroedel@suse.de>, Jason Gunthorpe <jgg@ziepe.ca>,
	Jarkko Sakkinen <jarkko@kernel.org>,
	linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>,
	 Thomas Gleixner <tglx@linutronix.de>,
	Dov Murik <dovmurik@linux.ibm.com>,
	Oliver Steffen <osteffen@redhat.com>
Subject: Re: [PATCH 1/3] tpm: add generic platform device
Date: Thu, 12 Dec 2024 09:35:46 -0500	[thread overview]
Message-ID: <b92113a11f121dc4d485b5ba522c8c8c0781d1be.camel@HansenPartnership.com> (raw)
In-Reply-To: <zzi3fvbo2rnb2d76soseuekwaqe22ifnrhhjplqhvw6x26lbb4@nmcqylrenzyj>

On Thu, 2024-12-12 at 10:51 +0100, Stefano Garzarella wrote:
> On Tue, Dec 10, 2024 at 03:34:21PM +0100, Stefano Garzarella wrote:
[...]
> > +static int tpm_platform_recv(struct tpm_chip *chip, u8 *buf,
> > size_t len)
> > +{
> > +       struct tpm_resp *resp = (struct tpm_resp *)buffer;
> > +
> > +       if (resp->size < 0)
> > +               return resp->size;
> 
> While reviewing Oliver's work for the driver in edk2[1], I noticed
> that
> there wasn't this check and asked to add it, but talking to him and
> looking in the code/spec, we realized that it's strange that
> tpm_resp.size field is signed.
> 
>  From SVSM spec it looks like it can't be negative:
> 
>      Table 17: TPM_SEND_COMMAND Response Structure
> 
>      Byte     Size        Meaning
>      Offset   (Bytes)
>      0x000    4           Response size (in bytes)
>      0x004    Variable    Variable Response
> 
> And also Coconut SVSM remap it to the `responseSize` of the TCG TPM
> implementation which is unsigned:
> 
>      LIB_EXPORT void _plat__RunCommand(
>          uint32_t        requestSize,   // IN: command buffer size
>          unsigned char*  request,       // IN: command buffer
>          uint32_t*       responseSize,  // IN/OUT: response buffer
> size
>          unsigned char** response       // IN/OUT: response buffer
>      )
> 
> @James, @Claudio, @Tom, should we use u32 for tpm_resp.size?

The original idea was to allow the protocol to return an error (like
out of memory or something) before the command ever got to the TPM
rather than having to wrap it up in a TPM error.  However, that's done
in the actual return from the SVSM call, which the sendrecv routine
checks, so I agree this can be removed and a u32 done for the length. 
Dov did recommend we should check the returned length against the
maximum allowable:

https://lore.kernel.org/linux-coco/f7d0bd07-ba1b-894e-5e39-15fb1817bc8b@linux.ibm.com/

Regards,

James


  reply	other threads:[~2024-12-12 14:35 UTC|newest]

Thread overview: 37+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-10 14:34 [PATCH 0/3] Enlightened vTPM support for SVSM on SEV-SNP Stefano Garzarella
2024-12-10 14:34 ` [PATCH 1/3] tpm: add generic platform device Stefano Garzarella
2024-12-12  9:51   ` Stefano Garzarella
2024-12-12 14:35     ` James Bottomley [this message]
2024-12-12 15:30       ` Stefano Garzarella
2024-12-12 15:41         ` James Bottomley
2024-12-12 16:12           ` Stefano Garzarella
2024-12-10 14:34 ` [PATCH 2/3] x86/sev: add SVSM call macros for the vTPM protocol Stefano Garzarella
2024-12-10 14:34 ` [PATCH 3/3] x86/sev: add a SVSM vTPM platform device Stefano Garzarella
2024-12-10 14:40   ` Jason Gunthorpe
2024-12-10 14:55     ` James Bottomley
2024-12-10 15:04       ` Jason Gunthorpe
2024-12-11  8:19         ` Stefano Garzarella
2024-12-11 15:00           ` Jason Gunthorpe
2024-12-11 15:38             ` Stefano Garzarella
2024-12-11 15:53               ` Jason Gunthorpe
2024-12-11 16:42                 ` Stefano Garzarella
2024-12-19 15:35             ` Stefano Garzarella
2024-12-19 15:40               ` Jarkko Sakkinen
2024-12-19 16:06                 ` Stefano Garzarella
2025-01-14 10:42                   ` Stefano Garzarella
2025-01-14 13:07                     ` Jason Gunthorpe
2025-01-14 16:51                       ` Stefano Garzarella
2025-01-14 17:33                         ` Jason Gunthorpe
2025-01-14 22:46                     ` Jarkko Sakkinen
2025-01-14 22:48                       ` Jarkko Sakkinen
2025-01-14 23:12                         ` Jarkko Sakkinen
2025-01-22 21:29                           ` Dionna Amalie Glaze
2025-01-23  9:50                             ` Jarkko Sakkinen
2025-01-23 10:09                               ` Stefano Garzarella
2025-01-23 11:46                                 ` Jarkko Sakkinen
2025-01-23 11:49                                   ` Jarkko Sakkinen
2025-01-23 12:29                                     ` Stefano Garzarella
2024-12-11 16:30   ` Tom Lendacky
2024-12-11 16:55     ` Stefano Garzarella
2024-12-11 17:02     ` James Bottomley
2024-12-13 11:48       ` Stefano Garzarella

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=b92113a11f121dc4d485b5ba522c8c8c0781d1be.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=bp@alien8.de \
    --cc=cclaudio@linux.ibm.com \
    --cc=dave.hansen@linux.intel.com \
    --cc=dovmurik@linux.ibm.com \
    --cc=hpa@zytor.com \
    --cc=jarkko@kernel.org \
    --cc=jgg@ziepe.ca \
    --cc=jroedel@suse.de \
    --cc=linux-coco@lists.linux.dev \
    --cc=linux-integrity@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=osteffen@redhat.com \
    --cc=peterhuewe@gmx.de \
    --cc=sgarzare@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox