Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp1078588ybi; Fri, 24 May 2019 16:53:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqyOAFJkJ1kQVzByo6wzW4vWOSeBI3L+vSqFFQujWdwQPUlYvWJV0kWhQsj+TdckAqJ3eqRB X-Received: by 2002:a17:902:2ae6:: with SMTP id j93mr87727872plb.130.1558742036437; Fri, 24 May 2019 16:53:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558742036; cv=none; d=google.com; s=arc-20160816; b=BUb6q+EBbvLVKDh4RtyiKZ/e/E7aQnAsavrRhfs6bcHKYkjUszRfgti+H7HcvGYKY0 o2wELjE4+h5V4VEpOPN+Qcu0rLJ8DXhtbSOi4fx/eq+KXjoypyWHYKnT0V5vT9lCXXyK wN58a4usqFMmA1hHATb8NojLMxXvzC/2W8opMk4NP9SKOG06NIjzgSdrgSRzNY1d4phu vzikE5x+3OWYXAldiaRx0LmN0+bHMCAKduLegwp8qlK+tfbloZ2ndPHECVpdMq50bir0 2tmn54X3+D1pNDMIH9Q+/2TkoGAACpowljGXy1BBjWN3WZl+JCDsgmKPtE99ysoMqymS ynRg== 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=re0zWjC2pd17s9gLYf1icYr/ZLqdUnftZeT/plk5oZ0=; b=UqDlEiuCdi18aeyWguhHnLmwpQ25YwsFbwYyi3pWHuzdWhUe8AKflCb4KdGqxsGp/A lQ7OrZJgirytZUIXLdL/Uz3mYDqcB1rzKnUbHTArJtjYsv4VPf66ws+x6e2AnYxrYs9Y UVlxQCfr9pt1vkbfHbVdGef1WRg2AlDA78VC1ZrvAkYN+qcIMi9vIuCaS1WsURNDzRyo bCVce21qzNJ42mhWXnH5SRJY4XhWfbkPCZOIGToPKuH/7Ac1RYGMnuSA3GYhl9GQfD0b GADdX5AKxT01QI9ufsdzq0TCPYLpK9mcC9mrHTAOXNFj/PjmVxbd7xHIYC2wfaxd1xBo bZsA== 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 e5si6104808pgs.463.2019.05.24.16.53.41; Fri, 24 May 2019 16:53:56 -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 S1726441AbfEXXup (ORCPT + 99 others); Fri, 24 May 2019 19:50:45 -0400 Received: from Galois.linutronix.de ([146.0.238.70]:44180 "EHLO Galois.linutronix.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfEXXup (ORCPT ); Fri, 24 May 2019 19:50:45 -0400 Received: from localhost ([127.0.0.1] helo=vostro.local) by Galois.linutronix.de with esmtp (Exim 4.80) (envelope-from ) id 1hUJxS-0005Qi-8g; Sat, 25 May 2019 01:50:42 +0200 From: John Ogness To: Jan Luebbe Cc: Alexey Dobriyan , Andrew Morton , Andy Lutomirski , kernel@pengutronix.de, linux-kernel@vger.kernel.org, linux-fsdevel@vger.kernel.org Subject: Re: [PATCH] proc: report eip and esp for all threads when coredumping References: <20190522161614.628-1-jlu@pengutronix.de> Date: Sat, 25 May 2019 01:50:40 +0200 In-Reply-To: <20190522161614.628-1-jlu@pengutronix.de> (Jan Luebbe's message of "Wed, 22 May 2019 18:16:14 +0200") Message-ID: <875zpzif8v.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 On 2019-05-22, Jan Luebbe wrote: > 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. This commit checks > mm->core_state instead, as already done for /proc//status in > task_core_dumping(). As we have a mm_struct available here anyway, this > seems to be a clean solution. > > Signed-off-by: Jan Luebbe > --- > 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..b76b1e29fc36 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 && (!!mm->core_state)) { This is not entirely safe. mm->core_state is set _before_ zap_process() is called. Therefore tasks can be executing on a CPU with mm->core_state set. With the following additional change, I was able to close the window. diff --git a/fs/coredump.c b/fs/coredump.c index e42e17e55bfd..93f55563e2c1 100644 --- a/fs/coredump.c +++ b/fs/coredump.c @@ -340,10 +340,10 @@ static int zap_threads(struct task_struct *tsk, struct mm_struct *mm, 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)) AFAICT core_state does not need to be set before the other lines. But there may be some side effects that I overlooked! John Ogness