Skip to content

libnvme: size the AEM ack recv buffer to what's actually left - #3912

Merged
igaw merged 1 commit into
linux-nvme:masterfrom
prabhakarpujeri:fix-aem-ack-buffer-size
Aug 26, 2026
Merged

libnvme: size the AEM ack recv buffer to what's actually left#3912
igaw merged 1 commit into
linux-nvme:masterfrom
prabhakarpujeri:fix-aem-ack-buffer-size

Conversation

@prabhakarpujeri

Copy link
Copy Markdown

Problem

Same issue as fixed in libnvme 1.x in linux-nvme/libnvme#1122: libnvme_mi_aem_process() receives the async event into response_buffer (4096 bytes), then issues the ACK read with the data pointer set to &response->occ_list_hdroffsetof(occ_list_hdr) into the buffer — but passes sizeof(response_buffer) as the capacity:

response_len = sizeof(response_buffer);
rc = libnvme_mi_aem_ack(ep, &response->occ_list_hdr, &response_len);

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_buffer sites 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

  • Full meson suite green (build + 99 passed; crypto-util skips on this host due to missing OpenSSL, also on pristine master).
  • MI paths are hardware-bound; validated by review against the AEM spec layout and the 1.x correspondence (mi: fix AEM ack response buffer size libnvme#1122).

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
igaw force-pushed the fix-aem-ack-buffer-size branch from 4e91fba to 05245bd Compare August 26, 2026 13:11
@igaw

igaw commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

removed libnvme 1 reference.

@igaw
igaw merged commit 6627cff into linux-nvme:master Aug 26, 2026
30 checks passed
@igaw

igaw commented Aug 26, 2026

Copy link
Copy Markdown
Collaborator

thanks!

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.

2 participants