liburing.h: fix integer overflow in recvmsg_cmsg_nexthdr#1587
Open
rootvector2 wants to merge 1 commit into
Open
liburing.h: fix integer overflow in recvmsg_cmsg_nexthdr#1587rootvector2 wants to merge 1 commit into
rootvector2 wants to merge 1 commit into
Conversation
io_uring_recvmsg_cmsg_nexthdr() advances cmsg by CMSG_ALIGN(cmsg_len) before any bounds check. A cmsg_len near SIZE_MAX makes CMSG_ALIGN() wrap to a small value, or the pointer addition wrap past the control buffer, so the following '> end' checks pass and the helper returns a wild cmsg whose cmsg_len is then dereferenced. Bound the aligned length against the remaining control space before advancing, matching the overflow hardening already done in recvmsg_validate. Signed-off-by: rootvector2 <dxbnaveed.k@gmail.com>
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.
Noticed recvmsg_cmsg_nexthdr advances cmsg by CMSG_ALIGN(cmsg_len) before any bounds check. A cmsg_len near SIZE_MAX makes the align wrap to a small value, or the pointer add wrap past the control buffer, so the '> end' checks pass and the wild cmsg gets returned and dereferenced. Bound the aligned length against the remaining control space before advancing, the same way the recent recvmsg_validate fix did.