All of lore.kernel.org
 help / color / mirror / Atom feed
From: James Bottomley <James.Bottomley@HansenPartnership.com>
To: Martin Galvan <omgalvan.86@gmail.com>,
	linux-integrity@vger.kernel.org, jarkko.sakkinen@linux.intel.com
Subject: Re: Question about the TPM driver
Date: Thu, 13 Sep 2018 10:22:09 -0400	[thread overview]
Message-ID: <1536848529.3436.2.camel@HansenPartnership.com> (raw)
In-Reply-To: <CAN19L9EEYK+OpJSCw+nNv7fCjkS5eQeAXfy=51nfk=fBZne-BA@mail.gmail.com>

On Thu, 2018-09-13 at 10:14 -0300, Martin Galvan wrote:
> Hi all,
> 
> I noticed that, after a command is done, the TPM driver only allows
> for a single read operation (for a limited time). If I wanted to e.g.
> check a command's response code before attempting to read the rest of
> the response, my next read would fail. Same happens if I take too
> long to read a command's results.
> 
> I can understand the timeout, but I'm curious about this single-read
> policy, especially since some commands such as GetCapability don't
> guarantee how much data will actually be returned. Does anyone know
> why it was implemented this way?

Internally the TPM has a single message buffer.  It can't be reused for
the next command until the last one is fully received.  For
efficiency's sake you should have a pending read as soon as the command
is sent so the return of the read tells you the TPM has finished and
the TPM can get on to the next user.  The timeout is merely a courtesy
for the case the command completes before you can queue a read.  It's
short by design otherwise you give users the ability to DoS the TPM.

Exact buffer size hasn't been thought to be an issue since you know
that any response will fit into MAX_RESPONSE_SIZE which the current
implementation defines to be 4096.

James

  reply	other threads:[~2018-09-13 19:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-13 13:14 Question about the TPM driver Martin Galvan
2018-09-13 14:22 ` James Bottomley [this message]
2018-09-13 14:31   ` Martin Galvan
2018-09-13 15:11     ` Javier Martinez Canillas
2018-09-13 15:21       ` Tadeusz Struk
2018-09-13 15:26         ` Martin Galvan
2018-10-11 15:17   ` Ken Goldman
2018-09-16 19:16 ` Jarkko Sakkinen
2018-09-17 13:32   ` Martin Galvan
2018-09-17 14:45     ` James Bottomley
2018-09-17 21:23       ` Jarkko Sakkinen
2018-09-17 21:20     ` 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=1536848529.3436.2.camel@HansenPartnership.com \
    --to=james.bottomley@hansenpartnership.com \
    --cc=jarkko.sakkinen@linux.intel.com \
    --cc=linux-integrity@vger.kernel.org \
    --cc=omgalvan.86@gmail.com \
    /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.