aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOleg Nesterov <oleg@tv-sign.ru>2008-07-25 04:47:47 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-25 13:53:40 -0400
commit565b9b14e7f48131bca58840aa404bbef058fa89 (patch)
tree7925875b10dae248a9fa887c6881c544f59c6173
parenta94e2d408eaedbd85aae259621d46fafc10479a2 (diff)
coredump: format_corename: fix the "core_uses_pid" logic
I don't understand why the multi-thread coredump implies the core_uses_pid behaviour, but we shouldn't use mm->mm_users for that. This counter can be incremented by get_task_mm(). Use the valued returned by coredump_wait() instead. Also, remove the "const char *pattern" argument, format_corename() can use core_pattern directly. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Oleg Nesterov <oleg@tv-sign.ru> Cc: Roland McGrath <roland@redhat.com> Cc: Alan Cox <alan@lxorguk.ukuu.org.uk> Cc: Andi Kleen <andi@firstfloor.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r--fs/exec.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/fs/exec.c b/fs/exec.c
index bff43aeb235e..5e559013e303 100644
--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1379,17 +1379,14 @@ EXPORT_SYMBOL(set_binfmt);
1379 * name into corename, which must have space for at least 1379 * name into corename, which must have space for at least
1380 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator. 1380 * CORENAME_MAX_SIZE bytes plus one byte for the zero terminator.
1381 */ 1381 */
1382static int format_corename(char *corename, const char *pattern, long signr) 1382static int format_corename(char *corename, int nr_threads, long signr)
1383{ 1383{
1384 const char *pat_ptr = pattern; 1384 const char *pat_ptr = core_pattern;
1385 int ispipe = (*pat_ptr == '|');
1385 char *out_ptr = corename; 1386 char *out_ptr = corename;
1386 char *const out_end = corename + CORENAME_MAX_SIZE; 1387 char *const out_end = corename + CORENAME_MAX_SIZE;
1387 int rc; 1388 int rc;
1388 int pid_in_pattern = 0; 1389 int pid_in_pattern = 0;
1389 int ispipe = 0;
1390
1391 if (*pattern == '|')
1392 ispipe = 1;
1393 1390
1394 /* Repeat as long as we have more pattern to process and more output 1391 /* Repeat as long as we have more pattern to process and more output
1395 space */ 1392 space */
@@ -1490,7 +1487,7 @@ static int format_corename(char *corename, const char *pattern, long signr)
1490 * and core_uses_pid is set, then .%pid will be appended to 1487 * and core_uses_pid is set, then .%pid will be appended to
1491 * the filename. Do not do this for piped commands. */ 1488 * the filename. Do not do this for piped commands. */
1492 if (!ispipe && !pid_in_pattern 1489 if (!ispipe && !pid_in_pattern
1493 && (core_uses_pid || atomic_read(&current->mm->mm_users) != 1)) { 1490 && (core_uses_pid || nr_threads)) {
1494 rc = snprintf(out_ptr, out_end - out_ptr, 1491 rc = snprintf(out_ptr, out_end - out_ptr,
1495 ".%d", task_tgid_vnr(current)); 1492 ".%d", task_tgid_vnr(current));
1496 if (rc > out_end - out_ptr) 1493 if (rc > out_end - out_ptr)
@@ -1753,7 +1750,7 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
1753 * uses lock_kernel() 1750 * uses lock_kernel()
1754 */ 1751 */
1755 lock_kernel(); 1752 lock_kernel();
1756 ispipe = format_corename(corename, core_pattern, signr); 1753 ispipe = format_corename(corename, retval, signr);
1757 unlock_kernel(); 1754 unlock_kernel();
1758 /* 1755 /*
1759 * Don't bother to check the RLIMIT_CORE value if core_pattern points 1756 * Don't bother to check the RLIMIT_CORE value if core_pattern points