Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp124225ybi; Wed, 29 May 2019 18:01:55 -0700 (PDT) X-Google-Smtp-Source: APXvYqxbr9L5TwyK6ea6sgrb99fQZu1JKy2hIaPM9UBmqNcSssWC3mbWlP47Rl+J73mAA6cJOlKD X-Received: by 2002:a17:902:a50c:: with SMTP id s12mr888327plq.273.1559178115510; Wed, 29 May 2019 18:01:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559178115; cv=none; d=google.com; s=arc-20160816; b=jzqyd5vMBsOe6l+eRgSII8GPwn2XdGvU9BW+uCrW/HkdY4K1jjIvXEwgmDR0m60Lbe naE1wbQx49zHDBnbNoz+iXlnA6gkWbxuiWE1QU6PGJB471wsUTvsAbXZ9xIWUYHQgYoM rcIjq8H/nJE0pBhONu94NzPVggc/VsvmrMHlCtRuwBg7kSvTZ4vJdpLS0jcL8mrfsn8j Jicbh/p78t+y/Er+q60axBpnELKqrDZbrPeUtNfcQhNUfqHJL5SZjjUA69sg9v87KHWi iSSq9Z6qvhUxwH82hlHsH7lP2m74qC1RFK2xVWZZiWhQyml32ZwxXNR3v6h58iSLgnXh jflg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from; bh=ZXrFYdRHf9RnBASSdqZdBFPOu+BC0KVnGgloxcMIir8=; b=a3tUmSPeeRWW8LaliGhAy8sZ+We19ZBwktikF75m8cmjd0WVkghbTarWz2VQo1TV1V 9KUVWPZhuHnKmgiV2Ad8LBgRyLGz389r+o4rrLd2miLaSaObWeGEkLZe1HIz7kKawBL3 5TvwqbarNjktr8yQDmM79gXJKlpovGAksLTIgVv3CNjGLa02ZOnia+rqhpKB1RIwN911 DTxN6A3d0Wyuw1ds1eVDA03pNT8/jD9SNKQc71s7lmXbIgBZ7hxscbmgg8YeOb0gts/E han357DQsHfDP/mXvqETNucAzWKVk+ucWyobcxdEQg2pNGSmgZzymYJoY9UyjvGzPoRh /J6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t5si1480247pgv.164.2019.05.29.18.01.37; Wed, 29 May 2019 18:01:55 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727216AbfE3A7E (ORCPT + 99 others); Wed, 29 May 2019 20:59:04 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:56137 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726527AbfE3A7D (ORCPT ); Wed, 29 May 2019 20:59:03 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hW9PI-0002tg-TN; Thu, 30 May 2019 02:59:01 +0200 From: John Ogness To: Jan Luebbe Cc: Andrew Morton , Alexey Dobriyan , Andy Lutomirski , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org, stable@vger.kernel.org Subject: [PATCHv3] fs/proc: allow reporting eip/esp for all coredumping threads References: <20190522161614.628-1-jlu@pengutronix.de> <875zpzif8v.fsf@linutronix.de> <20190525143220.e771b7915d17f22dad1438fa@linux-foundation.org> <87d0k5f1g7.fsf@linutronix.de> <87y32p7i7a.fsf@linutronix.de> Date: Thu, 30 May 2019 02:58:59 +0200 In-Reply-To: <87y32p7i7a.fsf@linutronix.de> (John Ogness's message of "Wed, 29 May 2019 10:55:53 +0200") Message-ID: <87pno0u59o.fsf_-_@linutronix.de> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 0a1eb2d474ed ("fs/proc: Stop reporting eip and esp in /proc/PID/stat") stopped reporting eip/esp and commit 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. Allow reporting the eip/esp for all threads by checking for PF_EXITING as well. This is set for all the other threads when they are killed. coredump_wait() waits for all the tasks to become inactive before proceeding to invoke a core dumper. Fixes: fd7d56270b526ca3 ("fs/proc: Report eip/esp in /prod/PID/stat for coredumping") Reported-by: Jan Luebbe Signed-off-by: John Ogness --- This is a rework of Jan's v1 patch that allows accessing eip/esp of all the threads without risk of the task still executing on a CPU. The code chagnes are the same as v2. With v3 I included a "Fixes" tag, fixed a typo in the commit message, and Cc'd stable. fs/proc/array.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 2edbb657f859..55180501b915 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -462,7 +462,7 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, * 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 && (task->flags & (PF_EXITING|PF_DUMPCORE))) { if (try_get_task_stack(task)) { eip = KSTK_EIP(task); esp = KSTK_ESP(task); -- 2.11.0