Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6048206ybi; Wed, 29 May 2019 01:57:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqxQqCvOp/u1YJBt70T+ttgxsX/WeTH3SitqjFDu+7llk3EdCCZaQNUYyKx4sjJ+Wx4EYrON X-Received: by 2002:a63:78cf:: with SMTP id t198mr47090598pgc.82.1559120244284; Wed, 29 May 2019 01:57:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559120244; cv=none; d=google.com; s=arc-20160816; b=ckQaZPs7+ydtHoNpFF2AbaF9WcXs6ltFcxeljfl8Th4SAVbcntXSNy/CyVjU8CSGey uoaE6X00MF867d30QR8jj/AdstkN2Jgpg/zxnhIhbis6vy9j3kJaEK0D5yUfxUn4q+k7 yJENVgQhU92U1jEXHMLW7b/trfxG+kvHdA2ZH9dAbVq4mtvUPY0UiEIXkxtCuzGluqyi WMkms+7M8kcpLMeh2r7RLNZFLiq8UzSSSg6Sow7BMYiptf+tIrFaaF4iLz7p5BsdA5pX hQqQM6fizV8JLJki4VkG2lDdRzKV2sOMlHPG3r+PqTsoMm3wgw6uOYhm7BhxdqvC95PG f2AA== 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:date :references:subject:cc:to:from; bh=anb4uUBHp+vRvaV73mGW6VG04WtaAYH9sGLth3XQLFo=; b=Zo9W/8D0BkNZpseoU8W4oW8LlC9SsAEk23FFP8nvwyFxddE2Sky5EFl2uEP3yINwkn hWxwInwDPYpCgVhIDTu7mea9snD9cLI47kEqkAXHMNljpk8V8nrq0szuO0+TFfEgMJ9y 6LHQZBRpoDm2CgjDig4kvZ7MxPAljkWipLbltyuHFFg5nJBf2Voj5JPeuxRps5HVnBuP //0MFadn7MmHTHQE5KyO1Dx1xEKFWxsx7cBaZfAravllRnM8O7inrYWIg8ULZmyCgRiE Ue6FLyy4AKYCcnBModSn4/kE0m23WpsqERvRdEedeahyZ/44rjRzufjda3avo9/gN/fM foAw== 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 i33si19102536pgl.159.2019.05.29.01.57.08; Wed, 29 May 2019 01:57:24 -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 S1726304AbfE2Iz5 (ORCPT + 99 others); Wed, 29 May 2019 04:55:57 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:52978 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726131AbfE2Iz5 (ORCPT ); Wed, 29 May 2019 04:55:57 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hVuNH-0004Bz-1T; Wed, 29 May 2019 10:55:55 +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 Subject: [PATCHv2] 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> Date: Wed, 29 May 2019 10:55:53 +0200 Message-ID: <87y32p7i7a.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 the core the core dumper. 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. 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