libnvme: mi: reject async events that carry the RSP bit in nmp - #3916
Merged
Conversation
The ROR check in libnvme_mi_async_read() was written as
!(resp->hdr->nmp & ~(NVME_MI_ROR_REQ << 7))
Since NVME_MI_ROR_REQ is 0, ~(0 << 7) is all-ones and the
expression reduces to !nmp: an event message is rejected only when
*all* nmp bits are clear, while a message that actually has the
response bit (RSP, bit 7) set sails through - the exact polarity of
what the log message intends (and what the sibling check in the
command-response verify does).
Test bit 7 directly with NVME_MI_ROR_RSP.
Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
igaw
force-pushed
the
fix-aem-ror-check
branch
from
August 26, 2026 13:56
274451e to
fc03d13
Compare
Collaborator
|
dropped libnvme 1 reference. |
There was a problem hiding this comment.
Pull request overview
Fixes an inverted Request-or-Response (ROR) bit check in the NVMe-MI async event read path so that incoming async events with the RSP bit set in NMP are correctly rejected (matching the intent of the existing error handling and the command/response verification logic elsewhere in mi.c).
Changes:
- Replace the broken
~(NVME_MI_ROR_REQ << 7)-based check with an explicit test for the RSP bit viaNVME_MI_ROR_RSP. - Ensure async events with
nmpbit 7 set are rejected as invalid inlibnvme_mi_async_read().
Suppressed comments (1)
libnvme/src/nvme/mi.c:524
- The debug message here is tautological ("in response indicates a response") and doesn’t clearly explain what is wrong with the incoming async event. Since this path rejects messages with the RSP bit set in NMP, the log should explicitly mention the unexpected RSP bit and ideally include the observed NMP value to aid troubleshooting.
if (resp->hdr->nmp & (NVME_MI_ROR_RSP << 7)) {
libnvme_msg(ep->ctx, LIBNVME_LOG_DEBUG,
"ROR value in response indicates a response\n");
return -EIO;
}
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
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
Port of linux-nvme/libnvme#1131. The same inverted ROR check reached this tree:
With
NVME_MI_ROR_REQ == 0the expression reduces to!nmp: a message is rejected only when all ofnmpis clear, while a message with the RSP bit (bit 7) set — precisely the condition the error message describes — passes.Fix
Test bit 7 with
NVME_MI_ROR_RSP, matching the polarity of the command-response verification a few dozen lines down.Testing