From: Jason Gunthorpe <jgg@nvidia.com>
To: James Bottomley <James.Bottomley@HansenPartnership.com>
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com>,
<linux-integrity@vger.kernel.org>
Subject: Re: [PATCH v4 1/1] tpm: add sysfs exports for all banks of PCR registers
Date: Wed, 19 Aug 2020 20:21:32 -0300 [thread overview]
Message-ID: <20200819232132.GT1152540@nvidia.com> (raw)
In-Reply-To: <1597867756.3875.39.camel@HansenPartnership.com>
On Wed, Aug 19, 2020 at 01:09:16PM -0700, James Bottomley wrote:
> On Wed, 2020-08-19 at 14:17 -0300, Jason Gunthorpe wrote:
> > On Wed, Aug 19, 2020 at 12:57:42PM -0400, Mimi Zohar wrote:
> > > On Wed, 2020-08-19 at 13:18 -0300, Jason Gunthorpe wrote:
> > > > Yes - it was dropped because TPM 2 was a *complete ABI break* for
> > > > everything. The kernel was reset to a uABI that matches current
> > > > uABI standards starting TPM 2.
> > > >
> > > > The whole userspace needed to be redone anyhow, and certainly
> > > > nobody objected at the time.
> > > >
> > > > At least my expecation was that a sensible userspace for TPM (for
> > > > administrator user) would be built, like we see in other
> > > > subsystems eg 'ip' for netdev.
> > >
> > > "Because TPM 2 was a complete ABI break for everything" could be
> > > reason for upstreaming a minimal subset of functionality initially,
> > > which could be expanded over time. I don't recall a discussion
> > > about limting features in the future.
> >
> > All new uAPI additions need to pass the usual uAPI hurdles.
> >
> > As James outlined, justify why the kernel must present a duplicated
> > uAPI between sysfs and /dev/tpm.
> >
> > There have been good reasons in the past, eg SCSI inquiry.
>
> First, can we please agree /dev/tpm does not substitute as a "duplicate
> API".
Er? Huh? How so?
> I can now clarify the objection into "it's a binary marshalled
> interface and Linus doesn't think we should force users to use them":
>
> https://lore.kernel.org/linux-api/CAHk-=wh5YifP7hzKSbwJj94+DZ2czjrZsczy6GBimiogZws=rg@mail.gmail.com/
I'm not sure which part of that you want to quote?
"It's great for well-specified wire protocols." which is describing
/dev/tpm - it has a multivendor standards body.
Bit puzzled about the rest of this message? Do you think Linus belives
netlink should have been implemented as ASCII? JSON parser in the
kernel maybe? Confusing.
> Perhaps we should also simply copy linux-api and accept the judgment of
> the experts on whether we should expose PCRs via sysfs.
Well, AFAIK, for a long time now the mantra has been "if it can be
done in userspace then it should not be in the kernel" ..
I would really like to see a better reason for this - one that doesn't
boil down to it being 'too hard' to write a bit of code in userspace.
eg we can't do it because we can't access /dev/tpm for permissions or
something.
> The reason we provide a kernel interface instead of a library or tool
> is that libraries and tools tend to be domain specific and the
> information needs to be provided across domains. So: both the current
> TPM 2.0 TSSs are written in C. This means they can just about be
> plugged into python but not easily into Go because of its abhorrence of
> ffis. Providing the PCRs from sysfs allows Go attestation easy access
> that the TSS tools don't because of the language domain problem.
I went to try to make a python implementation.. After about 10mins I
came up with this approximate thing:
select = struct.pack(">BBB", 1, 0, 0) # PCR 1
pcrread_in = struct.pack(">IHB", 1, TPM2_ALG_SHA1, len(select)) + select
msg = struct.pack(">HII", TPM2_ST_NO_SESSIONS, 10 + len(pcrread_in), TPM2_CC_PCR_READ) + pcrread_in
with open("/dev/tpm","wb") as tpm:
tpm.write(msg)
resp = tpm.read(msg)
tag, length, return_code = struct.unpack(">HII",res[:10])
if not return_code:
raise Error()
return res[10+20:] # digest
Which is hopefully quite close to being something working - at least
it looks fairly close to what the kernel implementation does.
Fortunately no Phd was required! I think Go would be about similar,
right?
Jason
next prev parent reply other threads:[~2020-08-19 23:21 UTC|newest]
Thread overview: 54+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-08-17 21:35 [PATCH v4 0/1] add sysfs exports for TPM 2 PCR registers James Bottomley
2020-08-17 21:35 ` [PATCH v4 1/1] tpm: add sysfs exports for all banks of " James Bottomley
2020-08-18 16:12 ` Jarkko Sakkinen
2020-08-18 16:19 ` Jarkko Sakkinen
2020-08-18 16:26 ` Jarkko Sakkinen
2020-08-18 16:46 ` Jason Gunthorpe
2020-08-18 18:26 ` Mimi Zohar
2020-08-18 18:36 ` Jason Gunthorpe
2020-08-18 18:55 ` Mimi Zohar
2020-08-19 12:02 ` Jason Gunthorpe
2020-08-19 13:27 ` Mimi Zohar
2020-08-19 14:09 ` Jason Gunthorpe
2020-08-19 14:53 ` Mimi Zohar
2020-08-19 14:55 ` Mimi Zohar
2020-08-19 22:16 ` Jarkko Sakkinen
2020-08-19 22:48 ` Jerry Snitselaar
2020-08-19 23:26 ` Jason Gunthorpe
2020-08-20 15:46 ` Jarkko Sakkinen
2020-08-19 14:56 ` Serge E. Hallyn
2020-08-19 22:15 ` Jarkko Sakkinen
2020-08-19 15:17 ` James Bottomley
2020-08-19 16:18 ` Jason Gunthorpe
2020-08-19 16:57 ` Mimi Zohar
2020-08-19 17:17 ` Jason Gunthorpe
2020-08-19 20:09 ` James Bottomley
2020-08-19 23:21 ` Jason Gunthorpe [this message]
2020-08-20 16:14 ` James Bottomley
2020-08-20 16:55 ` Serge E. Hallyn
2020-08-21 17:41 ` Jarkko Sakkinen
2020-08-21 19:38 ` Jason Gunthorpe
2020-08-24 19:44 ` Jarkko Sakkinen
2020-08-24 20:20 ` James Bottomley
2020-08-25 15:27 ` Jarkko Sakkinen
2020-08-25 15:33 ` James Bottomley
2020-08-26 13:15 ` Jarkko Sakkinen
2020-08-26 13:19 ` Jarkko Sakkinen
2020-08-24 21:57 ` Jason Gunthorpe
2020-08-19 22:14 ` Jarkko Sakkinen
2020-08-18 19:03 ` James Bottomley
2020-08-19 22:13 ` Jarkko Sakkinen
2020-08-19 22:01 ` Jarkko Sakkinen
2020-08-18 16:44 ` James Bottomley
2020-08-18 17:17 ` Jason Gunthorpe
2020-08-18 18:49 ` James Bottomley
2020-08-19 21:53 ` Jarkko Sakkinen
2020-08-19 22:46 ` James Bottomley
2020-08-20 15:22 ` Jarkko Sakkinen
2020-08-19 21:33 ` Jarkko Sakkinen
2020-09-14 17:41 ` Jarkko Sakkinen
2020-09-14 19:19 ` James Bottomley
2020-09-15 11:22 ` Jarkko Sakkinen
2020-10-08 11:45 ` Petr Vorel
2020-10-08 14:29 ` James Bottomley
2020-10-09 16:12 ` 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=20200819232132.GT1152540@nvidia.com \
--to=jgg@nvidia.com \
--cc=James.Bottomley@HansenPartnership.com \
--cc=jarkko.sakkinen@linux.intel.com \
--cc=linux-integrity@vger.kernel.org \
--cc=zohar@linux.ibm.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.