Skip to content

Don't let a mismatch AT_SYSINFO_EHDR image preclude use of AUX values. #1484

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 2 commits into from
Jul 15, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 7 additions & 10 deletions src/backend/linux_raw/param/auxv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ use core::sync::atomic::Ordering::Relaxed;
use core::sync::atomic::{AtomicPtr, AtomicUsize};
use linux_raw_sys::elf::*;
use linux_raw_sys::general::{
AT_BASE, AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_MINSIGSTKSZ, AT_NULL, AT_PAGESZ,
AT_SYSINFO_EHDR,
AT_CLKTCK, AT_EXECFN, AT_HWCAP, AT_HWCAP2, AT_MINSIGSTKSZ, AT_NULL, AT_PAGESZ, AT_SYSINFO_EHDR,
};
#[cfg(feature = "runtime")]
use linux_raw_sys::general::{
Expand Down Expand Up @@ -401,13 +400,12 @@ unsafe fn init_from_aux_iter(aux_iter: impl Iterator<Item = Elf_auxv_t>) -> Opti
AT_HWCAP2 => hwcap2 = a_val as usize,
AT_MINSIGSTKSZ => minsigstksz = a_val as usize,
AT_EXECFN => execfn = check_raw_pointer::<c::c_char>(a_val as *mut _)?.as_ptr(),
AT_SYSINFO_EHDR => sysinfo_ehdr = check_elf_base(a_val as *mut _)?.as_ptr(),

AT_BASE => {
// The `AT_BASE` value can be null in a static executable that
// doesn't use a dynamic linker. If so, ignore it.
if !a_val.is_null() {
let _ = check_elf_base(a_val.cast())?;
// Use the `AT_SYSINFO_EHDR` if it matches the platform rustix is
// compiled for.
AT_SYSINFO_EHDR => {
if let Some(value) = check_elf_base(a_val as *mut _) {
sysinfo_ehdr = value.as_ptr();
}
}

Expand Down Expand Up @@ -448,8 +446,7 @@ unsafe fn init_from_aux_iter(aux_iter: impl Iterator<Item = Elf_auxv_t>) -> Opti
secure = 2;
}

// The base and sysinfo_ehdr (if present) matches our platform. Accept the
// aux values.
// Accept the aux values.
PAGE_SIZE.store(pagesz, Relaxed);
CLOCK_TICKS_PER_SECOND.store(clktck, Relaxed);
HWCAP.store(hwcap, Relaxed);
Expand Down
Loading