From ef24de24a82fe681581cc130f342363c47c0969a Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 7 Jun 2024 07:48:48 +0200 Subject: Merging upstream version 1.75.0+dfsg1. Signed-off-by: Daniel Baumann --- vendor/rustix/src/runtime.rs | 46 ++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 42 insertions(+), 4 deletions(-) (limited to 'vendor/rustix/src/runtime.rs') diff --git a/vendor/rustix/src/runtime.rs b/vendor/rustix/src/runtime.rs index 2cb0eba54..3c754a62f 100644 --- a/vendor/rustix/src/runtime.rs +++ b/vendor/rustix/src/runtime.rs @@ -4,7 +4,7 @@ //! Do not use the functions in this module unless you've read all of their //! code. They don't always behave the same way as functions with similar names //! in `libc`. Sometimes information about the differences is included in the -//! Linux documentation under "C library/kernel differences" sections. And, if +//! Linux documentation under “C library/kernel differences” sections. And, if //! there is a libc in the process, these functions may have surprising //! interactions with it. //! @@ -89,7 +89,7 @@ pub unsafe fn arm_set_tls(data: *mut c_void) -> io::Result<()> { backend::runtime::syscalls::tls::arm_set_tls(data) } -/// `prctl(PR_SET_FS, data)`—Set the x86_64 `fs` register. +/// `prctl(PR_SET_FS, data)`—Set the x86-64 `fs` register. /// /// # Safety /// @@ -101,7 +101,7 @@ pub unsafe fn set_fs(data: *mut c_void) { backend::runtime::syscalls::tls::set_fs(data) } -/// Set the x86_64 thread ID address. +/// Set the x86-64 thread ID address. /// /// # Safety /// @@ -188,7 +188,7 @@ pub const EXIT_FAILURE: i32 = backend::c::EXIT_FAILURE; /// Return fields from the main executable segment headers ("phdrs") relevant /// to initializing TLS provided to the program at startup. /// -/// `addr` will always be non-null, even when the TLS data is absent, ao that +/// `addr` will always be non-null, even when the TLS data is absent, so that /// the `addr` and `file_size` parameters are suitable for creating a slice /// with `slice::from_raw_parts`. #[inline] @@ -485,3 +485,41 @@ pub unsafe fn sigwaitinfo(set: &Sigset) -> io::Result { pub unsafe fn sigtimedwait(set: &Sigset, timeout: Option) -> io::Result { backend::runtime::syscalls::sigtimedwait(set, timeout) } + +/// `getauxval(AT_SECURE)`—Returns the Linux “secure execution” mode. +/// +/// Return a boolean value indicating whether “secure execution” mode was +/// requested, due to the process having elevated privileges. This includes +/// whether the `AT_SECURE` AUX value is set, and whether the initial real UID +/// and GID differ from the initial effective UID and GID. +/// +/// The meaning of “secure execution” mode is beyond the scope of this comment. +/// +/// # References +/// - [Linux] +/// +/// [Linux]: https://man7.org/linux/man-pages/man3/getauxval.3.html +#[cfg(any( + linux_raw, + any( + all(target_os = "android", target_pointer_width = "64"), + target_os = "linux", + ) +))] +#[inline] +pub fn linux_secure() -> bool { + backend::param::auxv::linux_secure() +} + +/// `brk(addr)`—Change the location of the “program break”. +/// +/// # Safety +/// +/// This is not identical to `brk` in libc. libc `brk` may have bookkeeping +/// that needs to be kept up to date that this doesn't keep up to date, so +/// don't use it unless you are implementing libc. +#[cfg(linux_raw)] +#[inline] +pub unsafe fn brk(addr: *mut c_void) -> io::Result<*mut c_void> { + backend::runtime::syscalls::brk(addr) +} -- cgit v1.2.3