libnvme: reject oversized discovery log record counts - #3911
Merged
Conversation
discovery log fetch trusts the device-supplied numrec field and
computes the buffer size as
entries_size = sizeof(*log->entries) * numrec;
log = libnvme_alloc(sizeof(*log) + entries_size);
A malicious or malfunctioning discovery controller can answer with
a numrec large enough to wrap entries_size (or the subsequent
addition), yielding a tiny allocation while the copy into
log->entries proceeds with attacker-controlled length - heap
overflow.
Guard the multiply by rejecting numrec values that cannot fit in
size_t, before allocating.
Signed-off-by: Prabhakar Pujeri <prabhakar.pujeri@dell.com>
igaw
force-pushed
the
fix-numrec-disc-log
branch
from
August 26, 2026 13:05
eb46329 to
13f8933
Compare
Collaborator
|
removed libnvme reference in commit message |
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
libnvme3 keeps the local libnvme 1.x issue (fixed upstream in linux-nvme/libnvme#1121):
nvme_discovery_log()trusts the device-suppliednumrec:A controller returning large
numrecmakesentries_size(or thesizeof(*log) +addition) wrap, producing a small allocation whilelog->entriesgets filled with attacker-controlled length — heap overflow.Fix
Reject
numrecvalues that can't fit insize_tbefore allocating (same shape as the 1.x fix).Testing
crypto-utilskip is env-related: OpenSSL absent on this host, also on pristine master).