Commit 12a2b4b2 authored by Oleg Nesterov's avatar Oleg Nesterov Committed by Linus Torvalds
Browse files

coredump: add support for %d=__get_dumpable() in core name

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.


Developed during a discussion with Denys Vlasenko.
Signed-off-by: default avatarOleg Nesterov <>
Cc: Denys Vlasenko <>
Cc: Alex Kelly <>
Cc: Andi Kleen <>
Cc: Cong Wang <>
Cc: Jiri Moskovcak <>
Acked-by: default avatarNeil Horman <>
Cc: Alan Cox <>
Signed-off-by: default avatarAndrew Morton <>
Signed-off-by: default avatarLinus Torvalds <>
parent 179899fd
......@@ -181,6 +181,8 @@ core_pattern is used to specify a core dumpfile pattern name.
%p pid
%u uid
%g gid
%d dump mode, matches PR_SET_DUMPABLE and
%s signal number
%t UNIX time of dump
%h hostname
......@@ -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);
case 'd':
err = cn_printf(cn, "%d",
/* signal that caused the coredump */
case 's':
err = cn_printf(cn, "%ld", signr);
err = cn_printf(cn, "%ld", cprm->signr);
/* UNIX time of coredump */
case 't': {
......@@ -515,7 +519,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
ispipe = format_corename(&cn, signr);
ispipe = format_corename(&cn, &cprm);
if (ispipe) {
int dump_count;
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment