Bug 1288208

Summary: use of /proc/self/auxv breaks ps when running as a different euid
Product: Red Hat Enterprise Linux 6 Reporter: Todd Stansell <todd+rhbugs>
Component: procpsAssignee: Ondrej Vasik <ovasik>
Status: CLOSED ERRATA QA Contact: Branislav Náter <bnater>
Severity: unspecified Docs Contact: Petr Bokoc <pbokoc>
Priority: unspecified    
Version: 6.8CC: albert, bnater, pbokoc
Target Milestone: rcKeywords: Patch
Target Release: ---   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: procps-3.2.8-36.el6 Doc Type: Bug Fix
Doc Text:
With the recent fix of crash in the find_elf_note function a new limitation in the usage appeared. The fix was based on a reading of the /proc/self/auxv file instead of reading the notes directly from the memory, but when running with a different euid, the file content became inaccessible and the procps library init failed with "/proc/self/auxv: Permission denied". The fix allowed to call the library functions with dlopen, but prevented users from using the library and procps tools with different euid. This update introduces a fallback to the previous approach when the /proc/self/auxv file is inaccessible. That, however, means the mentioned conditions are mutually exclusive and the library functions cannot be called with dlopen and different euid at the same time.
Story Points: ---
Clone Of: Environment:
Last Closed: 2016-05-11 00:29:05 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Attachments:
Description Flags
procps-3.2.8-find_elf_note-memory-error-fix.patch none

Description Todd Stansell 2015-12-03 20:13:54 UTC
Description of problem:
The change from bug 1163404 seems to introduce an issue where a process that has changed it's effective uid can no longer access /proc/self/auxv, preventing ps from running (even --help).

Version-Release number of selected component (if applicable):
procps-3.2.8-31.el6

How reproducible:
Always fails when process has changed euid.

Steps to Reproduce:
1. install procps-3.2.8-31.el6 or newer
2. run the following perl script as root that changes the euid and tries to call ps:

#!/usr/bin/perl
($),$>) = (1000,1000);
my $psOutput = `/bin/ps --help`;
print "output: $psOutput\n";

Actual results:
# perl /var/tmp/test-ps.pl
/proc/self/auxv: Permission denied
output:

Expected results:
# perl /var/tmp/test-ps.pl
output: ********* simple selection *********  ********* selection by list *********
-A all processes                      -C by command name
-N negate selection                   -G by real group ID (supports names)
-a all w/ tty except session leaders  -U by real user ID (supports names)
-d all except session leaders         -g by session OR by effective group name
-e all processes                      -p by process ID
...

Additional info:

Comment 2 Jaromír Cápík 2015-12-04 09:37:00 UTC
Hello Todd.

Thanks a lot for the report. This apparently becomes more complicated than we thought. Reverting the change back is also no option. I'm thinking about a fallback based on the previous solution where a failure of the new approach would lead to retry with the old approach. But I'll think about that once again and if a better solution exists, I'll try to redesign that in a different way.

Comment 3 Jaromír Cápík 2015-12-16 13:16:50 UTC
Created attachment 1106403 [details]
procps-3.2.8-find_elf_note-memory-error-fix.patch

replacement for the previous elf note patch

Comment 9 errata-xmlrpc 2016-05-11 00:29:05 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-2016-0904.html