|
@@ -2111,6 +2111,7 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
int retval = 0;
|
|
|
int flag = 0;
|
|
|
int ispipe;
|
|
|
+ bool need_nonrelative = false;
|
|
|
static atomic_t core_dump_count = ATOMIC_INIT(0);
|
|
|
struct coredump_params cprm = {
|
|
|
.signr = signr,
|
|
@@ -2136,14 +2137,16 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
if (!cred)
|
|
|
goto fail;
|
|
|
/*
|
|
|
- * We cannot trust fsuid as being the "true" uid of the
|
|
|
- * process nor do we know its entire history. We only know it
|
|
|
- * was tainted so we dump it as root in mode 2.
|
|
|
+ * We cannot trust fsuid as being the "true" uid of the process
|
|
|
+ * nor do we know its entire history. We only know it was tainted
|
|
|
+ * so we dump it as root in mode 2, and only into a controlled
|
|
|
+ * environment (pipe handler or fully qualified path).
|
|
|
*/
|
|
|
if (__get_dumpable(cprm.mm_flags) == 2) {
|
|
|
/* Setuid core dump mode */
|
|
|
flag = O_EXCL; /* Stop rewrite attacks */
|
|
|
cred->fsuid = GLOBAL_ROOT_UID; /* Dump root private */
|
|
|
+ need_nonrelative = true;
|
|
|
}
|
|
|
|
|
|
retval = coredump_wait(exit_code, &core_state);
|
|
@@ -2223,6 +2226,14 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
if (cprm.limit < binfmt->min_coredump)
|
|
|
goto fail_unlock;
|
|
|
|
|
|
+ if (need_nonrelative && cn.corename[0] != '/') {
|
|
|
+ printk(KERN_WARNING "Pid %d(%s) can only dump core "\
|
|
|
+ "to fully qualified path!\n",
|
|
|
+ task_tgid_vnr(current), current->comm);
|
|
|
+ printk(KERN_WARNING "Skipping core dump\n");
|
|
|
+ goto fail_unlock;
|
|
|
+ }
|
|
|
+
|
|
|
cprm.file = filp_open(cn.corename,
|
|
|
O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
|
|
|
0600);
|