-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[0.2] Backports #4919
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
[0.2] Backports #4919
Conversation
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
This change makes sure that the header of `next` is within max, returning null if not. This is similar to how `glibc` does it. No checks were previously being done to assert that `next as usize + size_of::<cmsghdr>() < max`. Wrapping offset calculations could then lead to buffer over-reads in the following `(*next).cmsg_len`. [glibc ref](https://github.com/bminor/glibc/blob/b71d59074b98ad4abd23c136ec9ad4c26e29ee6d/sysdeps/unix/sysv/linux/cmsg_nxthdr.c#L49-L51) (backport <rust-lang#4903>) (cherry picked from commit cdc2077)
Likely written to make assertions in the unsound CMSG_NXTHDR implementations introduced in rust-lang#1235. CMSG_NXTHDR(mhdr, current_cmsghdr) should not be concerned with the value next_cmsghdr.cmsg_len, which the previous implementation did. (backport <rust-lang#4903>) (cherry picked from commit 1e43edb)
Setting `(*pcmsghdr).cmsg_len = cmsg_len as _;` when cmsg_len ranges from 0 to 64 is invalid as it must always be `>= size_of::<cmsghdr>()`, rounded up to the nearest alignment boundary. Some implementations (notably glbic) do check that `cmsg_len >= size_of::<cmsghdr>()` in `CMSG_NXTHDR`, returning null if so. But this is more so an extra precaution that is not mentioned in the POSIX 1003.1-2024. It can therefore not be relied on for tests executed on multiple platforms. The change also removes the ignoring of some testvalues when targeting AIX. (backport <rust-lang#4903>) (cherry picked from commit f391df3)
(backport <rust-lang#4903>) (cherry picked from commit 99280f2)
(backport <rust-lang#4903>) (cherry picked from commit 2782869)
(backport <rust-lang#4903>) (cherry picked from commit befc34b)
…es in CMSG_NXTHDR musl and its descendants check `next_addr >= max_addr` whilst the rest do `next_addr > max_addr`. This was previously not reflected in the implementations, coming to light only after testing was extended to execute at the controllen boundary. [musl_ref]: https://www.openwall.com/lists/musl/2025/12/27/1 (backport <rust-lang#4903>) (cherry picked from commit 17adf2d)
Fixes: rust-lang#4913 (backport <rust-lang#4914>) (cherry picked from commit ab195eb)
* Use the same type names as used by the native libc, to allow
more self-tests to succeed
* Remove un-needed imports, uncovered by libc's "cargo test"
* Compute _ALIGNBYTES the same way gcc does.
Verified by
* Running (and passing) the libc self-tests "natively"
on an emulated NetBSD/riscv64 system.
* Cross-built rust 1.92.0 with this file in place for riscv64
in the vendored libc-0.2.17{5,6,7} versions, targeting
NetBSD/riscv64.
[ extracted this commit from the two in the PR - Trevor ]
(backport <rust-lang#4886>)
(cherry picked from commit e9b8fa5)
Resolves a uclibc build error introduced in the "Fixes" commit. Fixes: 2fe1d91 ("Separate L4Re from Linux code and enable tests") (backport <rust-lang#4915>) (cherry picked from commit 3dad489)
Move netlink types defined in UAPI to the `new` module. This resolves
the following build error on uclibc platforms:
error[E0425]: cannot find value `NLMSG_MIN_TYPE` in the crate root
--> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.179/src/unix/linux_like/linux/mod.rs:1999:48
|
1999 | pub const NFNL_MSG_BATCH_BEGIN: c_int = crate::NLMSG_MIN_TYPE;
| ^^^^^^^^^^^^^^ not found in the crate root
|
note: found an item that was configured out
--> /home/runner/.cargo/registry/src/index.crates.io-1949cf8c6b5b557f/libc-0.2.179/src/unix/linux_like/linux_l4re_shared.rs:1222:19
|
1200 | if #[cfg(not(target_env = "uclibc"))] {
| ----------------------- the item is gated here
...
1222 | pub const NLMSG_MIN_TYPE: c_int = 0x10;
| ^^^^^^^^^^^^^^
Fixes: 2fe1d91 ("Separate L4Re from Linux code and enable tests")
(backport <rust-lang#4915>)
(cherry picked from commit e0ed72d)
(backport <rust-lang#4915>) (cherry picked from commit 68d3a77)
…ghdr. (backport <rust-lang#4916>) (cherry picked from commit 85a3691)
(backport <rust-lang#4917>) (cherry picked from commit b4995f3)
Collaborator
|
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.
Backport the following: