diff options
author | Oleg Nesterov <oleg@redhat.com> | 2012-10-04 20:15:25 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2012-10-05 14:05:15 -0400 |
commit | 12a2b4b2241e318b4f6df31228e4272d2c2968a1 (patch) | |
tree | 569ce8d4d64fa163a997d98fb9dd20d275c72068 | |
parent | 179899fd5dc780fe3bcd44d0eb7823e3d855c855 (diff) |
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.
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>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | Documentation/sysctl/kernel.txt | 2 | ||||
-rw-r--r-- | fs/coredump.c | 10 |
2 files changed, 9 insertions, 3 deletions
diff --git a/Documentation/sysctl/kernel.txt b/Documentation/sysctl/kernel.txt index 6d78841fd416..2907ba6c3607 100644 --- a/Documentation/sysctl/kernel.txt +++ b/Documentation/sysctl/kernel.txt | |||
@@ -181,6 +181,8 @@ core_pattern is used to specify a core dumpfile pattern name. | |||
181 | %p pid | 181 | %p pid |
182 | %u uid | 182 | %u uid |
183 | %g gid | 183 | %g gid |
184 | %d dump mode, matches PR_SET_DUMPABLE and | ||
185 | /proc/sys/fs/suid_dumpable | ||
184 | %s signal number | 186 | %s signal number |
185 | %t UNIX time of dump | 187 | %t UNIX time of dump |
186 | %h hostname | 188 | %h hostname |
diff --git a/fs/coredump.c b/fs/coredump.c index c01aa7b9ab5d..4fce06fc3b56 100644 --- a/fs/coredump.c +++ b/fs/coredump.c | |||
@@ -149,7 +149,7 @@ put_exe_file: | |||
149 | * name into corename, which must have space for at least | 149 | * name into corename, which must have space for at least |
150 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. | 150 | * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. |
151 | */ | 151 | */ |
152 | static int format_corename(struct core_name *cn, long signr) | 152 | static int format_corename(struct core_name *cn, struct coredump_params *cprm) |
153 | { | 153 | { |
154 | const struct cred *cred = current_cred(); | 154 | const struct cred *cred = current_cred(); |
155 | const char *pat_ptr = core_pattern; | 155 | const char *pat_ptr = core_pattern; |
@@ -194,9 +194,13 @@ static int format_corename(struct core_name *cn, long signr) | |||
194 | case 'g': | 194 | case 'g': |
195 | err = cn_printf(cn, "%d", cred->gid); | 195 | err = cn_printf(cn, "%d", cred->gid); |
196 | break; | 196 | break; |
197 | case 'd': | ||
198 | err = cn_printf(cn, "%d", | ||
199 | __get_dumpable(cprm->mm_flags)); | ||
200 | break; | ||
197 | /* signal that caused the coredump */ | 201 | /* signal that caused the coredump */ |
198 | case 's': | 202 | case 's': |
199 | err = cn_printf(cn, "%ld", signr); | 203 | err = cn_printf(cn, "%ld", cprm->signr); |
200 | break; | 204 | break; |
201 | /* UNIX time of coredump */ | 205 | /* UNIX time of coredump */ |
202 | case 't': { | 206 | case 't': { |
@@ -515,7 +519,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs) | |||
515 | */ | 519 | */ |
516 | clear_thread_flag(TIF_SIGPENDING); | 520 | clear_thread_flag(TIF_SIGPENDING); |
517 | 521 | ||
518 | ispipe = format_corename(&cn, signr); | 522 | ispipe = format_corename(&cn, &cprm); |
519 | 523 | ||
520 | if (ispipe) { | 524 | if (ispipe) { |
521 | int dump_count; | 525 | int dump_count; |