Procfs: Difference between revisions

 
(3 intermediate revisions by the same user not shown)
Line 13: Line 13:
Since time immemorial, tools like <tt>ps</tt> have enumerated processes via walking procfs's dentries when possible.
Since time immemorial, tools like <tt>ps</tt> have enumerated processes via walking procfs's dentries when possible.


procfs since Linux 3.3 accepts a mount option <tt>hidepid</tt>, taking one of three values:
procfs since Linux 3.3 accepts a mount option <tt>hidepid</tt>, taking one of four values:
* 0: everyone may access all <tt>proc/PID</tt> directories
* 0: everyone may access all <tt>proc/PID</tt> directories
* 1: users can only access their own <tt>proc/PID</tt> directories
* 1: users can only access their own <tt>proc/PID</tt> directories
* 2: users can only *see* their own <tt>proc/PID</tt> directories
* 2: users can only *see* their own <tt>proc/PID</tt> directories
* 4: users can only see directories of processes they can [[ptrace]]
Linux 3.3 also introduced the <tt>gid</tt> parameter, which specifies a group ID. Members of this group are exempted from <tt>hidepid</tt> restrictions.
Linux 3.3 also introduced the <tt>gid</tt> parameter, which specifies a group ID. Members of this group are exempted from <tt>hidepid</tt> restrictions.
Note that if you start a process as one user, and change to another user using e.g. <tt>setuid(2)</tt>, you might no longer be able to access your own <tt>/proc/PID</tt>.
===<tt>proc/PID/loginuid</tt>===
Note that this is only present when <tt>CONFIG_AUDIT</tt> is enabled in the kernel configuration. Audit doesn't have to be enabled, and auditd doesn't need to be running, but without that option, no <tt>loginuid</tt> for you.


===<tt>proc/PID/stat</tt> sucks===
===<tt>proc/PID/stat</tt> sucks===
Line 84: Line 90:
</pre>
</pre>


Unfortunately, <tt>proc/PID/status</tt> cheerfully leaves out several fields from <tt>stat</tt>, including <tt>flags</tt>, so it's like what was the point of that exactly. Ugh.
Unfortunately, <tt>proc/PID/status</tt> cheerfully leaves out several fields from <tt>stat</tt>, including <tt>flags</tt> and all the timing information, so it's like what was the point of that exactly. Ugh.


==See Also==
==See Also==
* The [[sysfs]] page
* The [[sysfs]] page
* UNIX V8 [http://man.cat-v.org/unix_8th/4/proc proc(4)] man page
* UNIX V8 [http://man.cat-v.org/unix_8th/4/proc proc(4)] man page