|
@@ -63,6 +63,7 @@
|
|
|
|
|
|
int core_uses_pid;
|
|
|
char core_pattern[CORENAME_MAX_SIZE] = "core";
|
|
|
+unsigned int core_pipe_limit;
|
|
|
int suid_dumpable = 0;
|
|
|
|
|
|
/* The maximal length of core_pattern is also specified in sysctl.c */
|
|
@@ -1744,7 +1745,8 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
unsigned long core_limit = current->signal->rlim[RLIMIT_CORE].rlim_cur;
|
|
|
char **helper_argv = NULL;
|
|
|
int helper_argc = 0;
|
|
|
- char *delimit;
|
|
|
+ int dump_count = 0;
|
|
|
+ static atomic_t core_dump_count = ATOMIC_INIT(0);
|
|
|
|
|
|
audit_core_dumps(signr);
|
|
|
|
|
@@ -1826,28 +1828,36 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
goto fail_unlock;
|
|
|
}
|
|
|
|
|
|
+ dump_count = atomic_inc_return(&core_dump_count);
|
|
|
+ if (core_pipe_limit && (core_pipe_limit < dump_count)) {
|
|
|
+ printk(KERN_WARNING "Pid %d(%s) over core_pipe_limit\n",
|
|
|
+ task_tgid_vnr(current), current->comm);
|
|
|
+ printk(KERN_WARNING "Skipping core dump\n");
|
|
|
+ goto fail_dropcount;
|
|
|
+ }
|
|
|
+
|
|
|
helper_argv = argv_split(GFP_KERNEL, corename+1, &helper_argc);
|
|
|
if (!helper_argv) {
|
|
|
printk(KERN_WARNING "%s failed to allocate memory\n",
|
|
|
__func__);
|
|
|
- goto fail_unlock;
|
|
|
+ goto fail_dropcount;
|
|
|
}
|
|
|
|
|
|
core_limit = RLIM_INFINITY;
|
|
|
|
|
|
/* SIGPIPE can happen, but it's just never processed */
|
|
|
- if (call_usermodehelper_pipe(corename+1, helper_argv, NULL,
|
|
|
+ if (call_usermodehelper_pipe(helper_argv[0], helper_argv, NULL,
|
|
|
&file)) {
|
|
|
printk(KERN_INFO "Core dump to %s pipe failed\n",
|
|
|
corename);
|
|
|
- goto fail_unlock;
|
|
|
+ goto fail_dropcount;
|
|
|
}
|
|
|
} else
|
|
|
file = filp_open(corename,
|
|
|
O_CREAT | 2 | O_NOFOLLOW | O_LARGEFILE | flag,
|
|
|
0600);
|
|
|
if (IS_ERR(file))
|
|
|
- goto fail_unlock;
|
|
|
+ goto fail_dropcount;
|
|
|
inode = file->f_path.dentry->d_inode;
|
|
|
if (inode->i_nlink > 1)
|
|
|
goto close_fail; /* multiple links - don't dump */
|
|
@@ -1877,6 +1887,9 @@ void do_coredump(long signr, int exit_code, struct pt_regs *regs)
|
|
|
current->signal->group_exit_code |= 0x80;
|
|
|
close_fail:
|
|
|
filp_close(file, NULL);
|
|
|
+fail_dropcount:
|
|
|
+ if (dump_count)
|
|
|
+ atomic_dec(&core_dump_count);
|
|
|
fail_unlock:
|
|
|
if (helper_argv)
|
|
|
argv_free(helper_argv);
|