Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp2300308ybl; Thu, 19 Dec 2019 11:13:18 -0800 (PST) X-Google-Smtp-Source: APXvYqyX8LeI+3lSb8/iS3W0uef3JGRMN/zF8B05Nyf0yy30BXa/rdp1S4JJ9SJU1PccjGCRt5D1 X-Received: by 2002:aca:ac0c:: with SMTP id v12mr1086581oie.123.1576782798474; Thu, 19 Dec 2019 11:13:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576782798; cv=none; d=google.com; s=arc-20160816; b=MRgAN2fYKvc79hq7R6hYzt6Cp1vTIoZgTS0ddi2tAGDdUQhA4+QdFq9g4t14tZw75t xpQ2QNZ2aaS4QKOz1KUr47Vum+PbdJETr4ee9RZn+remfPxijssFwtKoZJZXGC4jfFtz e8gPLm7Zb2xsBIv3vMyiX3v0K3/24PkAVfOhhR3zTNdKvlNbBB41AeVFwpBW29oa5iRS KGctVoR/xea8Iw9qC0O2VVrXd8AvauZlTDAwU8VkSFiA4kBwK21ZHXFF0A1KjcbxJUdI oRn7akOnD1Zmog/4qzSnM80WrALlhZCPHGx/94vojcA1HNNVRsKKSXPEZv2NcIgfqrHk gZfw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=njjLebgZRncv5yg0H1zbUP0yd7j0BqcD06QzjAzDaYY=; b=hM+vpBVEQb6pRXXFSjCGXHLGSkeXXIlRiutQ2qLSQpD5QpDiWUPQgV9u0aCXV8eWRD oRbeyZSm/sbSk9oghIZZcd3MATGKaIlMrx0Is5pnumG6zA6s8ZFyiTSi5380SUh+/0IH 6ClorTVrTclehnW07tJahUMbzHK089LTOWhlnTrp8lSULbPAVtWDmnxg4NJMT45fzB90 p/P7qN7rDkgPgdjDwauXou6zqWQ/y0e9bic7mNJUlg0rPNkmEOSaDosf/D9wVQerVfi3 gF4utv9c+ouj/XtclOtNil/oaE8qGfVhmIhcOz7x9joLg9wkYBAYezGB1tJ9hX4ae/ef yW+A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=RPDN67OC; 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 i26si3737467otl.29.2019.12.19.11.13.06; Thu, 19 Dec 2019 11:13:18 -0800 (PST) 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; dkim=pass header.i=@kernel.org header.s=default header.b=RPDN67OC; 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 S1727696AbfLSSiR (ORCPT + 99 others); Thu, 19 Dec 2019 13:38:17 -0500 Received: from mail.kernel.org ([198.145.29.99]:56120 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727991AbfLSSiO (ORCPT ); Thu, 19 Dec 2019 13:38:14 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id A6192222C2; Thu, 19 Dec 2019 18:38:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1576780693; bh=5IK6K/5emsZlqCtcxohp7khTC0xD+HkYdcob0eXt/4Q=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=RPDN67OCntBaZC84JsFfBKaucG6OJFGWAs8C/St2iN4vRNYWQRtOLVh4qXo8rb9WX U0WObGYYu/MGnlZdIC2v1IEKY8oLRR7iZUCchr5LDXBd9U4CR9xo2icuLsaxhG0i3w JVYHFYBNgC+Hj4+iLyJhMRX5zP6cHMX5gJ+DpDrY= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Marco Felsch , John Ogness , Andy Lutomirski , Tycho Andersen , Kees Cook , Peter Zijlstra , Brian Gerst , Tetsuo Handa , Borislav Petkov , Al Viro , Linux API , Andrew Morton , Linus Torvalds , Thomas Gleixner , "zhangyi (F)" Subject: [PATCH 4.4 079/162] fs/proc: Report eip/esp in /prod/PID/stat for coredumping Date: Thu, 19 Dec 2019 19:33:07 +0100 Message-Id: <20191219183212.607563852@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20191219183150.477687052@linuxfoundation.org> References: <20191219183150.477687052@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: John Ogness commit fd7d56270b526ca3ed0c224362e3c64a0f86687a upstream. Commit 0a1eb2d474ed ("fs/proc: Stop reporting eip and esp in /proc/PID/stat") stopped reporting eip/esp because it is racy and dangerous for executing tasks. The comment adds: As far as I know, there are no use programs that make any material use of these fields, so just get rid of them. However, existing userspace core-dump-handler applications (for example, minicoredumper) are using these fields since they provide an excellent cross-platform interface to these valuable pointers. So that commit introduced a user space visible regression. Partially revert the change and make the readout possible for tasks with the proper permissions and only if the target task has the PF_DUMPCORE flag set. Fixes: 0a1eb2d474ed ("fs/proc: Stop reporting eip and esp in> /proc/PID/stat") Reported-by: Marco Felsch Signed-off-by: John Ogness Reviewed-by: Andy Lutomirski Cc: Tycho Andersen Cc: Kees Cook Cc: Peter Zijlstra Cc: Brian Gerst Cc: stable@vger.kernel.org Cc: Tetsuo Handa Cc: Borislav Petkov Cc: Al Viro Cc: Linux API Cc: Andrew Morton Cc: Linus Torvalds Link: http://lkml.kernel.org/r/87poatfwg6.fsf@linutronix.de Signed-off-by: Thomas Gleixner [ zhangyi: 68db0cf10678 does not merged, skip the task_stack.h for 4.4] Signed-off-by: zhangyi (F) Signed-off-by: Greg Kroah-Hartman --- fs/proc/array.c | 8 ++++++++ 1 file changed, 8 insertions(+) --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -429,7 +429,15 @@ static int do_task_stat(struct seq_file * esp and eip are intentionally zeroed out. There is no * non-racy way to read them without freezing the task. * Programs that need reliable values can use ptrace(2). + * + * The only exception is if the task is core dumping because + * 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)) { + eip = KSTK_EIP(task); + esp = KSTK_ESP(task); + } } get_task_comm(tcomm, task);