I have a task_struct *
that I got by calling find_task_by_vpid(get_pid())
. I'd like to figure out what user owns that process so that I can do some permission checking in the system call I'm writing, but looking through the task_struct
source code hasn't helped much. The only thing that looked helpful is the loginuid
, but for some reason the kernel won't compile if I try to access it like this: my_task_struct->loginuid
. Is there another way to get the user who called the process from the task_struct
?
Unfortunately, the user/group ids are no longer stored in the task struct, but instead in a separate privilege structure that's dynamically allocated and shared between all tasks that have the same ids. This in turn creates a situation where setuid
can fail due to resource exhaustion, and failure of setuid
to prop privileges is an infamous source of vulnerabilities...
Anyway, it's in these members of the task_struct
:
const struct cred __rcu *real_cred; /* objective and real subjective task
* credentials (COW) */
const struct cred __rcu *cred; /* effective (overridable) subjective task
* credentials (COW) */
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With