RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.
Bug 787686 - pstree does not handle correctly /proc/ when it's mounted with hidepid=1/2 option
Summary: pstree does not handle correctly /proc/ when it's mounted with hidepid=1/2 op...
Keywords:
Status: CLOSED ERRATA
Alias: None
Product: Red Hat Enterprise Linux 6
Classification: Red Hat
Component: psmisc
Version: 6.2
Hardware: Unspecified
OS: Unspecified
unspecified
unspecified
Target Milestone: rc
: ---
Assignee: Jan Rybar
QA Contact: Jakub Heger
URL:
Whiteboard:
Depends On:
Blocks:
TreeView+ depends on / blocked
 
Reported: 2012-02-06 14:15 UTC by Jerome Marchand
Modified: 2017-03-21 11:41 UTC (History)
3 users (show)

Fixed In Version: psmisc-22.6-23.el6
Doc Type: If docs needed, set a value
Doc Text:
Clone Of:
: 787688 (view as bug list)
Environment:
Last Closed: 2017-03-21 11:41:37 UTC
Target Upstream Version:
Embargoed:


Attachments (Terms of Use)
Proposed patch - show accessible processes if hidepid on (431 bytes, patch)
2016-09-14 14:35 UTC, Jan Rybar
no flags Details | Diff
Upstream backport patch, fix orphan processes (2.51 KB, patch)
2016-12-02 14:48 UTC, Jan Rybar
no flags Details | Diff


Links
System ID Private Priority Status Summary Last Updated
Red Hat Product Errata RHBA-2017:0771 0 normal SHIPPED_LIVE psmisc bug fix update 2017-03-21 12:48:08 UTC

Description Jerome Marchand 2012-02-06 14:15:26 UTC
Description of problem:
I'm about to post a patch for the kernel that add hidepid option to procfs. That option restricts access to
/proc/ for security reasons. The comment of upstream commit indicates that when access to /proc/ is restricted pstree shows the subtree that contains pstree process. However, on RHEL6, pstree shows nothing.

Version-Release number of selected component (if applicable):


How reproducible:
Allways

Steps to Reproduce:
1. Install a kernel with hidpid option. You can found one at
https://brewweb.devel.redhat.com/taskinfo?taskID=4002146
2. remount /proc with hidepid=1 or hidepid=2 enable
mount -o remount,hidepid=1 /proc/
3. run pstree
  
Actual results:
pstree does not display anything

Expected results:
pstree displays a subtree of processes which it has access to in /proc/<pid>/

Additional info:

Comment 3 Suzanne Logcher 2012-02-14 23:31:00 UTC
This request was evaluated by Red Hat Product Management for
inclusion in the current release of Red Hat Enterprise Linux.
Because the affected component is not scheduled to be updated
in the current release, Red Hat is unfortunately unable to
address this request at this time. Red Hat invites you to
ask your support representative to propose this request, if
appropriate and relevant, in the next release of Red Hat
Enterprise Linux. If you would like it considered as an
exception in the current release, please ask your support
representative.

Comment 4 Jaromír Cápík 2016-01-18 13:01:45 UTC
Hello Jerome.

In my case the output is not empty, but it is missing accessible processes where the parents are inaccessible.

Comment 6 Jan Rybar 2016-08-30 09:36:00 UTC
I cannot reproduce the issue either. Output not empty on RHEL6.6, 2.6.32-642.el6.x86_64.

Comment 7 Jerome Marchand 2016-09-07 08:20:41 UTC
(In reply to Jan Rybar from comment #6)
> I cannot reproduce the issue either. Output not empty on RHEL6.6,
> 2.6.32-642.el6.x86_64.

The output is not empty, but does it contains all accessible processes?

[jmarchan@virt_rhel6 ~]$ pstree
init─┬─NetworkManager─┬─dhclient
     │                └─{NetworkManager}
[...]
     ├─sshd─┬─sshd───sshd───bash─┬─pstree
     │      │                    └─vi
     │      └─sshd───bash
     ├─udevd───2*[udevd]
     └─wpa_supplicant
[jmarchan@virt_rhel6 ~]$ ps -u jmarchan
  PID TTY          TIME CMD
 2698 ?        00:00:00 sshd
 2699 pts/0    00:00:01 bash
 9262 pts/0    00:00:00 vi
23192 pts/0    00:00:00 ps
[jmarchan@virt_rhel6 ~]$ sudo mount -o remount,hidepid=1 /proc/
[jmarchan@virt_rhel6 ~]$ pstree
[jmarchan@virt_rhel6 ~]$ ps -u jmarchan
  PID TTY          TIME CMD
 2699 pts/0    00:00:01 bash
 9262 pts/0    00:00:00 vi
23196 pts/0    00:00:00 ps

Note that sshd disappeared from ps output too. This is because it is suid root and thus it directory in /proc/ is also inaccessible to unprivileged processes.

If I run a program that forks a lot, the output is not empty anymore, yet there are still a number of process missing (see Jaromir's comment about the parent being inaccessible).

[jmarchan@virt_rhel6 ~]$ ./bz1151823/fork_snake
[jmarchan@virt_rhel6 ~]$ pstree
?───11*[fork_snake───fork_snake───fork_snake───fork_snake───fork_snake───fork_sn+
[jmarchan@virt_rhel6 ~]$

The changelog of upstream psmisc mention a fix regarding hidepid that landed in 22.17:
"Changes in 22.17
[...]
Fake pstree root for kernels with hidepid turned on"

Comment 8 Jan Rybar 2016-09-14 14:35:24 UTC
Created attachment 1200836 [details]
Proposed patch - show accessible processes if hidepid on

Comment 14 Jan Rybar 2016-12-02 14:48:02 UTC
Created attachment 1227351 [details]
Upstream backport patch, fix orphan processes

Comment 17 errata-xmlrpc 2017-03-21 11:41:37 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory, and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://rhn.redhat.com/errata/RHBA-2017-0771.html


Note You need to log in before you can comment on or make changes to this bug.