These changes propose helper functions and macros to consolidate choice of
the conduit method among devices communicating with an secure world that
complies with SMCCC v1.0 but not SMCCC v1.1 or later. The new helper
functions mimic arm_smccc_1_1_*() function but for SMCCC v1.0 compliant
firmwares.
This series of changes updates several firmware drivers that each define a
conduit method whereas kernel drivers are expected to use the very same
conduit. This series obviously does not enforce these drivers to apply the
proposed changes but the interest of the first patch is this series is that
at least the PSCI driver upgrades as it will allow new drivers to benefit
from the early initialized PSCI conduit method.
Etienne Carriere (6):
firmware: helper functions for SMCCC v1.0 invocation conduit
firmware: psci: set SMCCC v1.0 conduit and use helpers functions
tee: optee: use SMCCC v1.0 helper functions
firmware: arm_sdei: use SMCCC v1.0 helper functions
firmware: stratix10: use SMCCC v1.0 helper functions
firmware: zynqmp: use SMCCC v1.0 helper functions
drivers/firmware/Makefile | 1 +
drivers/firmware/arm_sdei.c | 79 +++++---------
drivers/firmware/arm_smccc_conduit.c | 147 +++++++++++++++++++++++++++
drivers/firmware/psci/psci.c | 60 ++---------
drivers/firmware/stratix10-svc.c | 97 ++----------------
drivers/firmware/xilinx/zynqmp.c | 87 ++--------------
drivers/tee/optee/call.c | 14 +--
drivers/tee/optee/core.c | 85 ++++------------
drivers/tee/optee/optee_private.h | 4 +-
include/linux/arm-smccc.h | 106 +++++++++++++++++++
include/linux/psci.h | 1 -
11 files changed, 337 insertions(+), 344 deletions(-)
create mode 100644 drivers/firmware/arm_smccc_conduit.c
--
2.17.1
Update documentation for Trusted and Encrypted Keys with TEE as a new
trust source. Following is brief description of updates:
- Add a section to demostrate a list of supported devices along with
their security properties/guarantees.
- Add a key generation section.
- Updates for usage section including differences specific to a trust
source.
Signed-off-by: Sumit Garg <sumit.garg(a)linaro.org>
---
First of all apologies for the long delay due to my involvement on other
projects. So now I am able to pick up pending documentation work [1].
I have tried to list down comparison on the basis of security properties/
guarantees among TPM and a TEE as mentioned by Mimi here [2].
So I do look forward to comments and fruitful discussions.
[1] https://lkml.org/lkml/2019/11/4/886
[2] https://lore.kernel.org/linux-integrity/1568025601.4614.253.camel@linux.ibm…
Documentation/security/keys/trusted-encrypted.rst | 201 ++++++++++++++++++----
1 file changed, 170 insertions(+), 31 deletions(-)
diff --git a/Documentation/security/keys/trusted-encrypted.rst b/Documentation/security/keys/trusted-encrypted.rst
index 50ac8bc..c12ba47 100644
--- a/Documentation/security/keys/trusted-encrypted.rst
+++ b/Documentation/security/keys/trusted-encrypted.rst
@@ -6,30 +6,161 @@ Trusted and Encrypted Keys are two new key types added to the existing kernel
key ring service. Both of these new types are variable length symmetric keys,
and in both cases all keys are created in the kernel, and user space sees,
stores, and loads only encrypted blobs. Trusted Keys require the availability
-of a Trusted Platform Module (TPM) chip for greater security, while Encrypted
-Keys can be used on any system. All user level blobs, are displayed and loaded
-in hex ascii for convenience, and are integrity verified.
+of a Trust Source for greater security, while Encrypted Keys can be used on any
+system. All user level blobs, are displayed and loaded in hex ascii for
+convenience, and are integrity verified.
-Trusted Keys use a TPM both to generate and to seal the keys. Keys are sealed
-under a 2048 bit RSA key in the TPM, and optionally sealed to specified PCR
-(integrity measurement) values, and only unsealed by the TPM, if PCRs and blob
-integrity verifications match. A loaded Trusted Key can be updated with new
-(future) PCR values, so keys are easily migrated to new pcr values, such as
-when the kernel and initramfs are updated. The same key can have many saved
-blobs under different PCR values, so multiple boots are easily supported.
-TPM 1.2
--------
+Trust Source
+============
-By default, trusted keys are sealed under the SRK, which has the default
-authorization value (20 zeros). This can be set at takeownership time with the
-trouser's utility: "tpm_takeownership -u -z".
+Trust Source provides the sense of security for the Trusted Keys, on which
+basis Trusted Keys establishes a Trust model with its user. A Trust Source could
+differ from one system to another depending on its security requirements. It
+could be either an off-chip device or an on-chip device. Following section
+demostrates a list of supported devices along with their security properties/
+guarantees:
-TPM 2.0
--------
+ * Root of trust for storage
-The user must first create a storage key and make it persistent, so the key is
-available after reboot. This can be done using the following commands.
+ (1) TPM (Trusted Platform Module: hardware device)
+
+ Rooted to Storage Root Key (SRK) which never leaves the TPM that
+ provides crypto operation to establish root of trust for storage.
+
+ (2) TEE (Trusted Execution Environment: OP-TEE based on Arm TrustZone)
+
+ Rooted to Hardware Unique Key (HUK) which is generally burnt in on-chip
+ fuses and is accessible to TEE only.
+
+ * Execution isolation
+
+ (1) TPM
+
+ Fixed set of operations running in isolated execution environment.
+
+ (2) TEE
+
+ Customizable set of operations running in isolated execution
+ environment verified via Secure/Trusted boot process.
+
+ * Optional binding to platform integrity state
+
+ (1) TPM
+
+ Keys can be optionally sealed to specified PCR (integrity measurement)
+ values, and only unsealed by the TPM, if PCRs and blob integrity
+ verifications match. A loaded Trusted Key can be updated with new
+ (future) PCR values, so keys are easily migrated to new pcr values,
+ such as when the kernel and initramfs are updated. The same key can
+ have many saved blobs under different PCR values, so multiple boots are
+ easily supported.
+
+ (2) TEE
+
+ Relies on Secure/Trusted boot process for platform integrity. It can
+ be extended with TEE based measured boot process.
+
+ * On-chip versus off-chip
+
+ (1) TPM
+
+ Off-chip device connected via serial bus (like I2C, SPI etc.) exposing
+ physical access which represents an attack surface that can be
+ mitigated via tamper detection.
+
+ (2) TEE
+
+ On-chip functionality, immune to this attack surface.
+
+ * Memory attacks (DRAM based like attaching a bus monitor etc.)
+
+ (1) TPM
+
+ Immune to these attacks as it doesn’t make use of system DRAM.
+
+ (2) TEE
+
+ An implementation based on TrustZone protected DRAM is susceptible to
+ such attacks. In order to mitigate these attacks one needs to rely on
+ on-chip secure RAM to store secrets or have the entire TEE
+ implementation based on on-chip secure RAM. An alternative mitigation
+ would be to use encrypted DRAM.
+
+ * Side-channel attacks (cache, memory, CPU or time based)
+
+ (1) TPM
+
+ Immune to side-channel attacks as its resources are isolated from the
+ main OS.
+
+ (2) TEE
+
+ A careful implementation is required to mitigate against these attacks
+ for resources which are shared (eg. shared memory) with the main OS.
+ Cache and CPU based side-channel attacks can be mitigated via
+ invalidating caches and CPU registers during context switch to and from
+ the secure world.
+ To mitigate against time based attacks, one needs to have time
+ invariant implementations (like crypto algorithms etc.).
+
+ * Resistance to physical attacks (power analysis, electromagnetic emanation,
+ probes etc.)
+
+ (1) TPM
+
+ Provides limited protection utilizing tamper resistance.
+
+ (2) TEE
+
+ Provides no protection by itself, relies on the underlying platform for
+ features such as tamper resistance.
+
+
+Key Generation
+==============
+
+Trusted Keys
+------------
+
+New keys are created from trust source generated random numbers, and are
+encrypted/decrypted using trust source storage root key.
+
+ * TPM (hardware device) based RNG
+
+ Strength of random numbers may vary from one device manufacturer to
+ another.
+
+ * TEE (OP-TEE based on Arm TrustZone) based RNG
+
+ RNG is customizable as per platform needs. It can either be direct output
+ from platform specific hardware RNG or a software based Fortuna CSPRNG
+ which can be seeded via multiple entropy sources.
+
+Encrypted Keys
+--------------
+
+Encrypted keys do not depend on a trust source, and are faster, as they use AES
+for encryption/decryption. New keys are created from kernel generated random
+numbers, and are encrypted/decrypted using a specified ‘master’ key. The
+‘master’ key can either be a trusted-key or user-key type. The main disadvantage
+of encrypted keys is that if they are not rooted in a trusted key, they are only
+as secure as the user key encrypting them. The master user key should therefore
+be loaded in as secure a way as possible, preferably early in boot.
+
+
+Usage
+=====
+
+Trusted Keys usage: TPM
+-----------------------
+
+TPM 1.2: By default, trusted keys are sealed under the SRK, which has the
+default authorization value (20 zeros). This can be set at takeownership time
+with the trouser's utility: "tpm_takeownership -u -z".
+
+TPM 2.0: The user must first create a storage key and make it persistent, so the
+key is available after reboot. This can be done using the following commands.
With the IBM TSS 2 stack::
@@ -79,14 +210,21 @@ TPM_STORED_DATA format. The key length for new keys are always in bytes.
Trusted Keys can be 32 - 128 bytes (256 - 1024 bits), the upper limit is to fit
within the 2048 bit SRK (RSA) keylength, with all necessary structure/padding.
-Encrypted keys do not depend on a TPM, and are faster, as they use AES for
-encryption/decryption. New keys are created from kernel generated random
-numbers, and are encrypted/decrypted using a specified 'master' key. The
-'master' key can either be a trusted-key or user-key type. The main
-disadvantage of encrypted keys is that if they are not rooted in a trusted key,
-they are only as secure as the user key encrypting them. The master user key
-should therefore be loaded in as secure a way as possible, preferably early in
-boot.
+Trusted Keys usage: TEE
+-----------------------
+
+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).
+
+Encrypted Keys usage
+--------------------
The decrypted portion of encrypted keys can contain either a simple symmetric
key or a more complex structure. The format of the more complex structure is
@@ -104,8 +242,8 @@ Where::
format:= 'default | ecryptfs | enc32'
key-type:= 'trusted' | 'user'
-
Examples of trusted and encrypted key usage:
+--------------------------------------------
Create and save a trusted key named "kmk" of length 32 bytes.
@@ -151,7 +289,7 @@ Load a trusted key from the saved blob::
f1f8fff03ad0acb083725535636addb08d73dedb9832da198081e5deae84bfaf0409c22b
e4a8aea2b607ec96931e6f4d4fe563ba
-Reseal a trusted key under new pcr values::
+Reseal (TPM specific) a trusted key under new pcr values::
$ keyctl update 268728824 "update pcrinfo=`cat pcr.blob`"
$ keyctl print 268728824
@@ -165,11 +303,12 @@ Reseal a trusted key under new pcr values::
7ef6a24defe4846104209bf0c3eced7fa1a672ed5b125fc9d8cd88b476a658a4434644ef
df8ae9a178e9f83ba9f08d10fa47e4226b98b0702f06b3b8
+
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
trusted key provides strong guarantees that the EVM key has not been
-compromised by a user level problem, and when sealed to specific boot PCR
-values, protects against boot and offline attacks. Create and save an
+compromised by a user level problem, and when sealed to a platform integrity
+state, protects against boot and offline attacks. Create and save an
encrypted key "evm" using the above trusted key "kmk":
option 1: omitting 'format'::
--
2.7.4
Hi,
In September 2019 the ownership of OP-TEE was transferred from Linaro to
TrustedFirmware.org [1]. As part of the transition work there are a few
things that will change and one of them touches this mailinglist
<tee-dev(a)lists.linaro.org>, that will be discontinued.
This list was created to support the discussions and the upstreaming
efforts of the TEE driver and framework in Linux kernel. It has also
served as the "OP-TEE" mailinglist for discussions that hasn't been
taking place at GitHub.
So for Linux kernel related TEE discussions, we encourage you to send
email/patches to the addresses that you get by running:
$ cd <linux-kernel> && ./scripts/get_maintainer.pl drivers/tee
Note that, it'll still list the old "tee-dev" as one of the lists, but
we intend to send a patch updating that to get rid of it from the
kernels MAINTAINERS file. Meanwhile use the other emails coming out from
the get_maintainer's script.
And for people interested in OP-TEE we encourage you to register and
start using the new list that you can find here [2]. This new list
hosted by TrustedFirmware.org will serve as the main mailinglist for
OP-TEE discussions. It's an open and public list.
We've also updated the documentation for OP-TEE with corresponding
changes, i.e., the contact information in terms of emails to use are
updated (and no longer going directly to Linaro).
[1] https://www.trustedfirmware.org/blog/op-tee-moving-into-trusted-firmware/
[2] https://lists.trustedfirmware.org/mailman/listinfo/op-tee
--
Regards,
Joakim
Hello maintainers,
I'm trying to boot OP-TEE in custom imx8qm-based board. As I can see from
OP-TEE sources, it is available for this type of SOC. But, I can't find any
instructions on how to actually load and boot it.
Would you please share inputs?
--
WBR Volodymyr Babchuk aka lorc [+380976646013]
mailto: vlad.babchuk(a)gmail.com
Earlier this patch-set was part of TEE Trusted keys patch-set [1]. But
since these are completely independent enhancements for TEE kernel
client interface which can be merged separately while TEE Trusted keys
discussions are ongoing.
Patch #1 enables support for registered kernel shared memory with TEE.
Patch #2 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.
[1] https://lkml.org/lkml/2019/10/31/430
Changes in v5:
- Misc. renaming of variables.
Sumit Garg (2):
tee: enable support to register kernel memory
tee: add private login method for kernel clients
drivers/tee/tee_core.c | 6 ++++++
drivers/tee/tee_shm.c | 28 +++++++++++++++++++++++++---
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 ++++++++
4 files changed, 40 insertions(+), 3 deletions(-)
--
2.7.4
Earlier this patch-set was part of TEE Trusted keys patch-set [1]. But
since these are completely independent enhancements for TEE kernel
client interface which can be merged separately while TEE Trusted keys
discussions are ongoing.
Patch #1 enables support for registered kernel shared memory with TEE.
Patch #2 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.
[1] https://lkml.org/lkml/2019/10/31/430
Sumit Garg (2):
tee: enable support to register kernel memory
tee: add private login method for kernel clients
drivers/tee/tee_core.c | 6 ++++++
drivers/tee/tee_shm.c | 26 ++++++++++++++++++++++++--
include/linux/tee_drv.h | 1 +
include/uapi/linux/tee.h | 8 ++++++++
4 files changed, 39 insertions(+), 2 deletions(-)
--
2.7.4
Hello arm-soc maintainers,
Please pull this AMDTEE driver fix for an out of bounds read in
find_session()
Thanks,
Jens
The following changes since commit 11a48a5a18c63fd7621bb050228cebf13566e4d8:
Linux 5.6-rc2 (2020-02-16 13:16:59 -0800)
are available in the Git repository at:
https://git.linaro.org/people/jens.wiklander/linux-tee.git tags/tee-amdtee-fix2-for-5.6
for you to fetch changes up to 36fa3e50085e3858dd506e4431b9abd1bcb1f542:
tee: amdtee: out of bounds read in find_session() (2020-03-10 08:12:04 +0100)
----------------------------------------------------------------
tee: amdtee: out of bounds read in find_session()
----------------------------------------------------------------
Dan Carpenter (1):
tee: amdtee: out of bounds read in find_session()
drivers/tee/amdtee/core.c | 3 +++
1 file changed, 3 insertions(+)
The "index" is a user provided value from 0-USHRT_MAX. If it's over
TEE_NUM_SESSIONS (31) then it results in an out of bounds read when we
call test_bit(index, sess->sess_mask).
Fixes: 757cc3e9ff1d ("tee: add AMD-TEE driver")
Signed-off-by: Dan Carpenter <dan.carpenter(a)oracle.com>
---
drivers/tee/amdtee/core.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c
index 6370bb55f512..dbc238c7c263 100644
--- a/drivers/tee/amdtee/core.c
+++ b/drivers/tee/amdtee/core.c
@@ -139,6 +139,9 @@ static struct amdtee_session *find_session(struct amdtee_context_data *ctxdata,
u32 index = get_session_index(session);
struct amdtee_session *sess;
+ if (index >= TEE_NUM_SESSIONS)
+ return NULL;
+
list_for_each_entry(sess, &ctxdata->sess_list, list_node)
if (ta_handle == sess->ta_handle &&
test_bit(index, sess->sess_mask))
--
2.11.0
Hello arm-soc maintainers,
Please pull these cleanup patches for shared memory in the TEE subsystem.
Thanks,
Jens
The following changes since commit 11a48a5a18c63fd7621bb050228cebf13566e4d8:
Linux 5.6-rc2 (2020-02-16 13:16:59 -0800)
are available in the Git repository at:
https://git.linaro.org/people/jens.wiklander/linux-tee.git tags/tee-cleanup-for-5.7
for you to fetch changes up to 758ecf13a41a9dc4f019c1381566132ef46c08ee:
tee: tee_shm_op_mmap(): use TEE_SHM_USER_MAPPED (2020-02-28 13:37:42 +0100)
----------------------------------------------------------------
Cleanup shared memory handing in TEE subsystem
The highlights are:
- Removing redundant or unused fields in struct tee_shm
- Only assign userspace shm IDs for shared memory objects originating from
user space
----------------------------------------------------------------
Jens Wiklander (5):
tee: remove linked list of struct tee_shm
tee: remove unused tee_shm_priv_alloc()
tee: don't assign shm id for private shms
tee: remove redundant teedev in struct tee_shm
tee: tee_shm_op_mmap(): use TEE_SHM_USER_MAPPED
drivers/tee/tee_core.c | 1 -
drivers/tee/tee_private.h | 3 +-
drivers/tee/tee_shm.c | 85 +++++++++++++----------------------------------
include/linux/tee_drv.h | 19 +----------
4 files changed, 27 insertions(+), 81 deletions(-)
Hi,
As SHM DMA memory is not unregistered by tee_shm_free() Linux tee driver
API in kexec path (Case A), we 're facing lot of issues including failures
in OP-TEE xtest. Can any one of you suggest the solution.
*Problem Description*
Case A
If tee_shm_free() is called in shutdown() of Linux tee_client_driver and
kexec kernel is booted, shutdown() & tee_shm_free() are invoked but
tee_shm_release() is not invoked on DMA SHM buffer.
Case B
If tee_shm_free() is called on SHM DMA buffer previously allocated from
rmmod path[module_exit()]
It unregisters the SHM memory and sends OPTEE_MSG_CMD_UNREGISTER_SHM to
optee_os through optee_shm_unregister().
*Call Sequence*
Case A: kexec path
*.shutdown()-->tee_shm_free()-->dma_buf_put()*
Case B: rmmod path
*.shutdown()-->tee_shm_free()-->tee_shm_release()-->optee_shm_unregister()
-->optee_do_call_with_arg() [cmd = OPTEE_MSG_CMD_UNREGISTER_SHM]*
*Repercussions of the issue: xtest failure due to out of memory*
If we register a big buffer of say 8MB in Linux tee client driver, if the
same memory is not unregistered, it can cause overhead of 2*1024*8 = 16KB
memory overhead for shm page book keeping data structures calloc'd in
optee_os. After kexec it causes 16 +16=32KB which significant memory on a
minimal heap of size, say 64KB. This causes failures with asymmetric crypto
operations of xtest due to out of memory error.
*Context*
In Linux kernel tee_client_driver probe() we 're calling tee_shm_alloc()
with flags=TEE_SHM_MAPPED | TEE_SHM_DMA_BUF
In remove() & shutdown() functions of the driver: we 're calling
tee_shm_free() on shm reference allocated in probe.
--
Thanks & Regards,
Rajesh