]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
coredump: add support for %d=__get_dumpable() in core name
authorOleg Nesterov <oleg@redhat.com>
Wed, 26 Sep 2012 01:34:52 +0000 (11:34 +1000)
committerStephen Rothwell <sfr@canb.auug.org.au>
Thu, 27 Sep 2012 07:28:45 +0000 (17:28 +1000)
Some coredump handlers want to create a core file in a way compatible with
standard behavior.  Standard behavior with fs.suid_dumpable = 2 is to
create core file with uid=gid=0.  However, there was no way for coredump
handler to know that the process being dumped was suid'ed.

This patch adds the new %d specifier for format_corename() which simply
reports __get_dumpable(mm->flags), this is compatible with
/proc/sys/fs/suid_dumpable we already have.

Addresses https://bugzilla.redhat.com/show_bug.cgi?id=787135

Developed during a discussion with Denys Vlasenko.

Signed-off-by: Oleg Nesterov <oleg@redhat.com>
Cc: Denys Vlasenko <vda.linux@googlemail.com>
Cc: Alex Kelly <alex.page.kelly@gmail.com>
Cc: Andi Kleen <andi@firstfloor.org>
Cc: Cong Wang <amwang@redhat.com>
Cc: Jiri Moskovcak <jmoskovc@redhat.com>
Acked-by: Neil Horman <nhorman@tuxdriver.com>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
fs/coredump.c

index c01aa7b9ab5ddb3ac78e98cbcfad31ccf1220b07..4fce06fc3b56dceaacaa0fd690481991449040de 100644 (file)
@@ -149,7 +149,7 @@ put_exe_file:
  * name into corename, which must have space for at least
  * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
  */
-static int format_corename(struct core_name *cn, long signr)
+static int format_corename(struct core_name *cn, struct coredump_params *cprm)
 {
        const struct cred *cred = current_cred();
        const char *pat_ptr = core_pattern;
@@ -194,9 +194,13 @@ static int format_corename(struct core_name *cn, long signr)
                        case 'g':
                                err = cn_printf(cn, "%d", cred->gid);
                                break;
+                       case 'd':
+                               err = cn_printf(cn, "%d",
+                                       __get_dumpable(cprm->mm_flags));
+                               break;
                        /* signal that caused the coredump */
                        case 's':
-                               err = cn_printf(cn, "%ld", signr);
+                               err = cn_printf(cn, "%ld", cprm->signr);
                                break;
                        /* UNIX time of coredump */
                        case 't': {
@@ -515,7 +519,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
         */
        clear_thread_flag(TIF_SIGPENDING);
 
-       ispipe = format_corename(&cn, signr);
+       ispipe = format_corename(&cn, &cprm);
 
        if (ispipe) {
                int dump_count;