-
Notifications
You must be signed in to change notification settings - Fork 240
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
tee_api: check for session->ctx before dereferencing it #60
Conversation
We need to check if session->ctx is valid pointer befor dereferncing it. Otherways it will lead to segfalut which is not desired behaviour for library users. This fill fix issue with segfaulting xtest when TEEC_OpenSession fails. Signed-off-by: Volodymyr Babchuk <vlad.babchuk@gmail.com>
Why do this? The client API is not supposed to be called with an invalid session or return an error status if that happens. I mean, why check ctx against zero when there are so many invalid virtual address values... In fact rather than adding tests, I would rather remove the NULL checks on the |
@jforissier , yes, that is the case. You can feed So, I have exactly opposite idea: lets leave |
@lorc there is no way you can make the client API 'foolproof', reliably, and safely. Adding a magic value to the session structure will only catch a limited number of invalid sessions. What if the I checked the GP spec, and there is nothing wrong with our current behavior. Only TEEC_CloseSession() is expected to check for So I stand on my position: no new validity checks, and let's keep the NULL checks on the PS: you mentioned segfaults in |
You're right Jerome. It doesn't become more robust with these added checks, what we do get is more unpredictable behavior. I think everyone prefers an early consistent crash compared to a late one that needs certain stuff to happen first. |
@jforissier Okay, I see your point. I'll rework xtest then. |
@lorc thank you. |
Library ckteec will implement the PKCS#11 API using the PKCS11 trusted application executing in OP-TEE as backend token. Implement pkcs11.h header file that partially covers the PKCS#11 specification. Resources initially planned to be supported are defined. The header will need to be updated with remaining PKCS#11 definition when related support will be implemented. Signed-off-by: Etienne Carriere <etienne.carriere@linaro.org> Check patch issues: ERROR: need consistent spacing around '*' (ctx:WxV) OP-TEE#86: FILE: libckteec/include/pkcs11.h:29: +typedef CK_BYTE *CK_BYTE_PTR; ^ WARNING: Prefer 'unsigned long' over 'unsigned long int' as the int is unnecessary OP-TEE#48: FILE: libckteec/include/pkcs11.h:22: +typedef unsigned long int CK_ULONG; ERROR: "foo * bar" should be "foo *bar" OP-TEE#60: FILE: libckteec/include/pkcs11.h:34: +typedef void * CK_VOID_PTR; WARNING: do not add new typedefs #424: FILE: libckteec/include/pkcs11.h:398: +typedef struct CK_AES_CBC_ENCRYPT_DATA_PARAMS CK_AES_CBC_ENCRYPT_DATA_PARAMS; WARNING: space prohibited between function name and open parenthesis '(' #693: FILE: libckteec/include/pkcs11.h:667: +typedef CK_RV (* CK_NOTIFY)(CK_SESSION_HANDLE hSession, ERROR: space prohibited after that '*' (ctx:BxW) #693: FILE: libckteec/include/pkcs11.h:667: +typedef CK_RV (* CK_NOTIFY)(CK_SESSION_HANDLE hSession, WARNING: Missing a blank line after declarations #708: FILE: libckteec/include/pkcs11.h:682: + CK_VERSION version; + CK_RV (*C_Initialize)(CK_VOID_PTR pInitArgs); WARNING: space prohibited between function name and open parenthesis '(' #712: FILE: libckteec/include/pkcs11.h:686: + CK_RV (*C_GetSlotList)(CK_BBOOL tokenPresent,
We need to check if session->ctx is valid pointer befor dereferncing it.
Otherways it will lead to segfalut which is not desired behaviour for
library users.
This fill fix issue with segfaulting xtest when TEEC_OpenSession fails.
Signed-off-by: Volodymyr Babchuk vlad.babchuk@gmail.com