From d83e4bfbcb86c683b16586ac6bc41b2e70f95812 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Fri, 26 Dec 2025 12:30:32 +0100 Subject: [PATCH 01/14] linux, l4re: address soundness issues of `CMSG_NXTHDR` 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::() < 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 ) (cherry picked from commit cdc2077f76b91a89b47aea132209e2ad20fe94a7) --- src/unix/linux_like/linux_l4re_shared.rs | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index bd3cfafeb6e72..ea958db979203 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1493,15 +1493,25 @@ f! { if ((*cmsg).cmsg_len as usize) < size_of::() { return core::ptr::null_mut::(); } - let next = - (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut crate::cmsghdr; - let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if (next.wrapping_offset(1)) as usize > max - || next as usize + super::CMSG_ALIGN((*next).cmsg_len as usize) > max - { + + // FIXME(msrv): `.wrapping_byte_add()` stabilized in 1.75 + let next_cmsg = cmsg + .cast::() + .wrapping_add(super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) + .cast::(); + + // In case the addition wrapped. `next_addr > max_addr` + // would otherwise not work as intended. + if (next_cmsg as usize) < (cmsg as usize) { + return core::ptr::null_mut(); + } + + let max_addr = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + + if next_cmsg as usize + size_of::() > max_addr { core::ptr::null_mut::() } else { - next + next_cmsg as *mut crate::cmsghdr } } From 9a4e53f7e6e17384dbf1b1a3e9625187278fc70c Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 27 Dec 2025 15:12:18 +0100 Subject: [PATCH 02/14] Remove redundant CMSG_NXTHDR test assertions. Likely written to make assertions in the unsound CMSG_NXTHDR implementations introduced in #1235. CMSG_NXTHDR(mhdr, current_cmsghdr) should not be concerned with the value next_cmsghdr.cmsg_len, which the previous implementation did. (backport ) (cherry picked from commit 1e43edbf5599a90540e90b3333f562f1e976aaa8) --- libc-test/tests/cmsg.rs | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index 80d4af53938e8..e8fa57d6ad479 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -80,21 +80,12 @@ mod t { if cfg!(target_os = "aix") && cmsg_len % std::mem::size_of::() != 0 { continue; } - for next_cmsg_len in 0..32 { - unsafe { - pcmsghdr.cast::().write_bytes(0, CAPACITY); - (*pcmsghdr).cmsg_len = cmsg_len as _; - let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); - let next = cmsg_nxthdr(&mhdr, pcmsghdr); - assert_eq!(libc_next, next); - - if !libc_next.is_null() { - (*libc_next).cmsg_len = next_cmsg_len; - let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); - let next = cmsg_nxthdr(&mhdr, pcmsghdr); - assert_eq!(libc_next, next); - } - } + unsafe { + pcmsghdr.cast::().write_bytes(0, CAPACITY); + (*pcmsghdr).cmsg_len = cmsg_len as _; + let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); + let next = cmsg_nxthdr(&mhdr, pcmsghdr); + assert_eq!(libc_next, next); } } } From 504913c34d87add2522c49098be37a1f87063961 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 27 Dec 2025 15:33:01 +0100 Subject: [PATCH 03/14] Properly set `cmsg_len` in `CMSG_NXTHDR` tests. Setting `(*pcmsghdr).cmsg_len = cmsg_len as _;` when cmsg_len ranges from 0 to 64 is invalid as it must always be `>= size_of::()`, rounded up to the nearest alignment boundary. Some implementations (notably glbic) do check that `cmsg_len >= size_of::()` 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 ) (cherry picked from commit f391df35f33a15ec71efc81d200d77fb30ef3bbe) --- libc-test/tests/cmsg.rs | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index e8fa57d6ad479..949763414394f 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -75,14 +75,10 @@ mod t { let pcmsghdr = buffer.0.as_mut_ptr().cast::(); mhdr.msg_control = pcmsghdr.cast::(); mhdr.msg_controllen = (160 - start_ofs) as _; - for cmsg_len in 0..64 { - // Address must be a multiple of 0x4 for testing on AIX. - if cfg!(target_os = "aix") && cmsg_len % std::mem::size_of::() != 0 { - continue; - } + for cmsg_payload_len in 0..64 { unsafe { pcmsghdr.cast::().write_bytes(0, CAPACITY); - (*pcmsghdr).cmsg_len = cmsg_len as _; + (*pcmsghdr).cmsg_len = libc::CMSG_LEN(cmsg_payload_len as _) as _; let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); let next = cmsg_nxthdr(&mhdr, pcmsghdr); assert_eq!(libc_next, next); From 8e787a1724004e9d38207fbcef1e8b187ca68e0a Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 27 Dec 2025 15:38:51 +0100 Subject: [PATCH 04/14] sparc64: remove ignore for `CMSG_NXTHDR` tests (backport ) (cherry picked from commit 99280f2d94010bcd82fda687e9608fcfae9b898d) --- libc-test/tests/cmsg.rs | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index 949763414394f..5b38d6fcc0e59 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -17,8 +17,6 @@ mod t { extern "C" { pub fn cmsg_firsthdr(msgh: *const msghdr) -> *mut cmsghdr; - // see below - #[cfg(not(target_arch = "sparc64"))] pub fn cmsg_nxthdr(mhdr: *const msghdr, cmsg: *const cmsghdr) -> *mut cmsghdr; pub fn cmsg_space(length: c_uint) -> usize; pub fn cmsg_len(length: c_uint) -> usize; @@ -59,9 +57,6 @@ mod t { } } - // Skip on sparc64 - // https://github.com/rust-lang/libc/issues/1239 - #[cfg(not(target_arch = "sparc64"))] #[test] fn test_cmsg_nxthdr() { // Helps to align the buffer on the stack. From 2434493fce40b06d1fa5f658e3c07491ddd278c3 Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 27 Dec 2025 16:19:30 +0100 Subject: [PATCH 05/14] Test msghdr.controllen boundary behaviour for `CMSG_NXTHDR` (backport ) (cherry picked from commit 2782869da59df7386b4618614035de815c62f9e9) --- libc-test/tests/cmsg.rs | 35 +++++++++++++++++++++++++++-------- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index 5b38d6fcc0e59..b7c212aa0b59b 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -65,18 +65,37 @@ mod t { const CAPACITY: usize = 512; let mut buffer = Align8([0_u8; CAPACITY]); + let pcmsghdr = buffer.0.as_mut_ptr().cast::(); + let mut mhdr: msghdr = unsafe { mem::zeroed() }; - for start_ofs in 0..64 { - let pcmsghdr = buffer.0.as_mut_ptr().cast::(); - mhdr.msg_control = pcmsghdr.cast::(); - mhdr.msg_controllen = (160 - start_ofs) as _; + mhdr.msg_control = pcmsghdr.cast::(); + + for trunc in 0..64 { + mhdr.msg_controllen = (160 - trunc) as _; + for cmsg_payload_len in 0..64 { + let mut current_cmsghdr_ptr = pcmsghdr; + assert!(!current_cmsghdr_ptr.is_null()); + + // Go from first cmsghdr to the last (until null) using various + // cmsg_len increments. `cmsg_len` is set by us to check that + // the jump to the next cmsghdr is correct with respect to + // alignment and payload padding. + while !current_cmsghdr_ptr.is_null() { + unsafe { + (*current_cmsghdr_ptr).cmsg_len = + libc::CMSG_LEN(cmsg_payload_len as _) as _; + + let libc_next = libc::CMSG_NXTHDR(&mhdr, current_cmsghdr_ptr); + let system_next = cmsg_nxthdr(&mhdr, current_cmsghdr_ptr); + assert_eq!(libc_next, system_next); + + current_cmsghdr_ptr = libc_next; + } + } + unsafe { pcmsghdr.cast::().write_bytes(0, CAPACITY); - (*pcmsghdr).cmsg_len = libc::CMSG_LEN(cmsg_payload_len as _) as _; - let libc_next = libc::CMSG_NXTHDR(&mhdr, pcmsghdr); - let next = cmsg_nxthdr(&mhdr, pcmsghdr); - assert_eq!(libc_next, next); } } } From f602a7a1e669aab9bcbe74569aedf489e2ccffcd Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 27 Dec 2025 16:49:43 +0100 Subject: [PATCH 06/14] Add some context to `CMSG_NXTHDR` test assertions. (backport ) (cherry picked from commit befc34b4e4587db45bd84205a0f9ec701dcd35fc) --- libc-test/tests/cmsg.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index b7c212aa0b59b..1be4506e7516e 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -76,6 +76,7 @@ mod t { for cmsg_payload_len in 0..64 { let mut current_cmsghdr_ptr = pcmsghdr; assert!(!current_cmsghdr_ptr.is_null()); + let mut count = 0; // Go from first cmsghdr to the last (until null) using various // cmsg_len increments. `cmsg_len` is set by us to check that @@ -88,9 +89,14 @@ mod t { let libc_next = libc::CMSG_NXTHDR(&mhdr, current_cmsghdr_ptr); let system_next = cmsg_nxthdr(&mhdr, current_cmsghdr_ptr); - assert_eq!(libc_next, system_next); + assert_eq!( + system_next, libc_next, + "msg_crontrollen: {}, payload_len: {}, count: {}", + mhdr.msg_controllen, cmsg_payload_len, count + ); current_cmsghdr_ptr = libc_next; + count += 1; } } From b2e55dd73abb272e045c03c332fe5eb37237821d Mon Sep 17 00:00:00 2001 From: gibbz00 Date: Sat, 3 Jan 2026 13:43:50 +0100 Subject: [PATCH 07/14] linux, emscripten, android, l4re: handle zero-sized payload differences 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 ) (cherry picked from commit 17adf2d8003fd5021358905abdfeed68d504070f) --- src/unix/linux_like/emscripten/mod.rs | 2 +- src/unix/linux_like/linux_l4re_shared.rs | 9 ++++++++- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/unix/linux_like/emscripten/mod.rs b/src/unix/linux_like/emscripten/mod.rs index 35d7001ff5f59..711ed8f8b4c37 100644 --- a/src/unix/linux_like/emscripten/mod.rs +++ b/src/unix/linux_like/emscripten/mod.rs @@ -1257,7 +1257,7 @@ f! { } let next = (cmsg as usize + super::CMSG_ALIGN((*cmsg).cmsg_len as usize)) as *mut cmsghdr; let max = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; - if (next.offset(1)) as usize > max { + if (next.offset(1)) as usize >= max { core::ptr::null_mut::() } else { next as *mut cmsghdr diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index ea958db979203..d4bbfbfbf7736 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1506,7 +1506,14 @@ f! { return core::ptr::null_mut(); } - let max_addr = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + let mut max_addr = (*mhdr).msg_control as usize + (*mhdr).msg_controllen as usize; + + if cfg!(any(target_env = "musl", target_env = "ohos")) { + // musl and some of its descendants do `>= max_addr` + // comparisons in the if statement below. + // https://www.openwall.com/lists/musl/2025/12/27/1 + max_addr -= 1; + } if next_cmsg as usize + size_of::() > max_addr { core::ptr::null_mut::() From 2e0e6e3fc57fbb748c5b927a15352d2fc9595269 Mon Sep 17 00:00:00 2001 From: Reagan Bohan Date: Mon, 5 Jan 2026 08:29:39 +0000 Subject: [PATCH 08/14] musl: Fix incorrect definitions of struct stat on some architectures Fixes: #4913 (backport ) (cherry picked from commit ab195ebff42d2e7ed890795869882c0626fbdc4e) --- src/unix/linux_like/linux/musl/b32/arm/mod.rs | 18 ++++++++++++------ src/unix/linux_like/linux/musl/b32/mips/mod.rs | 18 ++++++++++++------ src/unix/linux_like/linux/musl/b32/powerpc.rs | 18 ++++++++++++------ src/unix/linux_like/linux/musl/b32/x86/mod.rs | 18 ++++++++++++------ 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/unix/linux_like/linux/musl/b32/arm/mod.rs b/src/unix/linux_like/linux/musl/b32/arm/mod.rs index 0f96453fde4f4..ae8e4939bbcb2 100644 --- a/src/unix/linux_like/linux/musl/b32/arm/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/arm/mod.rs @@ -27,12 +27,18 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(not(musl32_time64))] - pub st_atim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_mtim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_ctim: crate::timespec, + #[cfg(not(musl_v1_2_3))] + pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_ctime_nsec: c_long, pub st_ino: crate::ino_t, diff --git a/src/unix/linux_like/linux/musl/b32/mips/mod.rs b/src/unix/linux_like/linux/musl/b32/mips/mod.rs index 0771a7f67c888..8c7ccbfc07450 100644 --- a/src/unix/linux_like/linux/musl/b32/mips/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/mips/mod.rs @@ -25,12 +25,18 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(not(musl32_time64))] - pub st_atim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_mtim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_ctim: crate::timespec, + #[cfg(not(musl_v1_2_3))] + pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_ctime_nsec: c_long, pub st_blksize: crate::blksize_t, __st_padding3: Padding, diff --git a/src/unix/linux_like/linux/musl/b32/powerpc.rs b/src/unix/linux_like/linux/musl/b32/powerpc.rs index 64a2719abbc11..cd11a44e43cd4 100644 --- a/src/unix/linux_like/linux/musl/b32/powerpc.rs +++ b/src/unix/linux_like/linux/musl/b32/powerpc.rs @@ -37,12 +37,18 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(not(musl32_time64))] - pub st_atim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_mtim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_ctim: crate::timespec, + #[cfg(not(musl_v1_2_3))] + pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_ctime_nsec: c_long, __unused: Padding<[c_long; 2]>, diff --git a/src/unix/linux_like/linux/musl/b32/x86/mod.rs b/src/unix/linux_like/linux/musl/b32/x86/mod.rs index 3f2145bc266ef..737438a594efb 100644 --- a/src/unix/linux_like/linux/musl/b32/x86/mod.rs +++ b/src/unix/linux_like/linux/musl/b32/x86/mod.rs @@ -27,12 +27,18 @@ s! { #[cfg(musl32_time64)] __st_ctim32: Padding<__c_anonymous_timespec32>, - #[cfg(not(musl32_time64))] - pub st_atim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_mtim: crate::timespec, - #[cfg(not(musl32_time64))] - pub st_ctim: crate::timespec, + #[cfg(not(musl_v1_2_3))] + pub st_atime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_atime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_mtime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_mtime_nsec: c_long, + #[cfg(not(musl_v1_2_3))] + pub st_ctime: crate::time_t, + #[cfg(not(musl_v1_2_3))] + pub st_ctime_nsec: c_long, pub st_ino: crate::ino_t, From b0f988ccd8ba3391b6c6d78e6b2ff2ee25d4b6b2 Mon Sep 17 00:00:00 2001 From: Havard Eidnes Date: Fri, 19 Dec 2025 17:07:45 +0000 Subject: [PATCH 09/14] netbsd/riscv64.rs: make changes so that this builds again. * 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 ) (cherry picked from commit e9b8fa5c93c6766cc28f4630bb69ea12ac90a77d) --- src/unix/bsd/netbsdlike/netbsd/riscv64.rs | 35 +++++++++++++---------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs index 8cacb7250eddc..05c0cd55cb80d 100644 --- a/src/unix/bsd/netbsdlike/netbsd/riscv64.rs +++ b/src/unix/bsd/netbsdlike/netbsd/riscv64.rs @@ -2,17 +2,9 @@ use crate::prelude::*; use crate::PT_FIRSTMACH; pub type __greg_t = u64; -pub type __cpu_simple_lock_nv_t = c_int; -pub type __gregset = [__greg_t; _NGREG]; -pub type __fregset = [__fpreg; _NFREG]; - -s! { - pub struct mcontext_t { - pub __gregs: __gregset, - pub __fregs: __fregset, - __spare: [crate::__greg_t; 7], - } -} +pub type __cpu_simple_lock_nv_t = c_uint; +pub type __gregset_t = [__greg_t; _NGREG]; +pub type __fregset_t = [__fpreg; _NFREG]; s_no_extra_traits! { pub union __fpreg { @@ -21,23 +13,36 @@ s_no_extra_traits! { } } +s! { + pub struct mcontext_t { + pub __gregs: __gregset_t, + pub __fregs: __fregset_t, + __spare: [crate::__greg_t; 7], + } +} + cfg_if! { if #[cfg(feature = "extra_traits")] { impl PartialEq for __fpreg { - fn eq(&self, other: &Self) -> bool { - unsafe { self.u_u64 == other.u_u64 } + fn eq(&self, other: &__fpreg) -> bool { + unsafe { self.u_u64 == other.u_u64 || self.u_d == other.u_d } } } impl Eq for __fpreg {} impl hash::Hash for __fpreg { fn hash(&self, state: &mut H) { - unsafe { self.u_u64.hash(state) }; + unsafe { + self.u_u64.hash(state); + } } } } } -pub(crate) const _ALIGNBYTES: usize = size_of::() - 1; +// gcc for riscv64 defines `BIGGEST_ALIGNMENT`, but it's mesured in bits. +pub(crate) const __BIGGEST_ALIGNMENT_IN_BITS__: usize = 128; +// `_ALIGNBYTES` is measured in, well, bytes. +pub(crate) const _ALIGNBYTES: usize = (__BIGGEST_ALIGNMENT_IN_BITS__ / 8) - 1; pub const PT_GETREGS: c_int = PT_FIRSTMACH + 0; pub const PT_SETREGS: c_int = PT_FIRSTMACH + 1; From e09a194392e17b1eee2c8b99c1d46b646d6fbea6 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 6 Jan 2026 01:24:25 -0600 Subject: [PATCH 10/14] uclibc: Re-enable `__SIZEOF_PTHREAD_COND_T` on non-L4Re uclibc Resolves a uclibc build error introduced in the "Fixes" commit. Fixes: 2fe1d91f1822 ("Separate L4Re from Linux code and enable tests") (backport ) (cherry picked from commit 3dad48911eb83ba149f4759191b2c4fa7d54a2d7) --- src/unix/linux_like/linux_l4re_shared.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index d4bbfbfbf7736..99f72ae03a806 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -953,7 +953,7 @@ pub const PTHREAD_PROCESS_PRIVATE: c_int = 0; pub const PTHREAD_PROCESS_SHARED: c_int = 1; pub const PTHREAD_INHERIT_SCHED: c_int = 0; pub const PTHREAD_EXPLICIT_SCHED: c_int = 1; -#[cfg(not(target_env = "uclibc"))] +#[cfg(not(all(target_os = "l4re", target_env = "uclibc")))] pub const __SIZEOF_PTHREAD_COND_T: usize = 48; // netinet/in.h From efc7b6ffefc1c81912db05d5cbb3237b61c79494 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 6 Jan 2026 01:36:04 -0600 Subject: [PATCH 11/14] linux: Restructure `netlink` to `src/new` 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: 2fe1d91f1822 ("Separate L4Re from Linux code and enable tests") (backport ) (cherry picked from commit e0ed72dc03f1d71d0ad6a014f2ef35dee4fd584d) --- libc-test/semver/linux-gnu.txt | 4 - libc-test/semver/linux.txt | 4 + src/new/linux_uapi/linux/mod.rs | 1 + src/new/linux_uapi/linux/netlink.rs | 136 +++++++++++++++++++++++ src/new/mod.rs | 1 + src/unix/linux_like/l4re/mod.rs | 10 ++ src/unix/linux_like/linux/gnu/mod.rs | 22 ---- src/unix/linux_like/linux/mod.rs | 93 +--------------- src/unix/linux_like/linux_l4re_shared.rs | 6 - 9 files changed, 153 insertions(+), 124 deletions(-) create mode 100644 src/new/linux_uapi/linux/netlink.rs diff --git a/libc-test/semver/linux-gnu.txt b/libc-test/semver/linux-gnu.txt index 0db7c9688797e..a28ac82250fb6 100644 --- a/libc-test/semver/linux-gnu.txt +++ b/libc-test/semver/linux-gnu.txt @@ -117,7 +117,6 @@ LOGIN_PROCESS Lmid_t MADV_COLLAPSE MAXTC -MAX_LINKS MINIX2_SUPER_MAGIC MINIX2_SUPER_MAGIC2 MINIX3_SUPER_MAGIC @@ -637,9 +636,6 @@ malloc_usable_size mallopt mempcpy mq_notify -nl_mmap_hdr -nl_mmap_req -nl_pktinfo ntp_adjtime ntp_gettime ntptimeval diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index f3cca5611ee4d..30fe2268e3011 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -1641,6 +1641,7 @@ MAP_TYPE MAXTTL MAX_ADDR_LEN MAX_IPOPTLEN +MAX_LINKS MCAST_BLOCK_SOURCE MCAST_EXCLUDE MCAST_INCLUDE @@ -4128,6 +4129,9 @@ nice nl_item nl_langinfo nl_langinfo_l +nl_mmap_hdr +nl_mmap_req +nl_pktinfo nlattr nlmsgerr nlmsghdr diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 993394e4370ca..9dd1f335ee55c 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -4,3 +4,4 @@ pub(crate) mod can; pub(crate) mod keyctl; +pub(crate) mod netlink; diff --git a/src/new/linux_uapi/linux/netlink.rs b/src/new/linux_uapi/linux/netlink.rs new file mode 100644 index 0000000000000..03e18d739300a --- /dev/null +++ b/src/new/linux_uapi/linux/netlink.rs @@ -0,0 +1,136 @@ +//! Header: `uapi/linux/netlink.h` + +use crate::prelude::*; + +pub const NETLINK_ROUTE: c_int = 0; +pub const NETLINK_UNUSED: c_int = 1; +pub const NETLINK_USERSOCK: c_int = 2; +pub const NETLINK_FIREWALL: c_int = 3; +pub const NETLINK_SOCK_DIAG: c_int = 4; +pub const NETLINK_NFLOG: c_int = 5; +pub const NETLINK_XFRM: c_int = 6; +pub const NETLINK_SELINUX: c_int = 7; +pub const NETLINK_ISCSI: c_int = 8; +pub const NETLINK_AUDIT: c_int = 9; +pub const NETLINK_FIB_LOOKUP: c_int = 10; +pub const NETLINK_CONNECTOR: c_int = 11; +pub const NETLINK_NETFILTER: c_int = 12; +pub const NETLINK_IP6_FW: c_int = 13; +pub const NETLINK_DNRTMSG: c_int = 14; +pub const NETLINK_KOBJECT_UEVENT: c_int = 15; +pub const NETLINK_GENERIC: c_int = 16; +pub const NETLINK_SCSITRANSPORT: c_int = 18; +pub const NETLINK_ECRYPTFS: c_int = 19; +pub const NETLINK_RDMA: c_int = 20; +pub const NETLINK_CRYPTO: c_int = 21; + +pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG; + +pub const MAX_LINKS: c_int = 32; + +s! { + pub struct sockaddr_nl { + pub nl_family: crate::sa_family_t, + nl_pad: Padding, + pub nl_pid: u32, + pub nl_groups: u32, + } + + pub struct nlmsghdr { + pub nlmsg_len: u32, + pub nlmsg_type: u16, + pub nlmsg_flags: u16, + pub nlmsg_seq: u32, + pub nlmsg_pid: u32, + } +} + +pub const NLM_F_REQUEST: c_int = 1; +pub const NLM_F_MULTI: c_int = 2; +pub const NLM_F_ACK: c_int = 4; +pub const NLM_F_ECHO: c_int = 8; +pub const NLM_F_DUMP_INTR: c_int = 16; +pub const NLM_F_DUMP_FILTERED: c_int = 32; + +pub const NLM_F_ROOT: c_int = 0x100; +pub const NLM_F_MATCH: c_int = 0x200; +pub const NLM_F_ATOMIC: c_int = 0x400; +pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH; + +pub const NLM_F_REPLACE: c_int = 0x100; +pub const NLM_F_EXCL: c_int = 0x200; +pub const NLM_F_CREATE: c_int = 0x400; +pub const NLM_F_APPEND: c_int = 0x800; + +pub const NLM_F_NONREC: c_int = 0x100; + +pub const NLM_F_CAPPED: c_int = 0x100; +pub const NLM_F_ACK_TLVS: c_int = 0x200; + +pub const NLMSG_NOOP: c_int = 0x1; +pub const NLMSG_ERROR: c_int = 0x2; +pub const NLMSG_DONE: c_int = 0x3; +pub const NLMSG_OVERRUN: c_int = 0x4; + +pub const NLMSG_MIN_TYPE: c_int = 0x10; + +s! { + pub struct nlmsgerr { + pub error: c_int, + pub msg: nlmsghdr, + } +} + +pub const NETLINK_ADD_MEMBERSHIP: c_int = 1; +pub const NETLINK_DROP_MEMBERSHIP: c_int = 2; +pub const NETLINK_PKTINFO: c_int = 3; +pub const NETLINK_BROADCAST_ERROR: c_int = 4; +pub const NETLINK_NO_ENOBUFS: c_int = 5; +pub const NETLINK_RX_RING: c_int = 6; +pub const NETLINK_TX_RING: c_int = 7; +pub const NETLINK_LISTEN_ALL_NSID: c_int = 8; +pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9; +pub const NETLINK_CAP_ACK: c_int = 10; +pub const NETLINK_EXT_ACK: c_int = 11; +pub const NETLINK_GET_STRICT_CHK: c_int = 12; + +s! { + pub struct nl_pktinfo { + pub group: u32, + } + + pub struct nl_mmap_req { + pub nm_block_size: c_uint, + pub nm_block_nr: c_uint, + pub nm_frame_size: c_uint, + pub nm_frame_nr: c_uint, + } + + pub struct nl_mmap_hdr { + pub nm_status: c_uint, + pub nm_len: c_uint, + pub nm_group: u32, + pub nm_pid: u32, + pub nm_uid: u32, + pub nm_gid: u32, + } +} + +s! { + pub struct nlattr { + pub nla_len: u16, + pub nla_type: u16, + } +} + +pub const NLA_F_NESTED: c_int = 1 << 15; +pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14; +pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); + +pub const NLA_ALIGNTO: c_int = 4; + +f! { + pub fn NLA_ALIGN(len: c_int) -> c_int { + return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); + } +} diff --git a/src/new/mod.rs b/src/new/mod.rs index d4d2636601e18..cdd6faf83cefa 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -181,6 +181,7 @@ cfg_if! { pub use linux::can::raw::*; pub use linux::can::*; pub use linux::keyctl::*; + pub use linux::netlink::*; #[cfg(target_env = "gnu")] pub use net::route::*; } else if #[cfg(target_vendor = "apple")] { diff --git a/src/unix/linux_like/l4re/mod.rs b/src/unix/linux_like/l4re/mod.rs index eb7cde2e3cde6..5ac4868f7d1c2 100644 --- a/src/unix/linux_like/l4re/mod.rs +++ b/src/unix/linux_like/l4re/mod.rs @@ -186,6 +186,16 @@ pub const TIOCGICOUNT: Ioctl = 0x545D; pub const BLKSSZGET: Ioctl = 0x1268; +cfg_if! { + if #[cfg(not(target_env = "uclibc"))] { + pub const NLMSG_NOOP: c_int = 0x1; + pub const NLMSG_ERROR: c_int = 0x2; + pub const NLMSG_DONE: c_int = 0x3; + pub const NLMSG_OVERRUN: c_int = 0x4; + pub const NLMSG_MIN_TYPE: c_int = 0x10; + } +} + cfg_if! { if #[cfg(target_env = "uclibc")] { mod uclibc; diff --git a/src/unix/linux_like/linux/gnu/mod.rs b/src/unix/linux_like/linux/gnu/mod.rs index 6e424b8b1d362..5fa2fdf591dda 100644 --- a/src/unix/linux_like/linux/gnu/mod.rs +++ b/src/unix/linux_like/linux/gnu/mod.rs @@ -133,26 +133,6 @@ s! { pub keepcost: size_t, } - pub struct nl_pktinfo { - pub group: u32, - } - - pub struct nl_mmap_req { - pub nm_block_size: c_uint, - pub nm_block_nr: c_uint, - pub nm_frame_size: c_uint, - pub nm_frame_nr: c_uint, - } - - pub struct nl_mmap_hdr { - pub nm_status: c_uint, - pub nm_len: c_uint, - pub nm_group: u32, - pub nm_pid: u32, - pub nm_uid: u32, - pub nm_gid: u32, - } - pub struct ntptimeval { pub time: crate::timeval, pub maxerror: c_long, @@ -810,8 +790,6 @@ pub const NDA_SRC_VNI: c_ushort = 11; pub const UNAME26: c_int = 0x0020000; pub const FDPIC_FUNCPTRS: c_int = 0x0080000; -pub const MAX_LINKS: c_int = 32; - pub const GENL_UNS_ADMIN_PERM: c_int = 0x10; pub const GENL_ID_VFS_DQUOT: c_int = crate::NLMSG_MIN_TYPE + 1; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 7b2c21df5516c..5cfc87112088f 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -473,24 +473,6 @@ s! { pub newfd_flags: __u32, } - pub struct nlmsghdr { - pub nlmsg_len: u32, - pub nlmsg_type: u16, - pub nlmsg_flags: u16, - pub nlmsg_seq: u32, - pub nlmsg_pid: u32, - } - - pub struct nlmsgerr { - pub error: c_int, - pub msg: nlmsghdr, - } - - pub struct nlattr { - pub nla_len: u16, - pub nla_type: u16, - } - pub struct in6_ifreq { pub ifr6_addr: crate::in6_addr, pub ifr6_prefixlen: u32, @@ -1063,13 +1045,6 @@ s! { pub token_count: crate::__u32, } - pub struct sockaddr_nl { - pub nl_family: crate::sa_family_t, - nl_pad: Padding, - pub nl_pid: u32, - pub nl_groups: u32, - } - pub struct sockaddr_alg { pub salg_family: crate::sa_family_t, pub salg_type: [c_uchar; 14], @@ -2653,70 +2628,8 @@ pub const NDA_VNI: c_ushort = 7; pub const NDA_IFINDEX: c_ushort = 8; // linux/netlink.h -pub const NLA_ALIGNTO: c_int = 4; - -pub const NETLINK_ROUTE: c_int = 0; -pub const NETLINK_UNUSED: c_int = 1; -pub const NETLINK_USERSOCK: c_int = 2; -pub const NETLINK_FIREWALL: c_int = 3; -pub const NETLINK_SOCK_DIAG: c_int = 4; -pub const NETLINK_NFLOG: c_int = 5; -pub const NETLINK_XFRM: c_int = 6; -pub const NETLINK_SELINUX: c_int = 7; -pub const NETLINK_ISCSI: c_int = 8; -pub const NETLINK_AUDIT: c_int = 9; -pub const NETLINK_FIB_LOOKUP: c_int = 10; -pub const NETLINK_CONNECTOR: c_int = 11; -pub const NETLINK_NETFILTER: c_int = 12; -pub const NETLINK_IP6_FW: c_int = 13; -pub const NETLINK_DNRTMSG: c_int = 14; -pub const NETLINK_KOBJECT_UEVENT: c_int = 15; -pub const NETLINK_GENERIC: c_int = 16; -pub const NETLINK_SCSITRANSPORT: c_int = 18; -pub const NETLINK_ECRYPTFS: c_int = 19; -pub const NETLINK_RDMA: c_int = 20; -pub const NETLINK_CRYPTO: c_int = 21; -pub const NETLINK_INET_DIAG: c_int = NETLINK_SOCK_DIAG; - -pub const NLM_F_REQUEST: c_int = 1; -pub const NLM_F_MULTI: c_int = 2; -pub const NLM_F_ACK: c_int = 4; -pub const NLM_F_ECHO: c_int = 8; -pub const NLM_F_DUMP_INTR: c_int = 16; -pub const NLM_F_DUMP_FILTERED: c_int = 32; - -pub const NLM_F_ROOT: c_int = 0x100; -pub const NLM_F_MATCH: c_int = 0x200; -pub const NLM_F_ATOMIC: c_int = 0x400; -pub const NLM_F_DUMP: c_int = NLM_F_ROOT | NLM_F_MATCH; - -pub const NLM_F_REPLACE: c_int = 0x100; -pub const NLM_F_EXCL: c_int = 0x200; -pub const NLM_F_CREATE: c_int = 0x400; -pub const NLM_F_APPEND: c_int = 0x800; - -pub const NLM_F_NONREC: c_int = 0x100; -pub const NLM_F_BULK: c_int = 0x200; -pub const NLM_F_CAPPED: c_int = 0x100; -pub const NLM_F_ACK_TLVS: c_int = 0x200; - -pub const NETLINK_ADD_MEMBERSHIP: c_int = 1; -pub const NETLINK_DROP_MEMBERSHIP: c_int = 2; -pub const NETLINK_PKTINFO: c_int = 3; -pub const NETLINK_BROADCAST_ERROR: c_int = 4; -pub const NETLINK_NO_ENOBUFS: c_int = 5; -pub const NETLINK_RX_RING: c_int = 6; -pub const NETLINK_TX_RING: c_int = 7; -pub const NETLINK_LISTEN_ALL_NSID: c_int = 8; -pub const NETLINK_LIST_MEMBERSHIPS: c_int = 9; -pub const NETLINK_CAP_ACK: c_int = 10; -pub const NETLINK_EXT_ACK: c_int = 11; -pub const NETLINK_GET_STRICT_CHK: c_int = 12; - -pub const NLA_F_NESTED: c_int = 1 << 15; -pub const NLA_F_NET_BYTEORDER: c_int = 1 << 14; -pub const NLA_TYPE_MASK: c_int = !(NLA_F_NESTED | NLA_F_NET_BYTEORDER); +pub const NLM_F_BULK: c_int = 0x200; // linux/rtnetlink.h pub const TCA_UNSPEC: c_ushort = 0; @@ -4056,10 +3969,6 @@ pub const SI_DETHREAD: c_int = -7; pub const TRAP_PERF: c_int = 6; f! { - pub fn NLA_ALIGN(len: c_int) -> c_int { - return ((len) + NLA_ALIGNTO - 1) & !(NLA_ALIGNTO - 1); - } - pub fn SCTP_PR_INDEX(policy: c_int) -> c_int { policy >> (4 - 1) } diff --git a/src/unix/linux_like/linux_l4re_shared.rs b/src/unix/linux_like/linux_l4re_shared.rs index 99f72ae03a806..d91240a058583 100644 --- a/src/unix/linux_like/linux_l4re_shared.rs +++ b/src/unix/linux_like/linux_l4re_shared.rs @@ -1214,12 +1214,6 @@ cfg_if! { pub const MFD_HUGE_16GB: c_uint = 0x88000000; pub const MFD_HUGE_MASK: c_uint = 63; pub const MFD_HUGE_SHIFT: c_uint = 26; - - pub const NLMSG_NOOP: c_int = 0x1; - pub const NLMSG_ERROR: c_int = 0x2; - pub const NLMSG_DONE: c_int = 0x3; - pub const NLMSG_OVERRUN: c_int = 0x4; - pub const NLMSG_MIN_TYPE: c_int = 0x10; } } From b3fa2267787d594d0c05badcb12ebedbe6fa1642 Mon Sep 17 00:00:00 2001 From: Trevor Gross Date: Tue, 6 Jan 2026 01:52:43 -0600 Subject: [PATCH 12/14] linux: Move `membarrier.h` constants to `src/new` (backport ) (cherry picked from commit 68d3a77a7db4786791c25690360edfc0e01ab574) --- libc-test/build.rs | 14 ++++++++++---- libc-test/semver/linux.txt | 1 + src/new/linux_uapi/linux/membarrier.rs | 20 ++++++++++++++++++++ src/new/linux_uapi/linux/mod.rs | 1 + src/new/mod.rs | 1 + src/unix/linux_like/linux/mod.rs | 12 ------------ 6 files changed, 33 insertions(+), 16 deletions(-) create mode 100644 src/new/linux_uapi/linux/membarrier.rs diff --git a/libc-test/build.rs b/libc-test/build.rs index 330388f874553..66cced85f5a6c 100644 --- a/libc-test/build.rs +++ b/libc-test/build.rs @@ -1737,7 +1737,6 @@ fn test_dragonflybsd(target: &str) { "sem_t" => true, // mqd_t is a pointer on DragonFly "mqd_t" => true, - _ => false, } }); @@ -4653,16 +4652,23 @@ fn test_linux(target: &str) { }); let c_enums = [ - "tpacket_versions", - "proc_cn_mcast_op", - "proc_cn_event", + "membarrier_cmd", "pid_type", + "proc_cn_event", + "proc_cn_mcast_op", + "tpacket_versions", ]; cfg.alias_is_c_enum(move |e| c_enums.contains(&e)); // FIXME(libc): `pid_type` and `proc_cn_event` is hidden. cfg.skip_c_enum(|e| e == "pid_type" || e == "proc_cn_event"); + cfg.skip_signededness(move |c| match c { + // FIXME(1.0): uses the enum default signedness + "membarrier_cmd" => true, + _ => false, + }); + cfg.skip_fn(move |function| { let name = function.ident(); // skip those that are manually verified diff --git a/libc-test/semver/linux.txt b/libc-test/semver/linux.txt index 30fe2268e3011..25a3a593f44e8 100644 --- a/libc-test/semver/linux.txt +++ b/libc-test/semver/linux.txt @@ -4086,6 +4086,7 @@ madvise major makedev memalign +membarrier_cmd memmem memrchr mincore diff --git a/src/new/linux_uapi/linux/membarrier.rs b/src/new/linux_uapi/linux/membarrier.rs new file mode 100644 index 0000000000000..4446202cb3bfb --- /dev/null +++ b/src/new/linux_uapi/linux/membarrier.rs @@ -0,0 +1,20 @@ +//! Header: `uapi/linux/membarrier.h` + +use crate::prelude::*; + +c_enum! { + // FIXME(1.0): incorrect repr signedness, this should be removed in a breaking change. + #[repr(c_int)] + pub enum membarrier_cmd { + pub MEMBARRIER_CMD_QUERY = 0, + pub MEMBARRIER_CMD_GLOBAL = 1 << 0, + pub MEMBARRIER_CMD_GLOBAL_EXPEDITED = 1 << 1, + pub MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED = 1 << 2, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED = 1 << 3, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED = 1 << 4, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE = 1 << 5, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE = 1 << 6, + pub MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ = 1 << 7, + pub MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ = 1 << 8, + } +} diff --git a/src/new/linux_uapi/linux/mod.rs b/src/new/linux_uapi/linux/mod.rs index 9dd1f335ee55c..994a59c0c3864 100644 --- a/src/new/linux_uapi/linux/mod.rs +++ b/src/new/linux_uapi/linux/mod.rs @@ -4,4 +4,5 @@ pub(crate) mod can; pub(crate) mod keyctl; +pub(crate) mod membarrier; pub(crate) mod netlink; diff --git a/src/new/mod.rs b/src/new/mod.rs index cdd6faf83cefa..88b881a6c2e7c 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -181,6 +181,7 @@ cfg_if! { pub use linux::can::raw::*; pub use linux::can::*; pub use linux::keyctl::*; + pub use linux::membarrier::*; pub use linux::netlink::*; #[cfg(target_env = "gnu")] pub use net::route::*; diff --git a/src/unix/linux_like/linux/mod.rs b/src/unix/linux_like/linux/mod.rs index 5cfc87112088f..13d25bd9722d9 100644 --- a/src/unix/linux_like/linux/mod.rs +++ b/src/unix/linux_like/linux/mod.rs @@ -1557,18 +1557,6 @@ pub const MPOL_F_NUMA_BALANCING: c_int = 1 << 13; pub const MPOL_F_RELATIVE_NODES: c_int = 1 << 14; pub const MPOL_F_STATIC_NODES: c_int = 1 << 15; -// linux/membarrier.h -pub const MEMBARRIER_CMD_QUERY: c_int = 0; -pub const MEMBARRIER_CMD_GLOBAL: c_int = 1 << 0; -pub const MEMBARRIER_CMD_GLOBAL_EXPEDITED: c_int = 1 << 1; -pub const MEMBARRIER_CMD_REGISTER_GLOBAL_EXPEDITED: c_int = 1 << 2; -pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED: c_int = 1 << 3; -pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED: c_int = 1 << 4; -pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 5; -pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_SYNC_CORE: c_int = 1 << 6; -pub const MEMBARRIER_CMD_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 7; -pub const MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED_RSEQ: c_int = 1 << 8; - pub const PTHREAD_MUTEX_INITIALIZER: crate::pthread_mutex_t = crate::pthread_mutex_t { size: [0; crate::__SIZEOF_PTHREAD_MUTEX_T], }; From abc22f1fc4757d71d0e6a7f809c3cef1b6cb714f Mon Sep 17 00:00:00 2001 From: Xing Xue Date: Tue, 6 Jan 2026 14:04:55 -0500 Subject: [PATCH 13/14] Only test addresses of cmsghdrs that are multiples of the size of cmsghdr. (backport ) (cherry picked from commit 85a3691237a2386116ad36b703bd0062b839043a) --- libc-test/tests/cmsg.rs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/libc-test/tests/cmsg.rs b/libc-test/tests/cmsg.rs index 1be4506e7516e..c358081698afc 100644 --- a/libc-test/tests/cmsg.rs +++ b/libc-test/tests/cmsg.rs @@ -74,6 +74,14 @@ mod t { mhdr.msg_controllen = (160 - trunc) as _; for cmsg_payload_len in 0..64 { + // AIX does not apply any alignment or padding to ancillary + // data and CMSG_ALIGN() is a noop. So only test addresses + // that are multiples of the size of cmsghdr here. + if cfg!(target_os = "aix") && cmsg_payload_len % std::mem::size_of::() != 0 + { + continue; + } + let mut current_cmsghdr_ptr = pcmsghdr; assert!(!current_cmsghdr_ptr.is_null()); let mut count = 0; From c82756e0aa55e851a8055a4529cc30304ff0b85a Mon Sep 17 00:00:00 2001 From: Jan Sommer Date: Wed, 7 Jan 2026 18:42:27 +0100 Subject: [PATCH 14/14] ci: Add rtems to basic tier 3 checks (backport ) (cherry picked from commit b4995f36c84cb058bfba601bdd221270ffc63c29) --- ci/verify-build.py | 1 + src/new/mod.rs | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/verify-build.py b/ci/verify-build.py index 0e0ea0c25b2ca..b3b35f1c6e0bc 100755 --- a/ci/verify-build.py +++ b/ci/verify-build.py @@ -155,6 +155,7 @@ class TargetResult: Target("aarch64-unknown-openbsd", dist=False), Target("aarch64-wrs-vxworks", dist=False), Target("armebv7r-none-eabihf", dist=False), + Target("armv7-rtems-eabihf", dist=False), Target("armv7-wrs-vxworks-eabihf", dist=False), Target("armv7r-none-eabihf", dist=False), Target("armv7s-apple-ios", dist=False), diff --git a/src/new/mod.rs b/src/new/mod.rs index 88b881a6c2e7c..9a1e56df20053 100644 --- a/src/new/mod.rs +++ b/src/new/mod.rs @@ -110,7 +110,7 @@ cfg_if! { // pub(crate) use redox::*; } else if #[cfg(target_os = "rtems")] { mod rtems; - pub(crate) use rtems::*; + // pub(crate) use rtems::*; } else if #[cfg(target_os = "solaris")] { mod solaris; pub(crate) use solaris::*;