core: spmc: fix tx buffer overrun in the retrieve response - #7960
Merged
Conversation
jenswikl
reviewed
Aug 28, 2026
anarchyj
force-pushed
the
anarchyj-patch-3
branch
from
August 28, 2026 07:54
b65c00f to
4cca1a4
Compare
Contributor
|
|
check_retrieve_request() decides whether the FFA_MEM_RETRIEVE_RESP fits in the endpoint's tx buffer by subtracting the requester-supplied mem_access_size from the buffer length. create_retrieve_response() instead writes the response using the SPMC's own access descriptor size (struct ffa_mem_access_1_0 for FF-A <= 1.1, struct ffa_mem_access_1_2 for 1.2), and its address range loop writes one struct ffa_address_range per shared region without checking the space left. An endpoint that retrieves with a mem_access_size smaller than the size the SPMC writes makes the estimate over-count the free space, so the check passes while the response is written past the end of the tx buffer. A malicious S-EL0 SP can drive this by negotiating FF-A 1.2, using a mem_access_size of sizeof(struct ffa_mem_access_common) and controlling how many regions the memory was shared with, causing the S-EL1 SPMC to write out of bounds into the SP's tx buffer. Reserve the space using the same access descriptor size create_retrieve_response() writes, so the estimate matches the write. Fixes: d45fc14 ("core: ffa: add missing field in memory access descriptor") Signed-off-by: Guled Hasan <Law.Zoldyck@proton.me> Reviewed-by: Jens Wiklander <jens.wiklander@oss.qualcomm.com>
anarchyj
force-pushed
the
anarchyj-patch-3
branch
from
August 28, 2026 09:43
4cca1a4 to
e8655df
Compare
Contributor
Author
|
Applied. |
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.
check_retrieve_request() decides whether the FFA_MEM_RETRIEVE_RESP fits in the endpoint's tx buffer by subtracting the requester-supplied mem_access_size from the buffer length. create_retrieve_response() instead writes the response using the SPMC's own access descriptor size (struct ffa_mem_access_1_0 for FF-A <= 1.1, struct ffa_mem_access_1_2 for 1.2), and its address range loop writes one struct ffa_address_range per shared region without checking the space left.
An endpoint that retrieves with a mem_access_size smaller than the size the SPMC writes makes the estimate over-count the free space, so the check passes while the response is written past the end of the tx buffer. A malicious S-EL0 SP can drive this by negotiating FF-A 1.2, using a mem_access_size of sizeof(struct ffa_mem_access_common) and controlling how many regions the memory was shared with, causing the S-EL1 SPMC to write out of bounds into the SP's tx buffer.
Reserve the space using the same access descriptor size create_retrieve_response() writes, so the estimate matches the write.
Fixes: d45fc14 ("core: ffa: add missing field in memory access descriptor")