summaryrefslogtreecommitdiffstats
path: root/rust/kernel/security.rs
diff options
context:
space:
mode:
authorDmitry Torokhov <dmitry.torokhov@gmail.com>2025-12-13 01:18:20 -0800
committerDmitry Torokhov <dmitry.torokhov@gmail.com>2025-12-13 01:18:20 -0800
commita4a508df2aa34f8650afde54ea804321c618f45f (patch)
treef75f10e7c54f991d7d859f8cbdcc8bcaed5bbd6f /rust/kernel/security.rs
parentc4b3133c6a2fc283cb3d34c64d40ed2fa254b608 (diff)
parent7d0a66e4bb9081d75c82ec4957c50034cb0ea449 (diff)
downloadlinux-a4a508df2aa34f8650afde54ea804321c618f45f.tar.gz
linux-a4a508df2aa34f8650afde54ea804321c618f45f.zip
Merge tag 'v6.18' into next
Sync up with the mainline to bring in the latest APIs.
Diffstat (limited to 'rust/kernel/security.rs')
-rw-r--r--rust/kernel/security.rs37
1 files changed, 37 insertions, 0 deletions
diff --git a/rust/kernel/security.rs b/rust/kernel/security.rs
index 0c63e9e7e564..9d271695265f 100644
--- a/rust/kernel/security.rs
+++ b/rust/kernel/security.rs
@@ -8,9 +8,46 @@
use crate::{
bindings,
+ cred::Credential,
error::{to_result, Result},
+ fs::File,
};
+/// Calls the security modules to determine if the given task can become the manager of a binder
+/// context.
+#[inline]
+pub fn binder_set_context_mgr(mgr: &Credential) -> Result {
+ // SAFETY: `mrg.0` is valid because the shared reference guarantees a nonzero refcount.
+ to_result(unsafe { bindings::security_binder_set_context_mgr(mgr.as_ptr()) })
+}
+
+/// Calls the security modules to determine if binder transactions are allowed from task `from` to
+/// task `to`.
+#[inline]
+pub fn binder_transaction(from: &Credential, to: &Credential) -> Result {
+ // SAFETY: `from` and `to` are valid because the shared references guarantee nonzero refcounts.
+ to_result(unsafe { bindings::security_binder_transaction(from.as_ptr(), to.as_ptr()) })
+}
+
+/// Calls the security modules to determine if task `from` is allowed to send binder objects
+/// (owned by itself or other processes) to task `to` through a binder transaction.
+#[inline]
+pub fn binder_transfer_binder(from: &Credential, to: &Credential) -> Result {
+ // SAFETY: `from` and `to` are valid because the shared references guarantee nonzero refcounts.
+ to_result(unsafe { bindings::security_binder_transfer_binder(from.as_ptr(), to.as_ptr()) })
+}
+
+/// Calls the security modules to determine if task `from` is allowed to send the given file to
+/// task `to` (which would get its own file descriptor) through a binder transaction.
+#[inline]
+pub fn binder_transfer_file(from: &Credential, to: &Credential, file: &File) -> Result {
+ // SAFETY: `from`, `to` and `file` are valid because the shared references guarantee nonzero
+ // refcounts.
+ to_result(unsafe {
+ bindings::security_binder_transfer_file(from.as_ptr(), to.as_ptr(), file.as_ptr())
+ })
+}
+
/// A security context string.
///
/// # Invariants