2

I would like to get uid of a pid. Please note that the uid that I want to get is NOT of the current process. Please let me know if you have an idea. Maybe can I get it by reuse the function of /proc/[pid]/status read function in kernel? //Bruce

Happy
  • 133
  • 8

1 Answers1

2
  1. Search process descriptor (struct task_struct) with given pid.

  2. Use task->cred->uid.

Struct struct task_struct is defined in include/linux/sched.h. Struct struct cred is defined in include/linux/cred.h.

Note, that iterating through processes and reading process's credentials should be done under RCU-critical section.

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153