mirror of
https://gitlab.alpinelinux.org/alpine/aports.git
synced 2026-02-18 06:12:35 +01:00
41 lines
1.5 KiB
Diff
41 lines
1.5 KiB
Diff
nix crate doesn't provide _MAGIC constants because libc crate doesn't
|
|
provide them. See https://github.com/rust-lang/libc/pull/2633.
|
|
|
|
--- a/crates/libcgroups/src/common.rs
|
|
+++ b/crates/libcgroups/src/common.rs
|
|
@@ -8,9 +8,13 @@
|
|
|
|
use anyhow::{bail, Context, Result};
|
|
use nix::{
|
|
- sys::statfs::{statfs, CGROUP2_SUPER_MAGIC, TMPFS_MAGIC},
|
|
+ sys::statfs::{statfs, FsType}, // XXX-Patched
|
|
unistd::Pid,
|
|
};
|
|
+// XXX-Patched: Workaround for https://github.com/rust-lang/libc/pull/2633
|
|
+const TMPFS_MAGIC: FsType = FsType(0x01021994);
|
|
+const CGROUP2_SUPER_MAGIC: FsType = FsType(0x63677270);
|
|
+
|
|
use oci_spec::runtime::{
|
|
LinuxDevice, LinuxDeviceBuilder, LinuxDeviceCgroup, LinuxDeviceCgroupBuilder, LinuxDeviceType,
|
|
LinuxResources,
|
|
--- a/crates/libcontainer/src/utils.rs
|
|
+++ b/crates/libcontainer/src/utils.rs
|
|
@@ -131,13 +131,16 @@
|
|
}
|
|
}
|
|
|
|
+// XXX-Patched: Workaround for https://github.com/rust-lang/libc/pull/2633.
|
|
+const PROC_SUPER_MAGIC: statfs::FsType = statfs::FsType(0x01021994);
|
|
+
|
|
// Make sure a given path is on procfs. This is to avoid the security risk that
|
|
// /proc path is mounted over. Ref: CVE-2019-16884
|
|
pub fn ensure_procfs(path: &Path) -> Result<()> {
|
|
let procfs_fd = fs::File::open(path)?;
|
|
let fstat_info = statfs::fstatfs(&procfs_fd.as_raw_fd())?;
|
|
|
|
- if fstat_info.filesystem_type() != statfs::PROC_SUPER_MAGIC {
|
|
+ if fstat_info.filesystem_type() != PROC_SUPER_MAGIC {
|
|
bail!(format!("{:?} is not on the procfs", path));
|
|
}
|
|
|