Get uid from pid (process id) from kernel level code

I would like to get uid pid. Note that the uid I want to get does NOT apply to the current process. Please let me know if you have an idea. Maybe I can get it by reusing the / proc / [pid] / function to read the state in the kernel? // Bruce

+1
source share
1 answer
  • A handle to the search process ( struct task_struct) with the given pid.

  • Use task->cred->uid.

Struct is struct task_structdefined in include/linux/sched.h. Struct is struct creddefined in include/linux/cred.h.

Note that iteration through the processes and credentials of the read process must be performed in the RCU-critical section.

+1

Source: https://habr.com/ru/post/1652389/


All Articles