Repository navigation
net/usrsock: fail sendmsg when the sum of iov_len overflows - #21434
Merged
xiaoxiang781216 merged 1 commit intoNov 5, 2026
Merged
Conversation
Swatantra-66
requested review from
jerpelea and
xiaoxiang781216
as code owners
November 3, 2026 23:31
|
Swatantra-66
force-pushed
the
fix/usrsock-sendmsg-overflow
branch
from
November 4, 2026 11:43
689bb41 to
f0ce5d1
Compare
jerpelea
previously approved these changes
Nov 4, 2026
xiaoxiang781216
previously approved these changes
Nov 4, 2026
casaroli
reviewed
Nov 4, 2026
Swatantra-66
dismissed stale reviews from xiaoxiang781216 and jerpelea
via
November 4, 2026 14:49
5e12061
Swatantra-66
force-pushed
the
fix/usrsock-sendmsg-overflow
branch
from
November 4, 2026 14:49
f0ce5d1 to
5e12061
Compare
With more than one iovec, usrsock_sendmsg() adds the iov_len values into req.buflen. If the sum overflows, it silently wraps around, and the subsequent check (req.buflen > UINT32_MAX) was dead code because req.buflen is a uint32_t. Fail with -EINVAL when the sum of iov_len values exceeds MIN(SSIZE_MAX, UINT32_MAX). This enforces the POSIX IEEE Std 1003.1 limit (SSIZE_MAX) on 32-bit platforms and prevents 32-bit wrap-around of req.buflen (UINT32_MAX) on 64-bit platforms. Signed-off-by: Swatantra Yadav <maverickswatantra@gmail.com> Assisted-by: Google Gemini
Swatantra-66
force-pushed
the
fix/usrsock-sendmsg-overflow
branch
from
November 4, 2026 15:54
5e12061 to
ea46d80
Compare
xiaoxiang781216
approved these changes
Nov 4, 2026
casaroli
approved these changes
Nov 4, 2026
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.
Summary
Fails
sendmsg()innet/usrsockwith-EINVALwhen the sum ofiov_lenvalues exceedsMIN(SSIZE_MAX, UINT32_MAX).Previously,
usrsock_sendmsg()accumulatediov_lenvalues directly intoreq.buflen(uint32_t) without overflow detection. If the sum wrapped around, the subsequent check:was dead code because
req.buflenis typeduint32_tand can never exceedUINT32_MAX. This allowed silent integer wrap-around and protocol desync when queuing large scatter/gather vectors.The check enforces
(size_t)MIN(SSIZE_MAX, UINT32_MAX) - req.buflen:SSIZE_MAX= 2 GB), matchingnet/inet(commit 3671f94) andfs/vfs/fs_uio.c.SSIZE_MAXis 8 Exabytes, so the bound clamps toUINT32_MAX(4 GB) to preventreq.buflen(uint32_t) from silently wrapping around.Impact
sendmsg()over usrsock. Prevents silent integer wrap-around and protocol corruption when the sum ofiov_lenvalues exceedsSSIZE_MAXorUINT32_MAX.Testing
./tools/checkpatch.sh -c -u -m -g upstream/master..HEAD(exit code 0, all checks passed includingcodespell,cvt2utf, commit message validator, andnxstyle).net/usrsock/usrsock_sendmsg.chas 0 errors and 0 warnings withnxstyle.-Werror=sign-compareon both 32-bit and 64-bit targets.