Skip to contentSkip to conversation

RFC: in-kernel resource manager

RFC PATCH Dr. Greg Wettstein 8 participants 16 messages Jan 4, 2017 – Jan 11, 2017 6 messages not in the archive

lore
Share & tools
lore
#0 lore raw

On Jan 3, 5:21pm, Ken Goldman wrote:
} Subject: Re: [tpmdd-devel] [PATCH RFC 0/4] RFC: in-kernel resource manager

Good morning, I hope this note finds the day going well for everyone.

Quoted 11 lines · Jason Gunthorpe
Quoted 4 lines

I think we should also consider TPM 1.2 support in all of this, it is still a very popular piece of hardware and it is equally able to support a RM.

I suspect that TPM 2.0 and TPM 1.2 are so different that there may be little or no code in common.

My immediate need is for a 2.0 resource manager, since it's a gap in the technology, while 1.2 does have tcsd.

In the FWIW department.

I influence architecture and engineering for a company which builds deterministically modeled and attested computing platforms for high security assurance environments. This entity actually builds systems based on TPM1.2 and TPM2 hardware. TPM2 prototypes were being developed based on the simulator which came out of Ken's lab as soon as it was first made available.

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Repeat incessantly to oneself, TPM1.2 and TPM2 are only similar by virtue of sharing three ASCII characters.

DO NOT rush this process. If we do not get this right we will ultimately end up trying to shove something which is conceptually worse then tss/tscd into the kernel.

Repeat incesssantly to oneself, policy does not belong in the kernel.

Pay homage to Ken, his TSS2 and TPM2 simulator work are beyond excellent...

Greg

}-- End of excerpt from Ken Goldman

As always,

Dr. G.W. Wettstein, Ph.D.   Enjellic Systems Development, LLC.
4206 N. 19th Ave.           Specializing in information infra-structure
Fargo, ND  58102            development.

PH: 701-281-1686
FAX: 701-281-3949 EMAIL: [email protected]
------------------------------------------------------------------------------
"... you should really focus more on simplifying your life. I
actually spend most of my time finding ways to de-clog my brain."
-- Sarah Wettstein
At the lake

#2 lore raw
In reply to a message not in the archive

"Dr. Greg Wettstein" <greg-DHO+NtfOqB5PEDpkEIzg7wC/[email protected]> wrote on 01/04/2017 11:12:41 AM:

Quoted 4 lines

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel ...

If you're a TCG member, I invite you to join the TSS WG. I'd like an ally for simplicity.

Quoted 2 lines

Repeat incessantly to oneself, TPM1.2 and TPM2 are only similar by virtue of sharing three ASCII characters.

:-) I have to remember that one!

But, to be accurate, the hardware interface is nearly compatible, and the high level concepts (key hierarchy, authorization, PCRs, BV space) are similar. The API and implementation are new.

Quoted 3 lines

DO NOT rush this process. If we do not get this right we will ultimately end up trying to shove something which is conceptually worse then tss/tscd into the kernel.

The (only?) reason to put any of this in the kernel is that the kernel also needs access to the TPM.

Quoted 2 lines

Pay homage to Ken, his TSS2 and TPM2 simulator work are beyond excellent...

Thank you.

------------------------------------------------------------------------------
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 [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

#3 lore raw
In reply to Dr. Greg Wettstein
Quoted 7 lines · Dr. Greg Wettstein

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

This keeps the core for RM inside the kernel small and tight.

If we start to do some weird shit to the bodies that we think is good after long hours over engineering, the implementation will be a failure. In the user space the way bodies are virtualizes is easier to fine-tune because it doesn't break every possible app using the in-kernel RM.

/Jarkko

#4 lore raw
Quoted 7 lines · Jarkko Sakkinen

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

Is it correct that "bodies" are the parameter area of the commands and responses?

if so, eventually something should virtualize getcapability. It may be safer in user space, but it can mask RM issues.

#6 lore raw
In reply to Jarkko Sakkinen
Quoted 9 lines · Jarkko Sakkinen
Quoted 7 lines · Dr. Greg Wettstein

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Quoted 8 lines

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

This keeps the core for RM inside the kernel small and tight.

I think this makes sense.

In addition the kernel should only permit RM operations that are known to be 100% correct with the RM.

I think you should stick with your original design basic design, except instead of using an ioctl to switch modes, use an ioctl to execute the operation:

struct tpm_ioctl_operation {
u16 mode; // == TPM1_RAW,TPM2_RAW,TPM1_RM,TPM2_RM u16 locality;
u32 txlen;
u32 rxlen;
const void *txbuf;
void *rxbuf;
};

The userspace broker would be expected to use a mixture of RM and RAW operations.

Let's deal with the idea of another cdev some other day when someone can figure out a comprehensive way to do that securely for unpriv..

Jason

#8 lore raw
In reply to a message not in the archive

Am 10.01.2017 um 21:05 schrieb Jason Gunthorpe:

Quoted 9 lines · Jarkko Sakkinen
Quoted 8 lines · Dr. Greg Wettstein
Quoted 7 lines

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Quoted 8 lines
Quoted 8 lines

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

This keeps the core for RM inside the kernel small and tight.

You need to do virtualization inside bodies, because TPM2_FlushContext carries it's handles inside the parameter body.
Yep, huge blunder in the TPM spec, but hey, time for quirks... ;-)

Quoted 9 lines

I think this makes sense.

In addition the kernel should only permit RM operations that are known to be 100% correct with the RM.

I think you should stick with your original design basic design, except instead of using an ioctl to switch modes, use an ioctl to execute the operation:

Quoted 8 lines
struct tpm_ioctl_operation {
    u16 mode;  // == TPM1_RAW,TPM2_RAW,TPM1_RM,TPM2_RM
    u16 locality;
    u32 txlen;
    u32 rxlen;
    const void *txbuf;
    void *rxbuf;
};

could we please get an ioctl, that switches the "mode" of the fd entirely. I'd like to see the write()/read() support still intact.
All my current code uses main-loop based poll on the fd and I don't want to be force to start using threads...

Thanks,
Andreas

Quoted 9 lines

The userspace broker would be expected to use a mixture of RM and RAW operations.

Let's deal with the idea of another cdev some other day when someone can figure out a comprehensive way to do that securely for unpriv..

Jason

Quoted 10 lines

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
tpmdd-devel mailing list [email protected]
https://lists.sourceforge.net/lists/listinfo/tpmdd-devel

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#15 lore raw
In reply to a message not in the archive
Quoted 37 lines · Jason Gunthorpe
Quoted 9 lines · Jarkko Sakkinen
Quoted 7 lines · Dr. Greg Wettstein

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Quoted 8 lines

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

This keeps the core for RM inside the kernel small and tight.

I think this makes sense.

In addition the kernel should only permit RM operations that are known to be 100% correct with the RM.

I think you should stick with your original design basic design, except instead of using an ioctl to switch modes, use an ioctl to execute the operation:

struct tpm_ioctl_operation {
   u16 mode;  // == TPM1_RAW,TPM2_RAW,TPM1_RM,TPM2_RM
   u16 locality;
   u32 txlen;
   u32 rxlen;
   const void *txbuf;
   void *rxbuf;
};
Quoted 5 lines

The userspace broker would be expected to use a mixture of RM and RAW operations.

Let's deal with the idea of another cdev some other day when someone can figure out a comprehensive way to do that securely for unpriv..

James, what do you think about this proposal?

/Jarkko

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#5 lore raw
In reply to Ken Goldman
Quoted 9 lines · Ken Goldman
Quoted 7 lines · Jarkko Sakkinen

Here's my cuts for the kernel:

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session isolation for sessions.

Quoted 5 lines

Is it correct that "bodies" are the parameter area of the commands and responses?

if so, eventually something should virtualize getcapability. It may be safer in user space, but it can mask RM issues.

body == command / response - (header + handle area)

/Jarkko

#17 lore raw
In reply to a message not in the archive
Quoted 41 lines · Jarkko Sakkinen
Quoted 40 lines · Jason Gunthorpe
Quoted 13 lines · Jarkko Sakkinen
Quoted 8 lines · Dr. Greg Wettstein

The kernel needs a resource manager. Everyone needs to think VERY hard and VERY, VERY carefully about what gets put into the kernel. In making a decision, put the ABSOLUTE smallest amount of code into the kernel which allows various 'TPM2 personalities' to be implemented in userspace and functionally verified and protected by the physical instance. The emergence of commodity TEE's (SGX, et.al) should be in the back of everyone's mind as a factor in the roadmap.

Here's my cuts for the kernel:

Quoted 7 lines

- Kernel virtualizes handle areas. It's mechanical.
- Kernel does not virtualize bodies. It's not mechanical.
- At least the first version of the RM will not do other than session
isolation for sessions.

This keeps the core for RM inside the kernel small and tight.

I think this makes sense.

In addition the kernel should only permit RM operations that are known to be 100% correct with the RM.

I think you should stick with your original design basic design, except instead of using an ioctl to switch modes, use an ioctl to execute the operation:

struct tpm_ioctl_operation {
   u16 mode;  // == TPM1_RAW,TPM2_RAW,TPM1_RM,TPM2_RM
   u16 locality;
   u32 txlen;
   u32 rxlen;
   const void *txbuf;
   void *rxbuf;
};
Quoted 8 lines
Quoted 6 lines

The userspace broker would be expected to use a mixture of RM and RAW operations.

Let's deal with the idea of another cdev some other day when someone can figure out a comprehensive way to do that securely for unpriv..

James, what do you think about this proposal?

I don't think it's a good idea for the reasons stated before:

RAW access means the ability to DoS the TPM simply by exhausting handles. Therefore, I think most applications only get RM access. If you adopt this proposal, then, if you're only opening a single fd, we can't go by the unix permissions (even the RM only applications need to open it), so we'd need some permissions infrastructure within the kernel to reject RAW access from RM only users. That's why having multiple devices is much better because we can use the usual UNIX mechanism to separate access from raw and rm. I'm less sure about localities, but there may be the same issue at some point (not all applications get access to all localities). It would be good to get the localities use case sorted out before adding it to an ioctl based interfaces.

James

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#10 lore raw
In reply to a message not in the archive
Quoted 4 lines · Andreas Fuchs

You need to do virtualization inside bodies, because TPM2_FlushContext carries it's handles inside the parameter body.
Yep, huge blunder in the TPM spec, but hey, time for quirks... ;-)

It's not huge, not even a blunder. The TPM spec Part 3 has a note explaining why the TPM side does it that way.

For the TSS and resource manager, simply treat flushHandle as a handle (in the handle area rather than in the parameter/body area). It all just works. I modified the TSS as a test, and there's no issue at all.

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#19 lore raw
In reply to a message not in the archive
Quoted 2 lines · James Bottomley

RAW access means the ability to DoS the TPM simply by exhausting handles. Therefore, I think most applications only get RM access.

Re-read what Jarkko is proposing. He is not making a complete safe & secure RM in the kernel. He is making a tool to allow userspace and the kernel to share the TPM sanely.

It is not an access control tool, it is not a security tool, it is not intended to support safe unpriv userspace access.

So there is no reason to have a different access control model in userspace, it is not a fundamentally different security environment from the existing raw device.

A future project to provide an unpriv safe cdev from the kernel is something different.

Jason

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#11 lore raw
In reply to a message not in the archive
Quoted 4 lines · Andreas Fuchs

could we please get an ioctl, that switches the "mode" of the fd entirely. I'd like to see the write()/read() support still intact.
All my current code uses main-loop based poll on the fd and I don't want to be force to start using threads...

We currently do not support poll in the kernel for /dev/tpmX.

ie we do not supply a poll method for 'struct file_operations'.

Even worse, the current implementation blocks returning from write() until the TPM has completed its work, so it doesn't even make sense to combine it with poll.

Jason

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#20 lore raw
In reply to Jason Gunthorpe
Quoted 12 lines · Jason Gunthorpe
Quoted 2 lines · James Bottomley

RAW access means the ability to DoS the TPM simply by exhausting handles. Therefore, I think most applications only get RM access.

Re-read what Jarkko is proposing. He is not making a complete safe & secure RM in the kernel. He is making a tool to allow userspace and the kernel to share the TPM sanely.

It is not an access control tool, it is not a security tool, it is not intended to support safe unpriv userspace access.

Quoted 6 lines

So there is no reason to have a different access control model in userspace, it is not a fundamentally different security environment from the existing raw device.

A future project to provide an unpriv safe cdev from the kernel is something different.

Right, but we're going around in circles. I'm currently researching what it would take to be daemonless, so an ioctl which requires an access broker daemon would obviously be something I'd object to.

Basically, though, I think you can do both: we can add an ioctl and the differing device hooks. I just think for that case RAW vs RM would be redundant.

James

#13 lore raw
In reply to a message not in the archive
Quoted 6 lines · Jason Gunthorpe
Quoted 4 lines · Andreas Fuchs

could we please get an ioctl, that switches the "mode" of the fd entirely. I'd like to see the write()/read() support still intact.
All my current code uses main-loop based poll on the fd and I don't want to be force to start using threads...

Quoted 7 lines

We currently do not support poll in the kernel for /dev/tpmX.

ie we do not supply a poll method for 'struct file_operations'.

Even worse, the current implementation blocks returning from write() until the TPM has completed its work, so it doesn't even make sense to combine it with poll.

Newer applications could issue an ioctl() after the open() to unblock the write().

Stefan

------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors Access to Intel Xeon Phi processor-based developer platforms. With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi

#21 lore raw
In reply to James Bottomley
Quoted 3 lines · James Bottomley

Right, but we're going around in circles. I'm currently researching what it would take to be daemonless, so an ioctl which requires an access broker daemon would obviously be something I'd object to.

Well, when we figure out a security model that works for that and can be implemented in the kernel then lets add the new cdev.

But that is *explicitly* not what Jarkko is doing, no reason to jump the gun.

Quoted 3 lines

Basically, though, I think you can do both: we can add an ioctl and the differing device hooks. I just think for that case RAW vs RM would be redundant.

Right, some future new cdev would only support ioctl and only the RM path, but for priv use having both concurrently available makes sense as a userspace broker producing a full RM will need to using both paths.

Jason

#14 lore raw
In reply to Stefan Berger
Quoted 9 lines · Stefan Berger
Quoted 8 lines · Jason Gunthorpe
Quoted 4 lines · Andreas Fuchs

could we please get an ioctl, that switches the "mode" of the fd entirely. I'd like to see the write()/read() support still intact.
All my current code uses main-loop based poll on the fd and I don't want to be force to start using threads...

We currently do not support poll in the kernel for /dev/tpmX.

Quoted 8 lines
Quoted 5 lines

ie we do not supply a poll method for 'struct file_operations'.

Even worse, the current implementation blocks returning from write() until the TPM has completed its work, so it doesn't even make sense to combine it with poll.

Newer applications could issue an ioctl() after the open() to unblock the write().

The ioctl api I outlined could support poll by having userspace set the rxbuf = NULL.

The kernel would then launch the tx async and provide poll support to allow read() to return the result once the tpm has finished.

This can be added as a new capability down the road..

Jason