Skip to contentSkip to conversation

tee: optee: do not check memref size on return from Secure World

PATCH New Jerome Forissier 3 participants 3 messages Mar 22, 2021 – Apr 1, 2021 2 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH 1/1 tee: optee: do not check memref size on return from Secure World

When Secure World returns, it may have changed the size attribute of the memory references passed as [in/out] parameters. The GlobalPlatform TEE Internal Core API specification does not restrict the values that this size can take. In particular, Secure World may increase the value to be larger than the size of the input buffer to indicate that it needs more.

Therefore, the size check in optee_from_msg_param() is incorrect and needs to be removed. This fixes a number of failed test cases in the GlobalPlatform TEE Initial Configuratiom Test Suite v2_0_0_0-2017_06_09 when OP-TEE is compiled without dynamic shared memory support (CFG_CORE_DYN_SHM=n).

---
 drivers/tee/optee/core.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/tee/optee/core.c +0 -10
index 319a1e701163..ddb8f9ecf307 100644
@@ -79,16 +79,6 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params,
 				return rc;
 			p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa;
 			p->u.memref.shm = shm;
-
-			/* Check that the memref is covered by the shm object */
-			if (p->u.memref.size) {
-				size_t o = p->u.memref.shm_offs +
-					   p->u.memref.size - 1;
-
-				rc = tee_shm_get_pa(shm, o, NULL);
-				if (rc)
-					return rc;
-			}
 			break;
 		case OPTEE_MSG_ATTR_TYPE_RMEM_INPUT:
 		case OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT:
Signature · 1 line
2.25.1

A message that is not in the archive (sent off-list or not yet received): 010001785986e9be-63aa88ce-3cf8-425f-87da-b2e3f84f6ef5-000000@email.amazonses.com

Reviewed-by
#3 lore raw
Quoted 13 lines · Jerome Forissier via OP-TEE

When Secure World returns, it may have changed the size attribute of the memory references passed as [in/out] parameters. The GlobalPlatform TEE Internal Core API specification does not restrict the values that this size can take. In particular, Secure World may increase the value to be larger than the size of the input buffer to indicate that it needs more.

Therefore, the size check in optee_from_msg_param() is incorrect and needs to be removed. This fixes a number of failed test cases in the GlobalPlatform TEE Initial Configuratiom Test Suite v2_0_0_0-2017_06_09 when OP-TEE is compiled without dynamic shared memory support (CFG_CORE_DYN_SHM=n).

Quoted 6 lines
---
 drivers/tee/optee/core.c | 10 ----------
 1 file changed, 10 deletions(-)

Looks good to me.

-Sumit

Quoted 24 lines
drivers/tee/optee/core.c +0 -11
index 319a1e701163..ddb8f9ecf307 100644
@@ -79,16 +79,6 @@ int optee_from_msg_param(struct tee_param *params, size_t num_params,
                                return rc;
                        p->u.memref.shm_offs = mp->u.tmem.buf_ptr - pa;
                        p->u.memref.shm = shm;
-
-                       /* Check that the memref is covered by the shm object */
-                       if (p->u.memref.size) {
-                               size_t o = p->u.memref.shm_offs +
-                                          p->u.memref.size - 1;
-
-                               rc = tee_shm_get_pa(shm, o, NULL);
-                               if (rc)
-                                       return rc;
-                       }
                        break;
                case OPTEE_MSG_ATTR_TYPE_RMEM_INPUT:
                case OPTEE_MSG_ATTR_TYPE_RMEM_OUTPUT:
--

2.25.1

#4 lore raw
Quoted 23 lines · Sumit Garg
Quoted 13 lines · Jerome Forissier via OP-TEE

When Secure World returns, it may have changed the size attribute of the memory references passed as [in/out] parameters. The GlobalPlatform TEE Internal Core API specification does not restrict the values that this size can take. In particular, Secure World may increase the value to be larger than the size of the input buffer to indicate that it needs more.

Therefore, the size check in optee_from_msg_param() is incorrect and needs to be removed. This fixes a number of failed test cases in the GlobalPlatform TEE Initial Configuratiom Test Suite v2_0_0_0-2017_06_09 when OP-TEE is compiled without dynamic shared memory support (CFG_CORE_DYN_SHM=n).

Quoted 6 lines
---
 drivers/tee/optee/core.c | 10 ----------
 1 file changed, 10 deletions(-)
Quoted 3 lines

Looks good to me.

Thanks, I'm picking this up.

Cheers,
Jens