coreutils: fix panic on linux < 6.4 when /proc is not mounted (#12104)

This commit is contained in:
oech3
2026-05-16 22:12:43 +02:00
committed by GitHub
parent 9e3ab20009
commit ab328d170e
4 changed files with 16 additions and 6 deletions
+1
View File
@@ -368,6 +368,7 @@ mkfifoat
setpipe
# * other
auxv
getlimits
weblate
algs
+2 -3
View File
@@ -451,9 +451,8 @@ rstest = "0.26.0"
rstest_reuse = "0.7.0"
rustc-hash = "2.1.1"
rust-ini = "0.21.0"
# binary name of coreutils can be hijacked by overriding getauxval via LD_PRELOAD
# So we use param and avoid libc backend
rustix = { version = "1.1.4", features = ["param"] }
# raw-backend's linux_execfn is not supported on linux < 6.4 if /proc is not mounted. So use-libc-auxv is needed
rustix = { version = "1.1.4", features = ["param", "use-libc-auxv"] }
same-file = "1.0.6"
self_cell = "1.0.4"
selinux = "0.6"
+8 -2
View File
@@ -74,7 +74,10 @@ fn get_canonical_util_name(util_name: &str) -> &str {
/// Gets the binary path from command line arguments
/// Panics if the binary path cannot be determined
#[cfg(not(any(target_os = "linux", target_os = "android")))]
#[cfg(any(
not(any(target_os = "linux", target_os = "android")),
target_env = "musl"
))]
pub fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
match args.next() {
Some(ref s) if !s.is_empty() => PathBuf::from(s),
@@ -84,7 +87,10 @@ pub fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
}
/// Get actual binary path from kernel, not argv0, to prevent `env -a` from bypassing
/// AppArmor, SELinux policies on hard-linked binaries
#[cfg(any(target_os = "linux", target_os = "android"))]
#[cfg(all(
any(target_os = "linux", target_os = "android"),
not(target_env = "musl")
))]
pub fn binary_path(args: &mut impl Iterator<Item = OsString>) -> PathBuf {
use std::fs::File;
use std::io::Read;
+5 -1
View File
@@ -26,7 +26,11 @@ fn init() {
}
#[test]
#[cfg(all(feature = "env", any(target_os = "linux", target_os = "android")))]
#[cfg(all(
feature = "env",
any(target_os = "linux", target_os = "android"),
not(target_env = "musl")
))]
fn binary_name_protection() {
let ts = TestScenario::new("env");
let bin = ts.bin_path.clone();