+++ This bug was initially created as a clone of Bug #285761 +++ /proc/<pid>/maps is already accessible for RHEL-5.2. Description of problem: I trace a process using ptrace and the PTRACE_O_TRACEEXIT option. When I get the PTRACE_EVENT_EXIT notification for the process I examine its /proc/<pid>/environ. This works on RECENT vanilla Linux kernels. I am not aware of any applications depending on such feature. Version-Release number of selected component (if applicable): kernel-2.6.18-53.1.13.el5.x86_64 (it works on upstream kernel 2.6.25-0.101.rc4.git3.fc8 x86_64) (it works on F-8 kernel kernel-2.6.24.3-12.fc8.x86_64) How reproducible: Every time. Steps to Reproduce: 1. wget -O event-exit-proc-environ.c 'http://sources.redhat.com/cgi-bin/cvsweb.cgi/~checkout~/tests/ptrace-tests/tests/event-exit-proc-environ.c?cvsroot=systemtap' 2. gcc -o event-exit-proc-environ event-exit-proc-environ.c -Wall -ggdb2 -D_GNU_SOURCE 3. ./event-exit-proc-environ; echo $? Actual results: /proc/15504/environ has uid 0 and mode 0400 ./event-exit-proc-environ: Failed to open /proc/15504/environ: error 13: Permission denied 1 Expected results: 0 -- Additional comment from roland on 2007-10-10 23:06 EST -- This problem is not really related to ptrace. It's a Fedora difference that AFAICT is more or less intentional, but at any rate I am not the sole person to ask about it. The issue is that Fedora makes maps et al not world-readable. In all kernels, the core dump code (even with ulimit -c 0) clears the process's (mm's) "dumpable" flag. Once this flag is clear, the /proc/pid file access all acts with the files owned by root rather than by the euid. Since maps has mode 400 in Fedora (444 upstream), you can't read it when it belongs to root, so you can no longer open your own child's /proc files for reading. This is probably an unintended confluence of factors motivated by different things. The 400 vs 444 is an intended security change in Fedora. The permission meaning of dumpable=0 is intended for keeping secure things that changed uids or something like that--a privileged daemon that switches to your uid does not dump a core file owned by you. The core dump code clearing dumpable is probably part of some necessary synchronization plan or something. All added together, they have the effect of denying a permission noone ever intended to deny (/proc files of a task that is in the process of dying by a core signal)--but this can only be seen in non-racy conditions when you are either looking at a zombie (which has no such info as e.g. maps left to show anyway) or are looking at a PTRACE_EVENT_EXIT stop. -- Additional comment from roland on 2007-10-10 23:07 EST -- linux-2.6-execshield.patch is what changes the fs/proc/base.c permissions to cause this. -- Additional comment from roland on 2007-10-11 06:38 EST -- http://lkml.org/lkml/2007/10/11/16 -- Additional comment from roland on 2007-11-12 17:18 EST -- http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commit;h=00ec99da43a7c2aed46c6595aa271b84bb1b1462 A variant of my fix went in upstream today. This should hit rawhide in the fullness of time. It would be trivial to backport to 2.6.23 if this is worth bothering with fixing early for Fedora [678].
This request was evaluated by Red Hat Product Management for inclusion in a Red Hat Enterprise Linux maintenance release. Product Management has requested further review of this request by Red Hat Engineering, for potential inclusion in a Red Hat Enterprise Linux Update release for currently deployed products. This request is not yet committed for inclusion in an Update release.
Posted on rhkl: http://post-office.corp.redhat.com/archives/rhkernel-list/2008-July/msg00283.html
in kernel-2.6.18-104.el5 You can download this test kernel from http://people.redhat.com/dzickus/el5
An advisory has been issued which should help the problem described in this bug report. This report is therefore being closed with a resolution of ERRATA. For more information on therefore solution and/or where to find the updated files, please follow the link below. You may reopen this bug report if the solution does not work for you. http://rhn.redhat.com/errata/RHSA-2009-0225.html