[to-be-updated] proc-report-eip-and-esp-for-all-threads-when-coredumping.patch removed from -mm tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The patch titled
     Subject: proc: report eip and esp for all threads when coredumping
has been removed from the -mm tree.  Its filename was
     proc-report-eip-and-esp-for-all-threads-when-coredumping.patch

This patch was dropped because an updated version will be merged

------------------------------------------------------
From: Jan Luebbe <jlu@xxxxxxxxxxxxxx>
Subject: proc: report eip and esp for all threads when coredumping

0a1eb2d474ed ("fs/proc: Stop reporting eip and esp in /proc/PID/stat")
stopped reporting eip/esp and fd7d56270b52 ("fs/proc: Report eip/esp in
/prod/PID/stat for coredumping") reintroduced the feature to fix a
regression with userspace core dump handlers (such as minicoredumper).

Because PF_DUMPCORE is only set for the primary thread, this didn't fix
the original problem for secondary threads.  This commit checks
mm->core_state instead, as already done for /proc/<pid>/status in
task_core_dumping().  As we have a mm_struct available here anyway, this
seems to be a clean solution.

In current mainline, all threads except the main have the
/proc/[pid]/stat fields 'kstkesp' (29, current stack pointer) and
'kstkeip' (30, current instruction pointer) show as 0 even during
coredumping when read by the core dump handler.

minicoredumper for example tries to use this value to find each
thread's stack and tries to dump it, which fails as there is nothing
mapped at 0.  The result is that the thread's stack data is missing
from the generated core dump.

With this patch, kstkesp and kstkeip are visible again to the core dump
handler, so the minified core dump contains all stacks again.  For a
process running normally, the values are still reported as 0 (as
intended).

[akpm@xxxxxxxxxxxxxxxxxxxx: cleanup, per Alexey]
[john.ogness@xxxxxxxxxxxxx: close race window]
  Link: http://lkml.kernel.org/r/875zpzif8v.fsf@xxxxxxxxxxxxx
Link: http://lkml.kernel.org/r/20190522161614.628-1-jlu@xxxxxxxxxxxxxx
Fixes: fd7d56270b526ca3 ("fs/proc: Report eip/esp in /prod/PID/stat for coredumping")
Signed-off-by: Jan Luebbe <jlu@xxxxxxxxxxxxxx>
Cc: Alexey Dobriyan <adobriyan@xxxxxxxxx>
Cc: John Ogness <john.ogness@xxxxxxxxxxxxx>
Cc: Andy Lutomirski <luto@xxxxxxxxxx>
Cc: <stable@xxxxxxxxxxxxxxx>
Signed-off-by: Andrew Morton <akpm@xxxxxxxxxxxxxxxxxxxx>
---

 fs/coredump.c   |    2 +-
 fs/proc/array.c |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/fs/proc/array.c~proc-report-eip-and-esp-for-all-threads-when-coredumping
+++ a/fs/proc/array.c
@@ -462,7 +462,7 @@ static int do_task_stat(struct seq_file
 		 * a program is not able to use ptrace(2) in that case. It is
 		 * safe because the task has stopped executing permanently.
 		 */
-		if (permitted && (task->flags & PF_DUMPCORE)) {
+		if (permitted && mm->core_state) {
 			if (try_get_task_stack(task)) {
 				eip = KSTK_EIP(task);
 				esp = KSTK_ESP(task);
--- a/fs/coredump.c~proc-report-eip-and-esp-for-all-threads-when-coredumping
+++ a/fs/coredump.c
@@ -340,10 +340,10 @@ static int zap_threads(struct task_struc
 
 	spin_lock_irq(&tsk->sighand->siglock);
 	if (!signal_group_exit(tsk->signal)) {
-		mm->core_state = core_state;
 		tsk->signal->group_exit_task = tsk;
 		nr = zap_process(tsk, exit_code, 0);
 		clear_tsk_thread_flag(tsk, TIF_SIGPENDING);
+		mm->core_state = core_state;
 	}
 	spin_unlock_irq(&tsk->sighand->siglock);
 	if (unlikely(nr < 0))
_

Patches currently in -mm which might be from jlu@xxxxxxxxxxxxxx are





[Index of Archives]     [Kernel Archive]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]

  Powered by Linux