Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key. Also, this is
an alternative in case platform doesn't possess a TPM device.
This series also adds some TEE features like:
Patch #1, #2 enables support for registered kernel shared memory with TEE.
Patch #3 enables support for private kernel login method required for
cases like trusted keys where we don't wan't user-space to directly access
TEE service to retrieve trusted key contents.
Rest of the patches from #4 to #6 adds support for TEE based trusted keys.
This patch-set has been tested with OP-TEE based pseudo TA which can be
found here [1].
Also, this patch-set is dependent on generic Trusted Keys framework
patch-set [2].
[1] https://github.com/OP-TEE/optee_os/pull/3082
[2] https://lkml.org/lkml/2019/7/18/284
Changes in v2:
1. Add reviewed-by tags for patch #1 and #2.
2. Incorporate comments from Jens for patch #3.
3. Switch to use generic trusted keys framework.
Sumit Garg (6):
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Documentation/security/keys/index.rst | 1 +
Documentation/security/keys/tee-trusted.rst | 93 +++++++++
MAINTAINERS | 9 +
drivers/tee/optee/call.c | 7 +
drivers/tee/tee_core.c | 6 +
drivers/tee/tee_shm.c | 16 +-
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 +++++++
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 +
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 ++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
14 files changed, 498 insertions(+), 3 deletions(-)
create mode 100644 Documentation/security/keys/tee-trusted.rst
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
--
2.7.4
Kernel pages are marked as normal type memory only so allow kernel pages
to be registered as shared memory with OP-TEE.
Signed-off-by: Sumit Garg <redacted>
Reviewed-by: Jarkko Sakkinen <redacted>
Reviewed-by: Jens Wiklander <redacted>
---
drivers/tee/optee/call.c | 7 +++++++
1 file changed, 7 insertions(+)
Enable support to register kernel memory reference with TEE. This change
will allow TEE bus drivers to register memory references.
Signed-off-by: Sumit Garg <redacted>
Reviewed-by: Jarkko Sakkinen <redacted>
Reviewed-by: Jens Wiklander <redacted>
---
drivers/tee/tee_shm.c | 16 ++++++++++++++--
include/linux/tee_drv.h | 1 +
2 files changed, 15 insertions(+), 2 deletions(-)
@@ -26,6 +26,7 @@#define TEE_SHM_REGISTER BIT(3) /* Memory registered in secure world */#define TEE_SHM_USER_MAPPED BIT(4) /* Memory mapped in user space */#define TEE_SHM_POOL BIT(5) /* Memory allocated from pool */+#define TEE_SHM_KERNEL_MAPPED BIT(6) /* Memory mapped in kernel space */structdevice;structtee_device;
There are use-cases where user-space shouldn't be allowed to communicate
directly with a TEE device which is dedicated to provide a specific
service for a kernel client. So add a private login method for kernel
clients and disallow user-space to open-session using GP implementation
defined login method range: (0x80000000 - 0xFFFFFFFF).
Signed-off-by: Sumit Garg <redacted>
---
drivers/tee/tee_core.c | 6 ++++++
include/uapi/linux/tee.h | 8 ++++++++
2 files changed, 14 insertions(+)
@@ -334,6 +334,12 @@ static int tee_ioctl_open_session(struct tee_context *ctx,gotoout;}+if(arg.clnt_login&TEE_IOCTL_LOGIN_MASK){+pr_debug("login method not allowed for user-space client\n");+rc=-EPERM;+gotoout;+}+rc=ctx->teedev->desc->ops->open_session(ctx,&arg,params);if(rc)gotoout;
Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key.
Refer to Documentation/tee.txt for detailed information about TEE.
Signed-off-by: Sumit Garg <redacted>
---
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 ++++++++
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 +++++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
6 files changed, 359 insertions(+), 1 deletion(-)
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
@@ -0,0 +1,93 @@+======================+TEE based Trusted Keys+======================++TEE based Trusted Keys provides an alternative approach for providing Trusted+Keys in case TPM chip isn't present.++Trusted Keys use a TEE service/device both to generate and to seal the keys.+Keys are sealed under a hardware unique key in the TEE, and only unsealed by+the TEE.++For more information about TEE, refer to ``Documentation/tee.txt``.++Usage::++ keyctl add trusted name "new keylen" ring+ keyctl add trusted name "load hex_blob" ring+ keyctl print keyid++"keyctl print" returns an ascii hex copy of the sealed key, which is in format+specific to TEE device implementation. The key length for new keys are always+in bytes. Trusted Keys can be 32 - 128 bytes (256 - 1024 bits).++Examples of trusted key and its usage as 'master' key for encrypted key usage:++More details about encrypted keys can be found here:+``Documentation/security/keys/trusted-encrypted.rst``++Create and save a trusted key named "kmk" of length 32 bytes::++ $ keyctl add trusted kmk "new 32" @u+ 754414669++ $ keyctl show+ Session Keyring+ 827385718 --alswrv 0 65534 keyring: _uid_ses.0+ 274124851 --alswrv 0 65534 \_ keyring: _uid.0+ 754414669 --als-rv 0 0 \_ trusted: kmk++ $ keyctl print 754414669+ 15676790697861b422175596ae001c2f505cea2c6f3ebbc5fb08eeb1f343a07e++ $ keyctl pipe 754414669 > kmk.blob++Load a trusted key from the saved blob::++ $ keyctl add trusted kmk "load `cat kmk.blob`" @u+ 491638700++ $ keyctl print 491638700+ 15676790697861b422175596ae001c2f505cea2c6f3ebbc5fb08eeb1f343a07e++The initial consumer of trusted keys is EVM, which at boot time needs a high+quality symmetric key for HMAC protection of file metadata. The use of a+TEE based trusted key provides security that the EVM key has not been+compromised by a user level problem and tied to particular hardware.++Create and save an encrypted key "evm" using the above trusted key "kmk":++option 1: omitting 'format'::++ $ keyctl add encrypted evm "new trusted:kmk 32" @u+ 608915065++option 2: explicitly defining 'format' as 'default'::++ $ keyctl add encrypted evm "new default trusted:kmk 32" @u+ 608915065++ $ keyctl print 608915065+ default trusted:kmk 32 f380ac588a925f488d5be007cf23e4c900b8b652ab62241c8+ ed54906189b6659d139d619d4b51752a2645537b11fd44673f13154a65b3f595d5fb2131+ 2fe45529ea0407c644ea4026f2a1a75661f2c9b66++ $ keyctl pipe 608915065 > evm.blob++Load an encrypted key "evm" from saved blob::++ $ keyctl add encrypted evm "load `cat evm.blob`" @u+ 831684262++ $ keyctl print 831684262+ default trusted:kmk 32 f380ac588a925f488d5be007cf23e4c900b8b652ab62241c8+ ed54906189b6659d139d619d4b51752a2645537b11fd44673f13154a65b3f595d5fb2131+ 2fe45529ea0407c644ea4026f2a1a75661f2c9b66++Other uses for trusted and encrypted keys, such as for disk and file encryption+are anticipated. In particular the 'ecryptfs' encrypted keys format can be used+to mount an eCryptfs filesystem. More details about the usage can be found in+the file ``Documentation/security/keys/ecryptfs.rst``.++Another format 'enc32' can be used to support encrypted keys with payload size+of 32 bytes.
From: Janne Karhunen <hidden> Date: 2019-07-31 07:11:50
Hi,
Interesting, I wrote something similar and posted it to the lists a while back:
https://github.com/jkrh/linux/commit/d77ea03afedcb5fd42234cd834da8f8a0809f6a6
Since there are no generic 'TEEs' available, I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
--
Janne
On Tue, Jul 30, 2019 at 3:26 PM Sumit Garg [off-list ref] wrote:
Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key. Also, this is
an alternative in case platform doesn't possess a TPM device.
This series also adds some TEE features like:
Patch #1, #2 enables support for registered kernel shared memory with TEE.
Patch #3 enables support for private kernel login method required for
cases like trusted keys where we don't wan't user-space to directly access
TEE service to retrieve trusted key contents.
Rest of the patches from #4 to #6 adds support for TEE based trusted keys.
This patch-set has been tested with OP-TEE based pseudo TA which can be
found here [1].
Also, this patch-set is dependent on generic Trusted Keys framework
patch-set [2].
[1] https://github.com/OP-TEE/optee_os/pull/3082
[2] https://lkml.org/lkml/2019/7/18/284
Changes in v2:
1. Add reviewed-by tags for patch #1 and #2.
2. Incorporate comments from Jens for patch #3.
3. Switch to use generic trusted keys framework.
Sumit Garg (6):
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Documentation/security/keys/index.rst | 1 +
Documentation/security/keys/tee-trusted.rst | 93 +++++++++
MAINTAINERS | 9 +
drivers/tee/optee/call.c | 7 +
drivers/tee/tee_core.c | 6 +
drivers/tee/tee_shm.c | 16 +-
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 +++++++
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 +
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 ++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
14 files changed, 498 insertions(+), 3 deletions(-)
create mode 100644 Documentation/security/keys/tee-trusted.rst
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
--
2.7.4
From: Janne Karhunen <hidden> Date: 2019-07-31 10:21:58
Hi,
To clarify a bit further - my thought was to support any type of trust
source. Remote, local or both. Just having one particular type of
locally bound 'TEE' sounded very limited, especially when nothing from
the TEE execution side is really needed for supporting the kernel
crypto. What you really need is the seal/unseal transaction going
somewhere and where that somewhere is does not matter much. With the
user mode helper in between anyone can easily add their own thing in
there.
--
Janne
On Wed, Jul 31, 2019 at 10:11 AM Janne Karhunen
[off-list ref] wrote:
Hi,
Interesting, I wrote something similar and posted it to the lists a while back:
https://github.com/jkrh/linux/commit/d77ea03afedcb5fd42234cd834da8f8a0809f6a6
Since there are no generic 'TEEs' available, I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
--
Janne
On Tue, Jul 30, 2019 at 3:26 PM Sumit Garg [off-list ref] wrote:
quoted
Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key. Also, this is
an alternative in case platform doesn't possess a TPM device.
This series also adds some TEE features like:
Patch #1, #2 enables support for registered kernel shared memory with TEE.
Patch #3 enables support for private kernel login method required for
cases like trusted keys where we don't wan't user-space to directly access
TEE service to retrieve trusted key contents.
Rest of the patches from #4 to #6 adds support for TEE based trusted keys.
This patch-set has been tested with OP-TEE based pseudo TA which can be
found here [1].
Also, this patch-set is dependent on generic Trusted Keys framework
patch-set [2].
[1] https://github.com/OP-TEE/optee_os/pull/3082
[2] https://lkml.org/lkml/2019/7/18/284
Changes in v2:
1. Add reviewed-by tags for patch #1 and #2.
2. Incorporate comments from Jens for patch #3.
3. Switch to use generic trusted keys framework.
Sumit Garg (6):
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Documentation/security/keys/index.rst | 1 +
Documentation/security/keys/tee-trusted.rst | 93 +++++++++
MAINTAINERS | 9 +
drivers/tee/optee/call.c | 7 +
drivers/tee/tee_core.c | 6 +
drivers/tee/tee_shm.c | 16 +-
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 +++++++
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 +
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 ++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
14 files changed, 498 insertions(+), 3 deletions(-)
create mode 100644 Documentation/security/keys/tee-trusted.rst
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
--
2.7.4
There is already a generic TEE interface driver available in kernel.
Have a look here: "Documentation/tee.txt".
I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
If you look at patch #1 and #2, they add support to register kernel
memory buffer (keydata buffer in this case) with TEE to operate on. So
there isn't any limitation due to the size of the keydata.
-Sumit
--
Janne
On Tue, Jul 30, 2019 at 3:26 PM Sumit Garg [off-list ref] wrote:
quoted
Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key. Also, this is
an alternative in case platform doesn't possess a TPM device.
This series also adds some TEE features like:
Patch #1, #2 enables support for registered kernel shared memory with TEE.
Patch #3 enables support for private kernel login method required for
cases like trusted keys where we don't wan't user-space to directly access
TEE service to retrieve trusted key contents.
Rest of the patches from #4 to #6 adds support for TEE based trusted keys.
This patch-set has been tested with OP-TEE based pseudo TA which can be
found here [1].
Also, this patch-set is dependent on generic Trusted Keys framework
patch-set [2].
[1] https://github.com/OP-TEE/optee_os/pull/3082
[2] https://lkml.org/lkml/2019/7/18/284
Changes in v2:
1. Add reviewed-by tags for patch #1 and #2.
2. Incorporate comments from Jens for patch #3.
3. Switch to use generic trusted keys framework.
Sumit Garg (6):
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Documentation/security/keys/index.rst | 1 +
Documentation/security/keys/tee-trusted.rst | 93 +++++++++
MAINTAINERS | 9 +
drivers/tee/optee/call.c | 7 +
drivers/tee/tee_core.c | 6 +
drivers/tee/tee_shm.c | 16 +-
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 +++++++
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 +
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 ++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
14 files changed, 498 insertions(+), 3 deletions(-)
create mode 100644 Documentation/security/keys/tee-trusted.rst
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
--
2.7.4
There is already a generic TEE interface driver available in kernel.
Have a look here: "Documentation/tee.txt".
I guess my wording was wrong, tried to say that physical TEEs in the
wild vary massively hardware wise. Generalizing these things is rough.
quoted
I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
If you look at patch #1 and #2, they add support to register kernel
memory buffer (keydata buffer in this case) with TEE to operate on. So
there isn't any limitation due to the size of the keydata.
Ah, didn't mean that. Meant that the keydata is typically pretty small
in size, so there is limited benefit from passing that in via shm if
that complicates anything.
--
Janne
On Wed, 31 Jul 2019 at 15:51, Janne Karhunen [off-list ref] wrote:
Hi,
To clarify a bit further - my thought was to support any type of trust
source.
That could be very well accomplished via Trusted Keys abstraction
framework [1]. A trust source just need to implement following APIs:
struct trusted_key_ops ts_trusted_key_ops = {
.migratable = 0, /* non-migratable */
.init = init_ts_trusted,
.seal = ts_key_seal,
.unseal = ts_key_unseal,
.get_random = ts_get_random,
.cleanup = cleanup_ts_trusted,
};
Remote, local or both. Just having one particular type of
locally bound 'TEE' sounded very limited,
TEE is just one of trust source like TPM, we can have other trust
source as mentioned above.
especially when nothing from
the TEE execution side is really needed for supporting the kernel
crypto. What you really need is the seal/unseal transaction going
somewhere and where that somewhere is does not matter much.
Its only the seal/unseal operations that are provided by TEE driver
that hooks up under trusted keys abstraction layer.
With the
user mode helper in between anyone can easily add their own thing in
there.
Isn't actual purpose to have trusted keys is to protect user-space
from access to kernel keys in plain format? Doesn't user mode helper
defeat that purpose in one way or another?
--
Janne
On Wed, Jul 31, 2019 at 10:11 AM Janne Karhunen
[off-list ref] wrote:
quoted
Hi,
Interesting, I wrote something similar and posted it to the lists a while back:
https://github.com/jkrh/linux/commit/d77ea03afedcb5fd42234cd834da8f8a0809f6a6
Since there are no generic 'TEEs' available, I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
--
Janne
On Tue, Jul 30, 2019 at 3:26 PM Sumit Garg [off-list ref] wrote:
quoted
Add support for TEE based trusted keys where TEE provides the functionality
to seal and unseal trusted keys using hardware unique key. Also, this is
an alternative in case platform doesn't possess a TPM device.
This series also adds some TEE features like:
Patch #1, #2 enables support for registered kernel shared memory with TEE.
Patch #3 enables support for private kernel login method required for
cases like trusted keys where we don't wan't user-space to directly access
TEE service to retrieve trusted key contents.
Rest of the patches from #4 to #6 adds support for TEE based trusted keys.
This patch-set has been tested with OP-TEE based pseudo TA which can be
found here [1].
Also, this patch-set is dependent on generic Trusted Keys framework
patch-set [2].
[1] https://github.com/OP-TEE/optee_os/pull/3082
[2] https://lkml.org/lkml/2019/7/18/284
Changes in v2:
1. Add reviewed-by tags for patch #1 and #2.
2. Incorporate comments from Jens for patch #3.
3. Switch to use generic trusted keys framework.
Sumit Garg (6):
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Documentation/security/keys/index.rst | 1 +
Documentation/security/keys/tee-trusted.rst | 93 +++++++++
MAINTAINERS | 9 +
drivers/tee/optee/call.c | 7 +
drivers/tee/tee_core.c | 6 +
drivers/tee/tee_shm.c | 16 +-
include/keys/trusted-type.h | 3 +
include/keys/trusted_tee.h | 66 +++++++
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 +
security/keys/Kconfig | 3 +
security/keys/trusted-keys/Makefile | 3 +-
security/keys/trusted-keys/trusted-tee.c | 282 ++++++++++++++++++++++++++++
security/keys/trusted-keys/trusted.c | 3 +
14 files changed, 498 insertions(+), 3 deletions(-)
create mode 100644 Documentation/security/keys/tee-trusted.rst
create mode 100644 include/keys/trusted_tee.h
create mode 100644 security/keys/trusted-keys/trusted-tee.c
--
2.7.4
There is already a generic TEE interface driver available in kernel.
Have a look here: "Documentation/tee.txt".
I guess my wording was wrong, tried to say that physical TEEs in the
wild vary massively hardware wise. Generalizing these things is rough.
There are already well defined GlobalPlatform Standards to generalize
the TEE interface. One of them is GlobalPlatform TEE Client API [1]
which provides the basis for this TEE interface.
quoted
quoted
I implemented the same
thing as a generic protocol translator. The shared memory binding for
instance already assumes fair amount about the TEE and how that is
physically present in the system. Besides, the help from usage of shm
is pretty limited due to the size of the keydata.
If you look at patch #1 and #2, they add support to register kernel
memory buffer (keydata buffer in this case) with TEE to operate on. So
there isn't any limitation due to the size of the keydata.
Ah, didn't mean that. Meant that the keydata is typically pretty small
in size, so there is limited benefit from passing that in via shm if
that complicates anything.
From: Janne Karhunen <hidden> Date: 2019-08-01 06:21:56
On Wed, Jul 31, 2019 at 4:58 PM Sumit Garg [off-list ref] wrote:
quoted
To clarify a bit further - my thought was to support any type of trust
source.
That could be very well accomplished via Trusted Keys abstraction
framework [1]. A trust source just need to implement following APIs:
struct trusted_key_ops ts_trusted_key_ops = {
.migratable = 0, /* non-migratable */
.init = init_ts_trusted,
.seal = ts_key_seal,
.unseal = ts_key_unseal,
.get_random = ts_get_random,
.cleanup = cleanup_ts_trusted,
};
Which is basically the same as implementing a new keytype in the
kernel; abstraction is not raised in any considerable manner this way?
I chose the userspace plugin due to this, you can use userspace aids
to provide any type of service. Use the crypto library you desire to
do the magic you want.
quoted
With the
user mode helper in between anyone can easily add their own thing in
there.
Isn't actual purpose to have trusted keys is to protect user-space
from access to kernel keys in plain format? Doesn't user mode helper
defeat that purpose in one way or another?
Not really. CPU is in the user mode while running the code, but the
code or the secure keydata being is not available to the 'normal'
userspace. It's like microkernel service/driver this way. The usermode
driver is part of the kernel image and it runs on top of a invisible
rootfs.
--
Janne
From: Janne Karhunen <hidden> Date: 2019-08-01 06:37:03
On Wed, Jul 31, 2019 at 5:23 PM Sumit Garg [off-list ref] wrote:
quoted
I guess my wording was wrong, tried to say that physical TEEs in the
wild vary massively hardware wise. Generalizing these things is rough.
There are already well defined GlobalPlatform Standards to generalize
the TEE interface. One of them is GlobalPlatform TEE Client API [1]
which provides the basis for this TEE interface.
I'm aware of it - I have implemented a large part of the GP TEE APIs
earlier (primarily the crypto functions). Does the TEE you work with
actually support GP properly? Can I take a look at the code?
Normally the TEE implementations are well-guarded secrets and the
state of the implementation is quite random. In many cases keeping
things secret is fine from my point of view, given that it is a RoT
after all. The secrecy is the core business here. So, this is why I
opted the userspace 'secret' route - no secrets in the kernel, but
it's fine for the userspace. Umh was a logical fit to implement it.
--
Janne
On Thu, 2019-08-01 at 09:36 +0300, Janne Karhunen wrote:
On Wed, Jul 31, 2019 at 5:23 PM Sumit Garg [off-list ref]
wrote:
quoted
quoted
I guess my wording was wrong, tried to say that physical TEEs in
the
wild vary massively hardware wise. Generalizing these things is
rough.
There are already well defined GlobalPlatform Standards to
generalize
the TEE interface. One of them is GlobalPlatform TEE Client API [1]
which provides the basis for this TEE interface.
I'm aware of it - I have implemented a large part of the GP TEE APIs
earlier (primarily the crypto functions). Does the TEE you work with
actually support GP properly? Can I take a look at the code?
From: Janne Karhunen <hidden> Date: 2019-08-01 07:30:22
On Thu, Aug 1, 2019 at 9:50 AM Rouven Czerwinski
[off-list ref] wrote:
quoted
I'm aware of it - I have implemented a large part of the GP TEE APIs
earlier (primarily the crypto functions). Does the TEE you work with
actually support GP properly? Can I take a look at the code?
Thanks, I will take a look. The fundamental problem with these things
is that there are infinite amount of ways how TEEs and ROTs can be
done in terms of the hardware and software. I really doubt there are 2
implementations in existence that are even remotely compatible in real
life. As such, all things TEE/ROT would logically really belong in the
userland and thanks to the bpfilter folks now the umh logic really
makes that possible ... I think. The key implementation I did was just
an RFC on the concept, what if we start to move the stuff that really
belongs in the userspace to this pseudo-userland. It's not kernel, but
it's not commonly accessible userland either. The shared memory would
also work without any modifications between the umh based TEE/ROT
driver and the userland if needed.
Anyway, just my .02c. I guess having any new support in the kernel for
new trust sources is good and improvement from the current state. I
can certainly make my stuff work with your setup as well, what ever
people think is the best.
--
Janne
On Thu, 1 Aug 2019 at 11:51, Janne Karhunen [off-list ref] wrote:
On Wed, Jul 31, 2019 at 4:58 PM Sumit Garg [off-list ref] wrote:
quoted
quoted
To clarify a bit further - my thought was to support any type of trust
source.
That could be very well accomplished via Trusted Keys abstraction
framework [1]. A trust source just need to implement following APIs:
struct trusted_key_ops ts_trusted_key_ops = {
.migratable = 0, /* non-migratable */
.init = init_ts_trusted,
.seal = ts_key_seal,
.unseal = ts_key_unseal,
.get_random = ts_get_random,
.cleanup = cleanup_ts_trusted,
};
Which is basically the same as implementing a new keytype in the
kernel; abstraction is not raised in any considerable manner this way?
It doesn't create a new keytype. There is only single keytype:
"trusted" which could be implemented via one of the trust source
available in the system like TPM, TEE etc.
I chose the userspace plugin due to this, you can use userspace aids
to provide any type of service. Use the crypto library you desire to
do the magic you want.
Here TEE isn't similar to a user-space crypto library. In our case TEE
is based on ARM TrustZone which only allows TEE communications to be
initiated from privileged mode. So why would you like to route
communications via user-mode (which is less secure) when we have
standardised TEE interface available in kernel?
quoted
quoted
With the
user mode helper in between anyone can easily add their own thing in
there.
Isn't actual purpose to have trusted keys is to protect user-space
from access to kernel keys in plain format? Doesn't user mode helper
defeat that purpose in one way or another?
Not really. CPU is in the user mode while running the code, but the
code or the secure keydata being is not available to the 'normal'
userspace. It's like microkernel service/driver this way. The usermode
driver is part of the kernel image and it runs on top of a invisible
rootfs.
Can you elaborate here with an example regarding how this user-mode
helper will securely communicate with a hardware based trust source
with other user-space processes denied access to that trust source?
-Sumit
On Thu, 1 Aug 2019 at 13:00, Janne Karhunen [off-list ref] wrote:
On Thu, Aug 1, 2019 at 9:50 AM Rouven Czerwinski
[off-list ref] wrote:
quoted
quoted
I'm aware of it - I have implemented a large part of the GP TEE APIs
earlier (primarily the crypto functions). Does the TEE you work with
actually support GP properly? Can I take a look at the code?
The fundamental problem with these things
is that there are infinite amount of ways how TEEs and ROTs can be
done in terms of the hardware and software. I really doubt there are 2
implementations in existence that are even remotely compatible in real
life.
I agree with you regarding implementation specific nature of TEE but
having a standardized client interface does solves the problem.
As such, all things TEE/ROT would logically really belong in the
userland and thanks to the bpfilter folks now the umh logic really
makes that possible ... I think. The key implementation I did was just
an RFC on the concept, what if we start to move the stuff that really
belongs in the userspace to this pseudo-userland. It's not kernel, but
it's not commonly accessible userland either. The shared memory would
also work without any modifications between the umh based TEE/ROT
driver and the userland if needed.
Anyway, just my .02c. I guess having any new support in the kernel for
new trust sources is good and improvement from the current state. I
can certainly make my stuff work with your setup as well, what ever
people think is the best.
Yes your implementation can very well fit under trusted keys
abstraction framework without creating a new keytype: "ext-trusted".
-Sumit
From: Janne Karhunen <hidden> Date: 2019-08-01 08:00:06
On Thu, Aug 1, 2019 at 10:40 AM Sumit Garg [off-list ref] wrote:
quoted
I chose the userspace plugin due to this, you can use userspace aids
to provide any type of service. Use the crypto library you desire to
do the magic you want.
Here TEE isn't similar to a user-space crypto library. In our case TEE
is based on ARM TrustZone which only allows TEE communications to be
initiated from privileged mode. So why would you like to route
communications via user-mode (which is less secure) when we have
standardised TEE interface available in kernel?
The physical access guards for reading/writing the involved critical
memory are identical as far as I know? Layered security is generally a
good thing, and the userspace pass actually adds a layer, so not sure
which is really safer?
In my case the rerouting was to done generalize it. Any type of trust
source, anywhere.
quoted
quoted
Isn't actual purpose to have trusted keys is to protect user-space
from access to kernel keys in plain format? Doesn't user mode helper
defeat that purpose in one way or another?
Not really. CPU is in the user mode while running the code, but the
code or the secure keydata being is not available to the 'normal'
userspace. It's like microkernel service/driver this way. The usermode
driver is part of the kernel image and it runs on top of a invisible
rootfs.
Can you elaborate here with an example regarding how this user-mode
helper will securely communicate with a hardware based trust source
with other user-space processes denied access to that trust source?
The other user mode processes will never see the device node to open.
There is none in existence for them; it only exists in the ramfs based
root for the user mode helper.
--
Janne
From: Janne Karhunen <hidden> Date: 2019-08-01 08:30:22
On Thu, Aug 1, 2019 at 10:58 AM Sumit Garg [off-list ref] wrote:
quoted
Anyway, just my .02c. I guess having any new support in the kernel for
new trust sources is good and improvement from the current state. I
can certainly make my stuff work with your setup as well, what ever
people think is the best.
Yes your implementation can very well fit under trusted keys
abstraction framework without creating a new keytype: "ext-trusted".
The fundamental problem with the 'standardized kernel tee' still
exists - it will never be generic in real life. Getting all this in
the kernel will solve your problem and sell this particular product,
but it is quite unlikely to help that many users. If the security is
truly important to you, would you really trust any of this code to
someone else? In this day and age, I really doubt many do. Everyone
does their own thing, so this is why I really see all that as a
userspace problem.
--
Janne
On Thu, 1 Aug 2019 at 13:30, Janne Karhunen [off-list ref] wrote:
On Thu, Aug 1, 2019 at 10:40 AM Sumit Garg [off-list ref] wrote:
quoted
quoted
I chose the userspace plugin due to this, you can use userspace aids
to provide any type of service. Use the crypto library you desire to
do the magic you want.
Here TEE isn't similar to a user-space crypto library. In our case TEE
is based on ARM TrustZone which only allows TEE communications to be
initiated from privileged mode. So why would you like to route
communications via user-mode (which is less secure) when we have
standardised TEE interface available in kernel?
The physical access guards for reading/writing the involved critical
memory are identical as far as I know? Layered security is generally a
good thing, and the userspace pass actually adds a layer, so not sure
which is really safer?
AFAIK, layered security is better in case we move from lower privilege
level to higher privilege level rather than in reverse order.
-Sumit
In my case the rerouting was to done generalize it. Any type of trust
source, anywhere.
quoted
quoted
quoted
Isn't actual purpose to have trusted keys is to protect user-space
from access to kernel keys in plain format? Doesn't user mode helper
defeat that purpose in one way or another?
Not really. CPU is in the user mode while running the code, but the
code or the secure keydata being is not available to the 'normal'
userspace. It's like microkernel service/driver this way. The usermode
driver is part of the kernel image and it runs on top of a invisible
rootfs.
Can you elaborate here with an example regarding how this user-mode
helper will securely communicate with a hardware based trust source
with other user-space processes denied access to that trust source?
The other user mode processes will never see the device node to open.
There is none in existence for them; it only exists in the ramfs based
root for the user mode helper.
--
Janne
On Thu, 1 Aug 2019 at 14:00, Janne Karhunen [off-list ref] wrote:
On Thu, Aug 1, 2019 at 10:58 AM Sumit Garg [off-list ref] wrote:
quoted
quoted
Anyway, just my .02c. I guess having any new support in the kernel for
new trust sources is good and improvement from the current state. I
can certainly make my stuff work with your setup as well, what ever
people think is the best.
Yes your implementation can very well fit under trusted keys
abstraction framework without creating a new keytype: "ext-trusted".
The fundamental problem with the 'standardized kernel tee' still
exists - it will never be generic in real life. Getting all this in
the kernel will solve your problem and sell this particular product,
but it is quite unlikely to help that many users. If the security is
truly important to you, would you really trust any of this code to
someone else? In this day and age, I really doubt many do.
There are already multiple platforms supported by OP-TEE [1] which
could benefit from this trusted keys interface.
Everyone
does their own thing, so this is why I really see all that as a
userspace problem.
From: Janne Karhunen <hidden> Date: 2019-08-01 10:40:42
On Thu, Aug 1, 2019 at 1:00 PM Sumit Garg [off-list ref] wrote:
quoted
quoted
Here TEE isn't similar to a user-space crypto library. In our case TEE
is based on ARM TrustZone which only allows TEE communications to be
initiated from privileged mode. So why would you like to route
communications via user-mode (which is less secure) when we have
standardised TEE interface available in kernel?
The physical access guards for reading/writing the involved critical
memory are identical as far as I know? Layered security is generally a
good thing, and the userspace pass actually adds a layer, so not sure
which is really safer?
AFAIK, layered security is better in case we move from lower privilege
level to higher privilege level rather than in reverse order.
You can look at this in many ways. Another way to look at it is that
the services should be provided with the least amount of permissions
required for the task. Further you can containerize something, the
better.
As for your PLATFORMS support: it is all nice, but there is no way to
convince op-tee or any other tee to be adopted by many real users.
Every serious user can and will do their own thing, or at very best,
buy it from someone who did their own thing and is trusted. There is
zero chance that samsung, huawei, apple, nsa, google, rambus, payment
system vendors, .. would actually share the tee (or probably even the
interfaces). It is just too vital and people do not trust each other
anymore :(
Anyway, enough about the topic from my side. I guess people will tell
what they want, I'm fine with any, and it is all progress from the
current state :)
--
Janne
From: Jarkko Sakkinen <hidden> Date: 2019-08-04 20:48:19
On Tue, Jul 30, 2019 at 05:53:34PM +0530, Sumit Garg wrote:
tee: optee: allow kernel pages to register as shm
tee: enable support to register kernel memory
tee: add private login method for kernel clients
KEYS: trusted: Introduce TEE based Trusted Keys
doc: keys: Document usage of TEE based Trusted Keys
MAINTAINERS: Add entry for TEE based Trusted Keys
Skimmed through the patches. I think it is better to sort out the
current LKM dependency issue with trusted.ko and get TPM 1.2 and TPM 2.0
trusted keys code consolidated before it makes sense to really go detail
on this.
/Jarkko