libckteec: prevent integer overflow in shared memory allocations#417
Open
karnakarreddi wants to merge 2 commits into
Open
libckteec: prevent integer overflow in shared memory allocations#417karnakarreddi wants to merge 2 commits into
karnakarreddi wants to merge 2 commits into
Conversation
etienne-lms
reviewed
May 18, 2026
etienne-lms
left a comment
Contributor
There was a problem hiding this comment.
For commit "libckteec: add {ADD|SUB|MUL}_OVERFLOW() helper macros":
- Could break the message message into several lines, 80 char/line max IIR?
(ditto for the 2nd commit) - Could you add a reference from where the macros implementation were fetched from, e.g. OP-TEE OS Github URLs? It would be easier for one to find the source.
- With
Co-developed-by, you need to also provide the co-developperSigned-off-bytag. Alternatively useCo-authored-by, that do not require an added S-o-b tag.
336afb4 to
50b4e52
Compare
Author
Thanks for the review, @etienne-lms. I've addressed all three points and force-pushed the updated branch. Please take another look when you have a moment. |
Add ADD_OVERFLOW(), SUB_OVERFLOW() and MUL_OVERFLOW() helper macros dumped from optee_os util.h [1] and compiler.h [3] where released under the same BSD-2-Clause license terms used in libckteec implementation. Link: https://github.com/OP-TEE/optee_os/blob/4.10.0/lib/libutils/ext/include/util.h [1] Link: https://github.com/OP-TEE/optee_os/blob/4.10.0/lib/libutils/ext/include/compiler.h [2] Co-authored-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: karnakarreddi <thoorpukarnakar@gmail.com>
Guard against overflow in buffer size before allocations and when serializing data sent to the TA. The overflow guards return CKR_ARGUMENTS_BAD via the function's existing bail/out cleanup label so the serializer buffer allocated by serialize_ck_attributes() and serialize_ck_mecha_params() is released; the MUL_OVERFLOW() check in ck_find_objects() returns directly as nothing is allocated above it. Co-authored-by: Etienne Carriere <etienne.carriere@st.com> Signed-off-by: karnakarreddi <thoorpukarnakar@gmail.com>
50b4e52 to
5fd5c03
Compare
|
This pull request has been marked as a stale pull request because it has been open (more than) 30 days with no activity. Remove the stale label or add a comment, otherwise this pull request will automatically be closed in 5 days. Note, that you can always re-open a closed issue at any time. |
Contributor
|
@etienne-lms, are you OK with this PR? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes integer overflow in several libckteec callers of ckteec_alloc_shm() and in the PKCS#11 serializer.