Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crypto API: make sure TEE_Attribute parameters are readable #167

Merged
1 commit merged into from
Feb 12, 2015

Conversation

jforissier
Copy link
Contributor

Fixes #161.

Services that take a TEE_Attribute array for input must check that the
memory is readable before using it. This is accomplished by
check_attr_read_access(), which is either called directly by the system
service or by tee_svc_cryp_check_attr(). Buffers pointed to by 'reference'
attributes are also validated.
Then, it is no longer necessary to check accessibility in other
functions such as tee_svc_cryp_obj_store_attr_raw().

Signed-off-by: Jerome Forissier jerome.forissier@linaro.org

@pascal-brand38
Copy link
Contributor

xtest 7537 is wrong :(

This test does

ADBG_EXPECT(c, TEE_ERROR_BAD_PARAMETERS, Invoke_InitObjectAndAttributes(c, SESSION01, CMD_InitObjectAndAttributes, CASE_POPULATE_BAD_PARAM, TEE_TYPE_DES3, SIZE_DES3_192, TEE_ATTR_SECRET_VALUE, TEE_ATTR_DES3_192_VALUE01, sizeof(TEE_ATTR_DES3_192_VALUE01), TEE_ATTR_NONE, TEE_ATTR_VALUE_NONE, sizeof(TEE_ATTR_VALUE_NONE), TEE_ATTR_NONE, TEE_ATTR_VALUE_NONE, sizeof(TEE_ATTR_VALUE_NONE), TEE_ATTR_NONE, TEE_ATTR_VALUE_NONE, sizeof(TEE_ATTR_VALUE_NONE), TEE_ATTR_NONE, TEE_ATTR_VALUE_NONE, sizeof(TEE_ATTR_VALUE_NONE)));

This command panics the TA because of the change in tee_svc_cryp_check_attr(). check_attr_read_access() is called too earlier. Indeed, this test wait for a BAD_PARAMETER which is returned by tee_svc_cryp_obj_store_attr_raw(). In such a case, it does not panic.

@jforissier
Copy link
Contributor Author

So if I understand correctly, the test injects two errors: bad parameter value and invalid memory reference. And my patch checks memory access fist, when it should check the values first. Is it correct? I don't have test 7537 in my test suite and the GP spec doesn't have much details about parameter checking.

@pascal-brand38
Copy link
Contributor

A bug has been entered in GP. In the meantime, I propose to accept this patch if the XML test file is fixed with respect to this.

@jforissier Could you send me and Cedric the patch of the XML file to that the tests run ok?

Reviewed-by: Pascal Brand <pascal.brand@linaro.org>

@jforissier
Copy link
Contributor Author

I have updated optee_test to take into account the new behavior introduced
by this PR. Please check branch optee-pr-167.

  • XTEST_TEE_7537 9d-5c-6a
    ERR [629] TEEC:TEEC_InvokeCommand:402: Function returns with [-53212]
    XTEST_TEE_7537 OK

@jforissier
Copy link
Contributor Author

Rebased with tags applied.

@pascal-brand38
Copy link
Contributor

@jforissier can you rebase?

Fixes OP-TEE#161.

Services that take a TEE_Attribute array for input must check that the
memory is readable before using it. This is accomplished by
check_attr_read_access(), which is either called directly by the system
service or by tee_svc_cryp_check_attr(). Buffers pointed to by 'reference'
attributes are also validated.
Then, it is no longer necessary to check accessibility in other
functions such as tee_svc_cryp_obj_store_attr_raw().

Signed-off-by: Jerome Forissier <jerome.forissier@linaro.org>
Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org>
Reviewed-by: Pascal Brand <pascal.brand@linaro.org>
@ghost ghost merged commit c2e1a05 into OP-TEE:master Feb 12, 2015
@jforissier jforissier deleted the check-attr branch March 31, 2015 18:45
This pull request was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

tee_svc_cryp.c lacks accessibility checks on user-supplied TEE_Attributes
2 participants