Bug 104310 - prctl(PR_SET_DUMPABLE, 1) is ignored
prctl(PR_SET_DUMPABLE, 1) is ignored
Status: CLOSED ERRATA
Product: Red Hat Linux
Classification: Retired
Component: kernel (Show other bugs)
9
i386 Linux
medium Severity medium
: ---
: ---
Assigned To: Dave Jones
Brian Brock
:
: 98825 (view as bug list)
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2003-09-12 09:27 EDT by Hrunting Johnson
Modified: 2015-01-04 17:03 EST (History)
4 users (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed: 2004-01-04 22:44:43 EST
Type: ---
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Hrunting Johnson 2003-09-12 09:27:21 EDT
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.5b)
Gecko/20030910 Firebird/0.6.1+

Description of problem:
Normally, setuid() programs can't dump core.  However, a setuid() program should
be able to use prctl() (man prctl) to enable coredumps.  Under this kernel, that
doesn't seem to be the case.  

Basically, the end result is one cannot do any debugging of setuid programs,
which is a serious hinderance to the use of Linux as a development platform.

Here is a test script:

#include <stdio.h>
#include <sys/prctl.h>

int main(int argc, char* argv[]) {
  setuid(9);
  prctl(PR_SET_DUMPABLE, 1, 0, 0, 0);
  printf("sleeping for 20 seconds; kill me now\n");
  sleep(20);
  exit(0);
}

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

How reproducible:
Always

Steps to Reproduce:
1. ulimit -c unlimited
2. gcc t.c
3. ./a.out &
3. kill -SEGV <pid>
    

Actual Results:  Program dies, no core file is left

Expected Results:  Program dies, core file is left

Additional info:

Possibly related to this problem:
http://www.ussg.iu.edu/hypermail/linux/kernel/0305.1/0232.html
http://www.ussg.iu.edu/hypermail/linux/kernel/0304.3/0434.html
Comment 1 Joe Orton 2003-12-02 05:15:46 EST
*** Bug 98825 has been marked as a duplicate of this bug. ***
Comment 2 Joe Orton 2003-12-02 05:34:48 EST
This affects current 7.3 through 9 kernels.  Simple repro case:

#include <sys/types.h>
#include <sys/prctl.h>
#include <unistd.h>
#include <stdio.h>
#include <signal.h>

int main(int argc, char **argv)
{
    if (prctl(PR_SET_DUMPABLE, 0) || prctl(PR_SET_DUMPABLE, 1)) {
        perror("prctl(PR_SET_DUMPABLE)");
        return 1;
    }
    
    if (prctl(PR_GET_DUMPABLE) != 1) {
        fprintf(stderr, "prctl(PR_SET_DUMPABLE, 1) was ignored.\n");
        return 1;
    }

    printf("OK.\n");
    return 0;
}
Comment 3 Joe Orton 2003-12-02 05:38:16 EST
The fix is as simple as below IIRC:

--- kernel/sys.c.orig   Tue Dec  2 10:30:02 2003
+++ kernel/sys.c        Tue Dec  2 10:30:29 2003
@@ -1242,7 +1242,6 @@
                                error = -EINVAL;
                                break;
                        }
-                       if (is_dumpable(current))
                                current->mm->dumpable = arg2;
                        break;
                case PR_SET_UNALIGN:

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