Skip to content

liburing.h: fix integer overflow in recvmsg_cmsg_nexthdr#1587

Open
rootvector2 wants to merge 1 commit into
axboe:masterfrom
rootvector2:recvmsg-cmsg-nexthdr-overflow
Open

liburing.h: fix integer overflow in recvmsg_cmsg_nexthdr#1587
rootvector2 wants to merge 1 commit into
axboe:masterfrom
rootvector2:recvmsg-cmsg-nexthdr-overflow

Conversation

@rootvector2
Copy link
Copy Markdown
Contributor

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.

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>
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.

1 participant