diff options
Diffstat (limited to 'vendor/rustix/src/thread/prctl.rs')
-rw-r--r-- | vendor/rustix/src/thread/prctl.rs | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/vendor/rustix/src/thread/prctl.rs b/vendor/rustix/src/thread/prctl.rs index 2e11ff247..a9f411640 100644 --- a/vendor/rustix/src/thread/prctl.rs +++ b/vendor/rustix/src/thread/prctl.rs @@ -9,7 +9,6 @@ //! correctly. #![allow(unsafe_code)] -use core::convert::TryFrom; use core::mem::MaybeUninit; use core::num::NonZeroU64; use core::ptr; @@ -19,13 +18,14 @@ use core::sync::atomic::AtomicU8; use bitflags::bitflags; use crate::backend::c::{c_int, c_uint, c_void}; -use crate::backend::process::syscalls; +use crate::backend::prctl::syscalls; use crate::ffi::{CStr, CString}; use crate::io; -use crate::process::{ - prctl_1arg, prctl_2args, prctl_3args, prctl_get_at_arg2_optional, Pid, - PointerAuthenticationKeys, +use crate::pid::Pid; +use crate::prctl::{ + prctl_1arg, prctl_2args, prctl_3args, prctl_get_at_arg2_optional, PointerAuthenticationKeys, }; +use crate::utils::as_ptr; // // PR_GET_KEEPCAPS/PR_SET_KEEPCAPS @@ -54,7 +54,7 @@ const PR_SET_KEEPCAPS: c_int = 8; /// [`prctl(PR_SET_KEEPCAPS,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html #[inline] pub fn set_keep_capabilities(enable: bool) -> io::Result<()> { - unsafe { prctl_2args(PR_SET_KEEPCAPS, enable as usize as *mut _) }.map(|_r| ()) + unsafe { prctl_2args(PR_SET_KEEPCAPS, usize::from(enable) as *mut _) }.map(|_r| ()) } // @@ -411,6 +411,8 @@ const PR_GET_SECUREBITS: c_int = 27; bitflags! { /// `SECBIT_*`. + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct CapabilitiesSecureBits: u32 { /// If this bit is set, then the kernel does not grant capabilities when /// a `set-user-ID-root` program is executed, or when a process with an effective or real @@ -520,7 +522,7 @@ const PR_SET_NO_NEW_PRIVS: c_int = 38; /// [`prctl(PR_SET_NO_NEW_PRIVS,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html #[inline] pub fn set_no_new_privs(no_new_privs: bool) -> io::Result<()> { - unsafe { prctl_2args(PR_SET_NO_NEW_PRIVS, no_new_privs as usize as *mut _) }.map(|_r| ()) + unsafe { prctl_2args(PR_SET_NO_NEW_PRIVS, usize::from(no_new_privs) as *mut _) }.map(|_r| ()) } // @@ -568,7 +570,7 @@ const PR_SET_THP_DISABLE: c_int = 41; /// [`prctl(PR_SET_THP_DISABLE,...)`]: https://man7.org/linux/man-pages/man2/prctl.2.html #[inline] pub fn disable_transparent_huge_pages(thp_disable: bool) -> io::Result<()> { - unsafe { prctl_2args(PR_SET_THP_DISABLE, thp_disable as usize as *mut _) }.map(|_r| ()) + unsafe { prctl_2args(PR_SET_THP_DISABLE, usize::from(thp_disable) as *mut _) }.map(|_r| ()) } // @@ -732,6 +734,8 @@ const PR_MTE_TAG_MASK: u32 = 0xffff_u32 << PR_MTE_TAG_SHIFT; bitflags! { /// Zero means addresses that are passed for the purpose of being dereferenced by the kernel must be untagged. + #[repr(transparent)] + #[derive(Copy, Clone, Eq, PartialEq, Hash, Debug)] pub struct TaggedAddressMode: u32 { /// Addresses that are passed for the purpose of being dereferenced by the kernel may be tagged. const ENABLED = 1_u32 << 0; @@ -854,7 +858,7 @@ pub unsafe fn enable_syscall_user_dispatch( PR_SYS_DISPATCH_ON as *mut _, always_allowed_region.as_ptr() as *mut _, always_allowed_region.len() as *mut _, - fast_switch_flag as *const AtomicU8 as *mut _, + as_ptr(fast_switch_flag) as *mut _, ) .map(|_r| ()) } |