diff --git a/rust/kernel/task.rs b/rust/kernel/task.rs index d2f2615fe4a1b3..675f4dbee46ed7 100644 --- a/rust/kernel/task.rs +++ b/rust/kernel/task.rs @@ -164,7 +164,7 @@ impl Task { /// Returns the given task's pid in the current pid namespace. pub fn pid_in_current_ns(&self) -> Pid { // SAFETY: Calling `task_active_pid_ns` with the current task is always safe. - let namespace = unsafe { bindings::task_active_pid_ns(bindings::get_current()) }; + let namespace = unsafe { bindings::task_active_pid_ns(current!()) }; // SAFETY: We know that `self.0.get()` is valid by the type invariant. unsafe { bindings::task_tgid_nr_ns(self.0.get(), namespace) } } @@ -176,6 +176,15 @@ impl Task { // running. unsafe { bindings::wake_up_process(self.0.get()) }; } + + /// Returns a raw pointer to the underlying C task struct. + /// + /// # Safety + /// + /// Callers must ensure that the pointer is not used after `Task` is invalidated. + pub unsafe fn as_raw(&self) -> *const bindings::task_struct { + self.0.get() + } } impl Kuid {