Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1552084 > unrolled thread
| Started by | "Fuchs, Andreas" <andreas.fuchs@sit.fraunhofer.de> |
|---|---|
| First post | 2017-01-05 17:10 +0100 |
| Last post | 2017-01-11 11:10 +0100 |
| Articles | 17 — 6 participants |
Back to article view | Back to linux.kernel
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
RE: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager "Fuchs, Andreas" <andreas.fuchs@sit.fraunhofer.de> - 2017-01-05 17:10 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-05 18:30 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-05 19:10 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> - 2017-01-06 09:50 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-05 19:40 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-05 21:00 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-05 21:00 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-05 23:30 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-06 01:00 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-06 01:40 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> - 2017-01-06 10:10 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-06 20:20 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jason Gunthorpe <jgunthorpe@obsidianresearch.com> - 2017-01-06 20:10 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager James Bottomley <jejb@linux.vnet.ibm.com> - 2017-01-06 02:40 +0100
Re: [PATCH RFC 0/4] RFC: in-kernel resource manager Ken Goldman <kgoldman@us.ibm.com> - 2017-01-10 20:20 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> - 2017-01-09 23:40 +0100
Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> - 2017-01-11 11:10 +0100
| From | "Fuchs, Andreas" <andreas.fuchs@sit.fraunhofer.de> |
|---|---|
| Date | 2017-01-05 17:10 +0100 |
| Subject | RE: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager |
| Message-ID | <sWiM1-5ja-11@gated-at.bofh.it> |
Great to see this coming along so well. Thanks a lot to Jarkko ! I just wanted to point out a few things I deem important at this point: - Number of virtual handles: From what I see there are currently 14 slots for virtual objects in the RFC (if I'm mistaking, please correct me). I'd advice to ask the TPM2_GetCapabilities(TPM_CAP_TPM_PROPERTIES, TPM_PT_HR_TRANSIENT_MIN or TPM_PT_HR_TRANSIENT_AVAIL) [Note: there is no actual max, i.e. the TPM will allow more transient objects that e.g. 3 if they are small] and provide each TPM space with the same amount as the TPM will tell them is available. If an application needs more objects, I'd see a per-fd mini-RM module inside the TSS-libraries handling that job quite well. Same would apply for Session with TPM_PT_HR_LOADED_MIN and TPM_PT_HR_LOADED_AVAIL. This will reduce the memory consumption inside the kernel and provide userspace with a consistent view on the GetCapabilities vs its actual Allocations. - Enumeration of loaded (virtual) handles: The TPM allows an application to get the list of currently loaded handles TPM2_GetCapabilities(TPM_CAP_HANDLES). It would be great to have the RM be as transparent to userspace as possible. The RM spec of TCG therefore says that you need to intercept and override this command (unless it is run in an authentication session where you cannot override it, which is disadviced). It's a design choice, but I'd advice for it after long discussions. - Constant session handles (hurray): Sessions do not change their handles on contextsave/contextload, so you do not need to virtualize session handles. In fact you must not do so, because cpHash-calculation needs to know the TPM's handle number for sessions on at least 1 command. So this simplifies session handling inside the kernel since you do not need to alter the handle area for session handles. - Session Limits (here it gets ugly): Even thought the TPM supports the same swapping-scheme for sessions as it does for transient objects, it only allows for a limited number of session to be opened (64 in case of PC-Client), called active sessions. This means that a single process can still DoS the TPM if it allocates 64 sessions, or 64 processes can DoS the TPM if they allocate 1 session each. There are two principle solutions: a) Limit the number of active sessions per fd, process, user and hope for the best. Of course this will not really protect you from DoS'ed TPMs. b) Kick out old sessions whenever new sessions are requested and TPM is currently full (the TCG RM spec approach). Of course applications need to handle "randomly vanishing" hmac sessions in this case. - Session ungaping (here it gets REALLY ugly): The TPM has some scheme for handling sessions that are swapped (contextSaved) out. In this scheme, it can run into the case where it will deny actions on a session handle with a TPM2_RC_GAP error. This error means that the time between last usage of the oldest session and the current session is too far apart. The reaction needs to be that the RM loads this oldest sesssion (or in my implementation all swaped sessions) into the TPM and contextsave them back right away. This becomes especially ugly, when enabling the ability of userspace to contextsave a session on one fd and contextload this session on another fd (or even from another process). I hope your can parse what I wrote, feel free to ask for more details on any point. I'll be more than happy to help concepting around these problems but atm unfortunately I'm unable to help with actual code ... for reasons... Best regards, Andreas ________________________________________ From: Jarkko Sakkinen [jarkko.sakkinen@linux.intel.com] Sent: Monday, January 02, 2017 14:22 To: tpmdd-devel@lists.sourceforge.net Cc: linux-security-module@vger.kernel.org; open list Subject: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager This patch set adds support for TPM spaces that provide a context for isolating and swapping transient objects. This patch set does not yet include support for isolating policy and HMAC sessions but it is trivial to add once the basic approach is settled (and that's why I created an RFC patch set). There's a test script for trying out TPM spaces in git://git.infradead.org/users/jjs/tpm2-scripts.git A simple smoke test can be run by sudo python -m unittest -v tpm2_smoke.SpaceTest Jarkko Sakkinen (4): tpm: migrate struct tpm_buf to struct tpm_chip tpm: validate TPM 2.0 commands tpm: export tpm2_flush_context_cmd tpm: add the infrastructure for TPM space for TPM 2.0 drivers/char/tpm/Makefile | 2 +- drivers/char/tpm/tpm-chip.c | 15 ++ drivers/char/tpm/tpm-dev.c | 80 ++++++++++- drivers/char/tpm/tpm-interface.c | 93 +++++++++---- drivers/char/tpm/tpm-sysfs.c | 2 +- drivers/char/tpm/tpm.h | 106 ++++++++------ drivers/char/tpm/tpm2-cmd.c | 232 ++++++++++++++++--------------- drivers/char/tpm/tpm2-space.c | 288 +++++++++++++++++++++++++++++++++++++++ include/uapi/linux/tpm.h | 23 ++++ 9 files changed, 662 insertions(+), 179 deletions(-) create mode 100644 drivers/char/tpm/tpm2-space.c create mode 100644 include/uapi/linux/tpm.h -- 2.9.3 ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, SlashDot.org! http://sdm.link/slashdot _______________________________________________ tpmdd-devel mailing list tpmdd-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/tpmdd-devel
[toc] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-05 18:30 +0100 |
| Message-ID | <sWk1s-63E-21@gated-at.bofh.it> |
| In reply to | #1552084 |
On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: > Great to see this coming along so well. Thanks a lot to Jarkko ! > The TPM allows an application to get the list of currently loaded > handles TPM2_GetCapabilities(TPM_CAP_HANDLES). It would be great to > have the RM be as transparent to userspace as possible. The RM spec > of TCG therefore says that you need to intercept and override this I'd rather just ban unnecessary stuff like this on the RM fd. Tracking active handles can be done in userspace by the app itself. Debugging can be done by using the non-RM fd or debugfs. IMHO we need to focus narrowly on enabling *specific* unpriviledged user space use models and safe co-existence with kernel users. > - Constant session handles (hurray): > Sessions do not change their handles on contextsave/contextload, so > you do not need to virtualize session handles. The kernel still needs to track them, so they can be cleaned up and access controlled. > - Session Limits (here it gets ugly): > Even thought the TPM supports the same swapping-scheme for sessions > as it does for transient objects, it only allows for a limited > number of session to be opened (64 in case of PC-Client), called > active sessions. This means that a single process can still DoS the > TPM if it allocates 64 sessions, or 64 processes can DoS the TPM if Well, if we have an unpriv fd then it should not be able to DOS the system - that would suggest either that FD cannot use sessions or we need some kernel solution to guarentee the DOS is not possible. A combo ioctl that could setup the session, issue an operation in it and then delete the session, for instance. Jason
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <jejb@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-01-05 19:10 +0100 |
| Message-ID | <sWkE9-6xP-3@gated-at.bofh.it> |
| In reply to | #1552156 |
On Thu, 2017-01-05 at 10:27 -0700, Jason Gunthorpe wrote: > On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: > > Great to see this coming along so well. Thanks a lot to Jarkko ! > > > The TPM allows an application to get the list of currently loaded > > handles TPM2_GetCapabilities(TPM_CAP_HANDLES). It would be great > > to have the RM be as transparent to userspace as possible. The RM > > spec of TCG therefore says that you need to intercept and override > > this > > I'd rather just ban unnecessary stuff like this on the RM fd. > Tracking active handles can be done in userspace by the app > itself. Debugging can be done by using the non-RM fd or debugfs. Yes, we basically agreed on not doing this. The only handles that actually need translating are the transient 0x80 ones. Since the RM effectively segregates them, you can't see anyone else's, so the only query could be about the application's own transient handles and it's difficult to see how it could lose track of them and want to issue this query. So the best course is to leave it unimplemented (less code) and see if anyone complains because they have an actual use case. James
[toc] | [prev] | [next] | [standalone]
| From | Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> |
|---|---|
| Date | 2017-01-06 09:50 +0100 |
| Message-ID | <sWynM-7EX-13@gated-at.bofh.it> |
| In reply to | #1552185 |
Am 05.01.2017 um 19:06 schrieb James Bottomley: > On Thu, 2017-01-05 at 10:27 -0700, Jason Gunthorpe wrote: >> On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: >>> Great to see this coming along so well. Thanks a lot to Jarkko ! >>> The TPM allows an application to get the list of currently loaded >>> handles TPM2_GetCapabilities(TPM_CAP_HANDLES). It would be great >>> to have the RM be as transparent to userspace as possible. The RM >>> spec of TCG therefore says that you need to intercept and override >>> this >> I'd rather just ban unnecessary stuff like this on the RM fd. >> Tracking active handles can be done in userspace by the app >> itself. Debugging can be done by using the non-RM fd or debugfs. > Yes, we basically agreed on not doing this. The only handles that > actually need translating are the transient 0x80 ones. Since the RM > effectively segregates them, you can't see anyone else's, so the only > query could be about the application's own transient handles and it's > difficult to see how it could lose track of them and want to issue this > query. So the best course is to leave it unimplemented (less code) and > see if anyone complains because they have an actual use case. Then how about blocking TPM2_GetCapabilities(TPM_CAP_HANDLES, 0x80000000) ? My concern is with a consistent view, so you either get the correct result or no result, but please no false results...
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <jejb@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-01-05 19:40 +0100 |
| Message-ID | <sWl7c-6J7-37@gated-at.bofh.it> |
| In reply to | #1552156 |
On Thu, 2017-01-05 at 10:27 -0700, Jason Gunthorpe wrote: > On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: [...] > > - Session Limits (here it gets ugly): > > > Even thought the TPM supports the same swapping-scheme for sessions > > as it does for transient objects, it only allows for a limited > > number of session to be opened (64 in case of PC-Client), called > > active sessions. This means that a single process can still DoS > > the TPM if it allocates 64 sessions, or 64 processes can DoS the > > TPM if > > Well, if we have an unpriv fd then it should not be able to DOS the > system - that would suggest either that FD cannot use sessions or we > need some kernel solution to guarentee the DOS is not possible. The sessions issue is a bit of a monster nightmare. The basic problem is this issue that they're not fully virtualizable: the TPM retains knowledge that a session existed on this handle even if the session context is offloaded. It's this space for "session exists" that the TPM has a limited space for. > A combo ioctl that could setup the session, issue an operation in it > and then delete the session, for instance. This would work for encryption or HMAC sessions, but probably not for policy sessions, because they can have an arbitrarily large command sequence to construct them. The other issue we're likely to run into if we do it this way is delayed error reporting. How about a more traditional approach which would be leasing (basically what we use for NFS). Any application opening a session would have a certain time (probably in ms) to complete it or we'd close the handle and flush it. We'd store the jiffies time the session was first requested and loop over all the extent sessions to find ones which get too old. We know there can only be TPM_PT_ACTIVE_SESSIONS_MAX of these, so it's a cheap operation. It's only a small extra bit of logic to take care of the GAP problem as well, I think. If we're full when you try and start a session, we block you until a handle becomes free and the max lease time guarantees when this is. James
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-05 21:00 +0100 |
| Message-ID | <sWmmB-7rW-1@gated-at.bofh.it> |
| In reply to | #1552208 |
On Thu, Jan 05, 2017 at 10:33:43AM -0800, James Bottomley wrote: > > A combo ioctl that could setup the session, issue an operation in it > > and then delete the session, for instance. > > This would work for encryption or HMAC sessions, but probably not for > policy sessions, because they can have an arbitrarily large command > sequence to construct them. I'd rather give up features (eg policy sessions, if necessary) for the unpriv fd than give up security of the unpriv fd. We always have the out that special stuff can go down the priv path. > The other issue we're likely to run into if we do it this way is > delayed error reporting. Not sure I follow. > How about a more traditional approach which would be leasing (basically > what we use for NFS). Any application opening a session would have Doesn't this just change the DOS vector? Now the attacker has to delay execution of TPM commands long enough to force session leases to time out. That isn't too hard to do, asking the TPM to make a RSA key can take seconds, for instance. Jason
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <jejb@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-01-05 21:00 +0100 |
| Message-ID | <sWmmB-7rW-3@gated-at.bofh.it> |
| In reply to | #1552288 |
On Thu, 2017-01-05 at 12:20 -0700, Jason Gunthorpe wrote: > On Thu, Jan 05, 2017 at 10:33:43AM -0800, James Bottomley wrote: > > > > A combo ioctl that could setup the session, issue an operation in > > > it > > > and then delete the session, for instance. > > > > This would work for encryption or HMAC sessions, but probably not > > for policy sessions, because they can have an arbitrarily large > > command sequence to construct them. > > I'd rather give up features (eg policy sessions, if necessary) for > the unpriv fd than give up security of the unpriv fd. We don't really have that choice: Keys require authorization, so you have to have an auth session. If you want things like PCR sealed or time limited keys, you don't really have a choice on policy sessions either. I think we've got to the point where arguing about our divergent use requirements shows the default should be 0600 and every command enabled so that whatever changes the device to 0666 also applies the command filter policy. It's the fully safe default that satisfies everyone. Once you have the command blacklist, you can blacklist every policy command before you make your device 0666. That effecively achieves what you want because no-one can now initiate a policy session. > We always have the out that special stuff can go down the priv path. > > > The other issue we're likely to run into if we do it this way is > > delayed error reporting. > > Not sure I follow. If we try to issue a load of commands as a transaction, you only get the error when the transaction is executed, even if the entity causing the problem is way back in the command sequence. > > How about a more traditional approach which would be leasing > > (basically what we use for NFS). Any application opening a session > > would have > > Doesn't this just change the DOS vector? Now the attacker has to > delay execution of TPM commands long enough to force session leases > to time out. That isn't too hard to do, asking the TPM to make a RSA > key can take seconds, for instance. I really don't think we can prevent all types of DoS in the TPM. After all, in a lot of current silicon, it can take up to 90 seconds to generate an RSA key using the KDF ... the TPM is unavailable while this is happening, so there's your DoS on a standard command. What we need to aim for is effective resource sharing. The 64 handle limit is one of the nasty ones that a bunch of applications could accidentally overflow. A lease model bounds the TPM blocked time while you're waiting for an available handle and coping with a lease timeout can be done in the TSS. TPM execution time could be added to lease expiry, so even if someone's doing a sequence of RSA KDFs, you eventually get your job executed as long as we do the execution of blocked commands in a strict order. In this model, you can "DoS" me by substantially delaying the execution of my commands, but you can't prevent it from executing within a bounded time. I suppose we could even make TPM execution time an RLIMIT. James
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-05 23:30 +0100 |
| Message-ID | <sWoHM-Jf-7@gated-at.bofh.it> |
| In reply to | #1552289 |
On Thu, Jan 05, 2017 at 11:55:49AM -0800, James Bottomley wrote: > We don't really have that choice: Keys require authorization, so you > have to have an auth session. I know, this is why I suggested a combo op (kernel level atomicity is clearly DOS safe).. > If you want things like PCR sealed or time limited keys, you don't > really have a choice on policy sessions either. .. and advanced stuff like is what I was talking about giving up for unpriv if it can't be allowed safely ... > I think we've got to the point where arguing about our divergent use > requirements shows the default should be 0600 and every command enabled > so that whatever changes the device to 0666 also applies the command Well, that is what we already have with /dev/tpm0. I'm very surprised by this level of disagreement, so I'm inclined to drop the idea that the kernel can directly support a 0666 cdev at all. Lets stick with the user space broker process and just introduce enough kernel RM to enable co-existance with kernel users and clean-up on crash. This should be enough to make a user space broker much simpler. So Jarkko's uapi is basically fine.. No need for a kernel white list/etc I had really hoped we could have a secure default 0666 cdev that would be able to support the basic use of your user space plugins without a daemon :( Jason
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-06 01:00 +0100 |
| Message-ID | <sWq6R-1FB-21@gated-at.bofh.it> |
| In reply to | #1552377 |
On Thu, Jan 05, 2017 at 02:58:46PM -0800, James Bottomley wrote:
> On Thu, 2017-01-05 at 15:21 -0700, Jason Gunthorpe wrote:
> > On Thu, Jan 05, 2017 at 11:55:49AM -0800, James Bottomley wrote:
> >
> > > We don't really have that choice: Keys require authorization, so
> > > you have to have an auth session.
> >
> > I know, this is why I suggested a combo op (kernel level atomicity
> > is clearly DOS safe)..
>
> Transactions are a hard thing to guarantee to be DoS safe and the more
> complex they get, the more difficult they are to police within the
> kernel. Plus we have to keep the R/W interface for backwards
> compatibility now that we have it and I just don't see how we could
> layer transactions into it without having some sort of in-kernel
> emulator.
Again, this was only to make the unpriv FD usable and safe against
session DOS and that FD wouldn't use the legacy r/w interface. I don't
care if root can DOS the TPM via /dev/tpm0. combo ops would need to be
simple enough to reason about. (in my TPM libaries API calls are
combo'd with session anyhow, and that works quite well for my use
models)
> > Lets stick with the user space broker process and just introduce
> > enough kernel RM to enable co-existance with kernel users and clean
> > -up on crash. This should be enough to make a user space broker much
> > simpler.
>
> I wouldn't go that far. I'm still planning a userspace tss2 without
> any access broker daemon, but let's see how far I get on top of the RM.
> I think building in stages is a good way to get actual use experience
> to guide the next stage.
I'm sure you can implement what you are doing on top of the RM -
that isn't a question in my mind.
My question has always been how does your plugin deliver messages to
the kernel RM in a way that does not compromise the security of the
TPM system.
> > So Jarkko's uapi is basically fine.. No need for a kernel white
> > list/etc
>
> I suspect we'll eventually get to needing one, but I'm happy to
> begin
IMHO the problem with trousers as a broker is just how horribly
complex it was.
With the kernel RM this problem becomes very simple:
- 1:1 relationship between incoming clients and kernel fds (Jarkko's
existing design allows a broker to safely create many RM fds)
- Trivial inspection of messages to determine op and check whitelist
(just the first couple bytes give you the opcode, easy to deep
inspect things like get capability)
- No marshal/demarshal, no virtualization, no crypto.
(kernel does virtualization, client does marshal and crypto)
I'm not sure what reason would be big enough to put it in the kernel
when we seem to have irreconcilable use models for the security policy
it needs to implement...
Maybe that is OK, but it isn't what I was hoping for at the start :)
Jason
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <jejb@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-01-06 01:40 +0100 |
| Message-ID | <sWqJz-2cg-7@gated-at.bofh.it> |
| In reply to | #1552408 |
On Thu, 2017-01-05 at 16:50 -0700, Jason Gunthorpe wrote: > On Thu, Jan 05, 2017 at 02:58:46PM -0800, James Bottomley wrote: > > On Thu, 2017-01-05 at 15:21 -0700, Jason Gunthorpe wrote: > > > On Thu, Jan 05, 2017 at 11:55:49AM -0800, James Bottomley wrote: > > > > > > > We don't really have that choice: Keys require authorization, > > > > so you have to have an auth session. > > > > > > I know, this is why I suggested a combo op (kernel level > > > atomicity is clearly DOS safe).. > > > > Transactions are a hard thing to guarantee to be DoS safe and the > > more complex they get, the more difficult they are to police within > > the kernel. Plus we have to keep the R/W interface for backwards > > compatibility now that we have it and I just don't see how we could > > layer transactions into it without having some sort of in-kernel > > emulator. > > Again, this was only to make the unpriv FD usable and safe against > session DOS and that FD wouldn't use the legacy r/w interface. I > don't care if root can DOS the TPM via /dev/tpm0. combo ops would > need to be simple enough to reason about. (in my TPM libaries API > calls are combo'd with session anyhow, and that works quite well for > my use models) In Ken's TSS2 they are for simple authorisation. However, policy auth is where it gets tricky and right at the moment I believe I need policy based authorisation for keys. > > > Lets stick with the user space broker process and just introduce > > > enough kernel RM to enable co-existance with kernel users and > > > clean -up on crash. This should be enough to make a user space > > > broker much simpler. > > > > I wouldn't go that far. I'm still planning a userspace tss2 > > without any access broker daemon, but let's see how far I get on > > top of the RM. I think building in stages is a good way to get > > actual use experience to guide the next stage. > > I'm sure you can implement what you are doing on top of the RM - > that isn't a question in my mind. > > My question has always been how does your plugin deliver messages to > the kernel RM in a way that does not compromise the security of the > TPM system. So currently, it doesn't: I have to either run as root or run a udev script to give me access to the device, neither of which will work out of the box for distributions because of the security risks you identified. I think this is OK for now because the security issue only has to be sorted out before we make this ready for general release (i.e. advise the distros how to expose the TPM) and we need to gather use case data before we do that. > > > So Jarkko's uapi is basically fine.. No need for a kernel white > > > list/etc > > > > I suspect we'll eventually get to needing one, but I'm happy to > > begin > > IMHO the problem with trousers as a broker is just how horribly > complex it was. > > With the kernel RM this problem becomes very simple: > > - 1:1 relationship between incoming clients and kernel fds (Jarkko's > existing design allows a broker to safely create many RM fds) > - Trivial inspection of messages to determine op and check whitelist > (just the first couple bytes give you the opcode, easy to deep > inspect things like get capability) > - No marshal/demarshal, no virtualization, no crypto. > (kernel does virtualization, client does marshal and crypto) > > I'm not sure what reason would be big enough to put it in the kernel > when we seem to have irreconcilable use models for the security > policy it needs to implement... > > Maybe that is OK, but it isn't what I was hoping for at the start :) I actually think this is OK for now. I have theories about how I'm going to use policy in TPM keys but I haven't written any code yet. The only actual code I have is the openssl and gnome-keyring patches I posted to make use of password authorized TPM based RSA keys. I'd really rather not say what is and isn't safe to blacklist until I have some use experience of policy based keys: I'm going to continue working on them (although it looks like a hard problem because we need to standardise an ASN.1 form of key policy as well) so hopefully I can acquire the necessary experience over the next few weeks. I'm seriously pissed of with trousers and will port the trousers based TPM1.2 RSA key patches I've done to whatever direct connect API you come up with (just send me a link to the git tree or package or whatever), so this should generate some use experience for 1.2, like whether we actually need a RM without trousers and also what the safety issues might be. My main laptop is now TPM2, but I have a backup one that's TPM1.2 and also has all the TPM key stuff as well. Perhaps our models in practice may turn out not to be as diverse as they appear in theory, so let's try it out. This way we can build on actual use experience for extending the API (and in the mean time we keep the devices root only like they were previously) James
[toc] | [prev] | [next] | [standalone]
| From | Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> |
|---|---|
| Date | 2017-01-06 10:10 +0100 |
| Message-ID | <sWyH7-82e-21@gated-at.bofh.it> |
| In reply to | #1552431 |
Am 06.01.2017 um 01:36 schrieb James Bottomley: > On Thu, 2017-01-05 at 16:50 -0700, Jason Gunthorpe wrote: >> On Thu, Jan 05, 2017 at 02:58:46PM -0800, James Bottomley wrote: >>> On Thu, 2017-01-05 at 15:21 -0700, Jason Gunthorpe wrote: >>>> On Thu, Jan 05, 2017 at 11:55:49AM -0800, James Bottomley wrote: >>>> >>>>> We don't really have that choice: Keys require authorization, >>>>> so you have to have an auth session. >>>> I know, this is why I suggested a combo op (kernel level >>>> atomicity is clearly DOS safe).. >>> Transactions are a hard thing to guarantee to be DoS safe and the >>> more complex they get, the more difficult they are to police within >>> the kernel. Plus we have to keep the R/W interface for backwards >>> compatibility now that we have it and I just don't see how we could >>> layer transactions into it without having some sort of in-kernel >>> emulator. >> Again, this was only to make the unpriv FD usable and safe against >> session DOS and that FD wouldn't use the legacy r/w interface. I >> don't care if root can DOS the TPM via /dev/tpm0. combo ops would >> need to be simple enough to reason about. (in my TPM libaries API >> calls are combo'd with session anyhow, and that works quite well for >> my use models) > In Ken's TSS2 they are for simple authorisation. However, policy auth > is where it gets tricky and right at the moment I believe I need policy > based authorisation for keys. I don't think this is TSS-specific. It also holds true for the TCG-TSS. The thing is that you will need both, HMAC and Policy Sessions in standard userspace applications (not only the exotic ones)... ... and they must not be time-based leases, because other IO or user-UI might happen. Reasons: 1. PolicyPCR is an essential feature of TPM used all over the place, so we need support for policy sessions. 2. PolicySigned allows authentication of the user via SmartCard. So the application will have to challenge back using the challenge from the TPM. So no timeouts please. 3. HMAC-sessions could also be handled via authentication tokens that take the cpHash and session as challenge and provide an HMAC. Again we'd have IO and user interaction. In summary, in TCG we came to the conclusion that kicking out sessions is the best approach. IMHO session quotas per process, user, cgroup is even better, but was not possible in the TCG spec for a user-space cross-OS RM (no notion of such capabilities). We spent several f2f-meetings, confcalls and emails on this topic inside the TCG. I'd advice everyone to look into the RM-spec and coming updates, and especially TCG members to look into potential unrelease documents on these issues. Feel free to contact me as well for any TCG-insights. >>>> Lets stick with the user space broker process and just introduce >>>> enough kernel RM to enable co-existance with kernel users and >>>> clean -up on crash. This should be enough to make a user space >>>> broker much simpler. >>> I wouldn't go that far. I'm still planning a userspace tss2 >>> without any access broker daemon, but let's see how far I get on >>> top of the RM. I think building in stages is a good way to get >>> actual use experience to guide the next stage. >> I'm sure you can implement what you are doing on top of the RM - >> that isn't a question in my mind. >> >> My question has always been how does your plugin deliver messages to >> the kernel RM in a way that does not compromise the security of the >> TPM system. > So currently, it doesn't: I have to either run as root or run a udev > script to give me access to the device, neither of which will work out > of the box for distributions because of the security risks you > identified. I think this is OK for now because the security issue only > has to be sorted out before we make this ready for general release > (i.e. advise the distros how to expose the TPM) and we need to gather > use case data before we do that. The all-defeating reason for having in-kernel-RM is trusted keyrings or IMA/EVM appraise/protect or similar. They will want to use sealing to PCRs which in turn requires policy sessions from inside the kernel and thus RM inside the kernel to play nicely with the TSS. TCG's TSS had to add an ugly quirk into its spec in order to work with current trusted keyrings uapi that I really want to deprecate. And IMHO nobody wants the kernel security modules to call back to a userspace RM-daemon. If everyone agrees with this presumption the only question becomes how to do this, such that we don't need a second RM in userspace for the 99% of use cases. P.S. This fact should also be given some thought when discussing the priviledged 0600 node, i.e. /dev/tpm0 without the s in the middle. Cheers, Andreas
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-06 20:20 +0100 |
| Message-ID | <sWIds-6kw-31@gated-at.bofh.it> |
| In reply to | #1552620 |
On Fri, Jan 06, 2017 at 09:59:57AM +0100, Andreas Fuchs wrote: > 1. PolicyPCR is an essential feature of TPM used all over the place, > so we need support for policy sessions. > 2. PolicySigned allows authentication of the user via SmartCard. Are smart cards 0666 in linux? > The all-defeating reason for having in-kernel-RM is trusted keyrings > or IMA/EVM appraise/protect or similar. They will want to use sealing > to PCRs which in turn requires policy sessions from inside the kernel > and thus RM inside the kernel to play nicely with the TSS. Yes. I had hoped the in-kernel-RM could also provide safe 0666 access, but lets move on from that idea and focus on kernel/user TPM application co-existence... > And IMHO nobody wants the kernel security modules to call back to a > userspace RM-daemon. Yep. > If everyone agrees with this presumption the only question becomes > how to do this, such that we don't need a second RM in userspace > for the 99% of use cases. Yep. > P.S. This fact should also be given some thought when discussing the > priviledged 0600 node, i.e. /dev/tpm0 without the s in the middle. We are stuck with the non-RM interface for compat. There could be a kernel option/module option/sysctl/whatever of some kind to disable it I guess. Jason
[toc] | [prev] | [next] | [standalone]
| From | Jason Gunthorpe <jgunthorpe@obsidianresearch.com> |
|---|---|
| Date | 2017-01-06 20:10 +0100 |
| Message-ID | <sWI3L-6eW-15@gated-at.bofh.it> |
| In reply to | #1552431 |
On Thu, Jan 05, 2017 at 04:36:42PM -0800, James Bottomley wrote: > I'm seriously pissed of with trousers and will port the trousers based > TPM1.2 RSA key patches I've done to whatever direct connect API you > come up with (just send me a link to the git tree or package or > whatever), so this should generate some use experience for 1.2, like > whether we actually need a RM without trousers and also what the safety > issues might be. My main laptop is now TPM2, but I have a backup one > that's TPM1.2 and also has all the TPM key stuff as well. I would like to add basic 1.2 support to Jarkko's RM. I'm not sure if my 5mth old will ever let me.. If we do that we write a simple broker as I described that works on both 1.2 and 2.0 and trousers can go away. Jason
[toc] | [prev] | [next] | [standalone]
| From | James Bottomley <jejb@linux.vnet.ibm.com> |
|---|---|
| Date | 2017-01-06 02:40 +0100 |
| Message-ID | <sWq6R-1FB-23@gated-at.bofh.it> |
| In reply to | #1552377 |
On Thu, 2017-01-05 at 15:21 -0700, Jason Gunthorpe wrote: > On Thu, Jan 05, 2017 at 11:55:49AM -0800, James Bottomley wrote: > > > We don't really have that choice: Keys require authorization, so > > you have to have an auth session. > > I know, this is why I suggested a combo op (kernel level atomicity > is clearly DOS safe).. Transactions are a hard thing to guarantee to be DoS safe and the more complex they get, the more difficult they are to police within the kernel. Plus we have to keep the R/W interface for backwards compatibility now that we have it and I just don't see how we could layer transactions into it without having some sort of in-kernel emulator. > > If you want things like PCR sealed or time limited keys, you don't > > really have a choice on policy sessions either. > > .. and advanced stuff like is what I was talking about giving up for > unpriv if it can't be allowed safely ... > > > I think we've got to the point where arguing about our divergent > > use requirements shows the default should be 0600 and every command > > enabled so that whatever changes the device to 0666 also applies > > the command > > Well, that is what we already have with /dev/tpm0. Except that doesn't have the RM. > I'm very surprised by this level of disagreement, so I'm inclined to > drop the idea that the kernel can directly support a 0666 cdev at > all. Great. We'll keep it at 0600 and let userspace sort it out; that way policy becomes flexible too. > Lets stick with the user space broker process and just introduce > enough kernel RM to enable co-existance with kernel users and clean > -up on crash. This should be enough to make a user space broker much > simpler. I wouldn't go that far. I'm still planning a userspace tss2 without any access broker daemon, but let's see how far I get on top of the RM. I think building in stages is a good way to get actual use experience to guide the next stage. > So Jarkko's uapi is basically fine.. No need for a kernel white > list/etc I suspect we'll eventually get to needing one, but I'm happy to begin without and see what that experience tells us before we try to build it. This is actually a better way of doing stuff because we can add to an API based on what we find in the field; the hard thing is pulling back an API that doesn't work. > I had really hoped we could have a secure default 0666 cdev that > would be able to support the basic use of your user space plugins > without a daemon :( I think we can; I just don't think we can define a single in-kernel use policy that supports everyone's use case, so punting to userspace and letting it sort out the desired policy for the platform will work for everyone. James
[toc] | [prev] | [next] | [standalone]
| From | Ken Goldman <kgoldman@us.ibm.com> |
|---|---|
| Date | 2017-01-10 20:20 +0100 |
| Subject | Re: [PATCH RFC 0/4] RFC: in-kernel resource manager |
| Message-ID | <sYa7D-5fe-15@gated-at.bofh.it> |
| In reply to | #1552288 |
On 1/5/2017 2:20 PM, Jason Gunthorpe wrote: > > I'd rather give up features (eg policy sessions, if necessary) for the > unpriv fd than give up security of the unpriv fd. Please don't give up policy. Nearly every use case of that we think of for TPM 2.0 uses policy sessions. E.g., In 1.2, PCR authorization was built in to the object. In 2.0, it's a policy. In 1.2, key types were restricted to certain commands. In 2.0, it's a policy. Then there are all the new use cases - time restricted keys, use count restricted keys, keys with a PIN, etc., all use policy. Even use of the EK primary key requires a policy, and that's needed for salt (getting the first password in securely) and attestation (proof that the TPM is authentic).
[toc] | [prev] | [next] | [standalone]
| From | Jarkko Sakkinen <jarkko.sakkinen@linux.intel.com> |
|---|---|
| Date | 2017-01-09 23:40 +0100 |
| Message-ID | <sXQLE-1uM-33@gated-at.bofh.it> |
| In reply to | #1552084 |
On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: > Great to see this coming along so well. Thanks a lot to Jarkko ! > I just wanted to point out a few things I deem important at this point: > > - Number of virtual handles: > From what I see there are currently 14 slots for virtual objects in the RFC (if I'm mistaking, please correct me). > I'd advice to ask the TPM2_GetCapabilities(TPM_CAP_TPM_PROPERTIES, TPM_PT_HR_TRANSIENT_MIN or TPM_PT_HR_TRANSIENT_AVAIL) > [Note: there is no actual max, i.e. the TPM will allow more transient objects that e.g. 3 if they are small] > and provide each TPM space with the same amount as the TPM will tell them is available. > If an application needs more objects, I'd see a per-fd mini-RM module inside the TSS-libraries handling that job quite well. > Same would apply for Session with TPM_PT_HR_LOADED_MIN and TPM_PT_HR_LOADED_AVAIL. > This will reduce the memory consumption inside the kernel and provide userspace with a consistent view on the GetCapabilities vs its actual Allocations. I rather have a fixed size object. It keeps the implementation simple compact and stupid and that is what we want at this point. Even if I did what you proposed there would not be 1:1 match with GetCapability provided data because we need to virtual handle values. Leaving the virtualization of message bodies in the user space is a design choice from my side. The kernel will provide only basic mechanism for implementing easily an RM, not a full fledged implementation. > - Enumeration of loaded (virtual) handles: > The TPM allows an application to get the list of currently loaded handles TPM2_GetCapabilities(TPM_CAP_HANDLES). > It would be great to have the RM be as transparent to userspace as possible. The RM spec of TCG therefore says that you need to intercept and override this command (unless it is run in an authentication session where you cannot override it, which is disadviced). It's a design choice, but I'd advice for it after long discussions. I don't buy this because it doesn't scale (new commands in the standard, vendor specific commands). It's just something that is factors easier to do in the user space. It's not an uncommon design in the Linux kernel to have basic mechanism in the kernel and do some of the heavy lifting in the user space. For example, graphics drivers are like that. > - Session Limits (here it gets ugly): > Even thought the TPM supports the same swapping-scheme for sessions as it does for transient objects, it only allows for a limited number of session to be opened (64 in case of PC-Client), called active sessions. > This means that a single process can still DoS the TPM if it allocates 64 sessions, or 64 processes can DoS the TPM if they allocate 1 session each. > There are two principle solutions: > a) Limit the number of active sessions per fd, process, user and hope for the best. Of course this will not really protect you from DoS'ed TPMs. > b) Kick out old sessions whenever new sessions are requested and TPM is currently full (the TCG RM spec approach). Of course applications need to handle "randomly vanishing" hmac sessions in this case. I'll think about this. The next patch set version will include session isolation. > - Session ungaping (here it gets REALLY ugly): > The TPM has some scheme for handling sessions that are swapped (contextSaved) out. In this scheme, it can run into the case where it will deny actions on a session handle with a TPM2_RC_GAP error. > This error means that the time between last usage of the oldest session and the current session is too far apart. > The reaction needs to be that the RM loads this oldest sesssion (or in my implementation all swaped sessions) into the TPM and contextsave them back right away. > This becomes especially ugly, when enabling the ability of userspace to contextsave a session on one fd and contextload this session on another fd (or even from another process). This something we are not going to support in the first production version. I'm happy review patches that try to do this nicely after the first version of the feature has landed. I don't care about this feature all that much. /Jarkko
[toc] | [prev] | [next] | [standalone]
| From | Andreas Fuchs <andreas.fuchs@sit.fraunhofer.de> |
|---|---|
| Date | 2017-01-11 11:10 +0100 |
| Message-ID | <sYo0W-5B1-13@gated-at.bofh.it> |
| In reply to | #1554771 |
Am 09.01.2017 um 23:39 schrieb Jarkko Sakkinen: > On Thu, Jan 05, 2017 at 03:52:02PM +0000, Fuchs, Andreas wrote: >> Great to see this coming along so well. Thanks a lot to Jarkko ! >> I just wanted to point out a few things I deem important at this point: >> >> - Number of virtual handles: >> From what I see there are currently 14 slots for virtual objects in the RFC (if I'm mistaking, please correct me). >> I'd advice to ask the TPM2_GetCapabilities(TPM_CAP_TPM_PROPERTIES, TPM_PT_HR_TRANSIENT_MIN or TPM_PT_HR_TRANSIENT_AVAIL) >> [Note: there is no actual max, i.e. the TPM will allow more transient objects that e.g. 3 if they are small] >> and provide each TPM space with the same amount as the TPM will tell them is available. >> If an application needs more objects, I'd see a per-fd mini-RM module inside the TSS-libraries handling that job quite well. >> Same would apply for Session with TPM_PT_HR_LOADED_MIN and TPM_PT_HR_LOADED_AVAIL. >> This will reduce the memory consumption inside the kernel and provide userspace with a consistent view on the GetCapabilities vs its actual Allocations. > I rather have a fixed size object. It keeps the implementation simple > compact and stupid and that is what we want at this point. > > Even if I did what you proposed there would not be 1:1 match with > GetCapability provided data because we need to virtual handle values. > > Leaving the virtualization of message bodies in the user space is a > design choice from my side. The kernel will provide only basic mechanism > for implementing easily an RM, not a full fledged implementation. > >> - Enumeration of loaded (virtual) handles: >> The TPM allows an application to get the list of currently loaded handles TPM2_GetCapabilities(TPM_CAP_HANDLES). >> It would be great to have the RM be as transparent to userspace as possible. The RM spec of TCG therefore says that you need to intercept and override this command (unless it is run in an authentication session where you cannot override it, which is disadviced). It's a design choice, but I'd advice for it after long discussions. > I don't buy this because it doesn't scale (new commands in the standard, > vendor specific commands). It's just something that is factors easier > to do in the user space. > > It's not an uncommon design in the Linux kernel to have basic mechanism > in the kernel and do some of the heavy lifting in the user space. For example, > graphics drivers are like that. > >> - Session Limits (here it gets ugly): >> Even thought the TPM supports the same swapping-scheme for sessions as it does for transient objects, it only allows for a limited number of session to be opened (64 in case of PC-Client), called active sessions. >> This means that a single process can still DoS the TPM if it allocates 64 sessions, or 64 processes can DoS the TPM if they allocate 1 session each. >> There are two principle solutions: >> a) Limit the number of active sessions per fd, process, user and hope for the best. Of course this will not really protect you from DoS'ed TPMs. >> b) Kick out old sessions whenever new sessions are requested and TPM is currently full (the TCG RM spec approach). Of course applications need to handle "randomly vanishing" hmac sessions in this case. > I'll think about this. The next patch set version will include > session isolation. > >> - Session ungaping (here it gets REALLY ugly): >> The TPM has some scheme for handling sessions that are swapped (contextSaved) out. In this scheme, it can run into the case where it will deny actions on a session handle with a TPM2_RC_GAP error. >> This error means that the time between last usage of the oldest session and the current session is too far apart. >> The reaction needs to be that the RM loads this oldest sesssion (or in my implementation all swaped sessions) into the TPM and contextsave them back right away. >> This becomes especially ugly, when enabling the ability of userspace to contextsave a session on one fd and contextload this session on another fd (or even from another process). > This something we are not going to support in the first production > version. I'm happy review patches that try to do this nicely after > the first version of the feature has landed. I don't care about this > feature all that much. I guess all of the above is more or less debatable. This point here however is not. It's a necessity, otherwise you will get weird machines that (seemingly) randomly stop working after a long time; i.e. months. So nobody will find this in tests or be able to reproduce. These are the kind of bugs nobody will ever track down. So please, do not release session-RM-support without taking care of ungaping... This would be highly irresponsible ! Thanks, Andreas > > /Jarkko
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web