libnvme: size the AEM ack recv buffer to what's actually left - #3912
Merged
Conversation
libnvme_mi_aem_process() receives the AE into response_buffer, then issues the ack read with the data pointer set to &response->occ_list_hdr - offsetof() of a few dozen bytes into the buffer - but passes sizeof(response_buffer) as the capacity. If the ack payload approaches the stated capacity, the write runs ~offsetof(occ_list_hdr) bytes past the 4096-byte buffer. Use sizeof(response_buffer) - offsetof(struct nvme_mi_aem_msg, occ_list_hdr). The other two 4096-byte response_buffer sites in the file point their buffer at offset 0 and are correct. Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
igaw
force-pushed
the
fix-aem-ack-buffer-size
branch
from
August 26, 2026 13:11
4e91fba to
05245bd
Compare
Collaborator
|
removed libnvme 1 reference. |
Collaborator
|
thanks! |
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.
Problem
Same issue as fixed in libnvme 1.x in linux-nvme/libnvme#1122:
libnvme_mi_aem_process()receives the async event intoresponse_buffer(4096 bytes), then issues the ACK read with the data pointer set to&response->occ_list_hdr—offsetof(occ_list_hdr)into the buffer — but passessizeof(response_buffer)as the capacity:If the ACK payload approaches the stated capacity, the transport writes up to
~offsetof(struct nvme_mi_aem_msg, occ_list_hdr)bytes past the end of the 4096-byte stack buffer.The other two
response_buffersites in the file point at the buffer base and are correct.Fix
Pass the actual remaining capacity:
sizeof(response_buffer) - offsetof(struct nvme_mi_aem_msg, occ_list_hdr).Testing
crypto-utilskips on this host due to missing OpenSSL, also on pristine master).