From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933640AbcJTLOX (ORCPT ); Thu, 20 Oct 2016 07:14:23 -0400 Received: from terminus.zytor.com ([198.137.202.10]:39774 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750853AbcJTLOV (ORCPT ); Thu, 20 Oct 2016 07:14:21 -0400 Date: Thu, 20 Oct 2016 04:13:20 -0700 From: tip-bot for Andy Lutomirski Message-ID: Cc: brgerst@gmail.com, penguin-kernel@i-love.sakura.ne.jp, hpa@zytor.com, linux-api@vger.kernel.org, linux-kernel@vger.kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, luto@kernel.org, keescook@chromium.org, mingo@kernel.org, bp@alien8.de, peterz@infradead.org, viro@zeniv.linux.org.uk, torvalds@linux-foundation.org, tycho.andersen@canonical.com, jann@thejh.net Reply-To: torvalds@linux-foundation.org, jann@thejh.net, tycho.andersen@canonical.com, viro@zeniv.linux.org.uk, peterz@infradead.org, bp@alien8.de, luto@kernel.org, keescook@chromium.org, mingo@kernel.org, akpm@linux-foundation.org, tglx@linutronix.de, linux-kernel@vger.kernel.org, penguin-kernel@i-love.sakura.ne.jp, brgerst@gmail.com, linux-api@vger.kernel.org, hpa@zytor.com In-Reply-To: References: To: linux-tip-commits@vger.kernel.org Subject: [tip:mm/urgent] fs/proc: Stop reporting eip and esp in /proc/PID/stat Git-Commit-ID: 0a1eb2d474edfe75466be6b4677ad84e5e8ca3f5 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0a1eb2d474edfe75466be6b4677ad84e5e8ca3f5 Gitweb: http://git.kernel.org/tip/0a1eb2d474edfe75466be6b4677ad84e5e8ca3f5 Author: Andy Lutomirski AuthorDate: Fri, 30 Sep 2016 10:58:56 -0700 Committer: Ingo Molnar CommitDate: Thu, 20 Oct 2016 09:21:41 +0200 fs/proc: Stop reporting eip and esp in /proc/PID/stat Reporting these fields on a non-current task is dangerous. If the task is in any state other than normal kernel code, they may contain garbage or even kernel addresses on some architectures. (x86_64 used to do this. I bet lots of architectures still do.) With CONFIG_THREAD_INFO_IN_TASK=y, it can OOPS, too. As far as I know, there are no use programs that make any material use of these fields, so just get rid of them. Reported-by: Jann Horn Signed-off-by: Andy Lutomirski Acked-by: Thomas Gleixner Cc: Al Viro Cc: Andrew Morton Cc: Borislav Petkov Cc: Brian Gerst Cc: Kees Cook Cc: Linus Torvalds Cc: Linux API Cc: Peter Zijlstra Cc: Tetsuo Handa Cc: Tycho Andersen Link: http://lkml.kernel.org/r/a5fed4c3f4e33ed25d4bb03567e329bc5a712bcc.1475257877.git.luto@kernel.org Signed-off-by: Ingo Molnar --- fs/proc/array.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/fs/proc/array.c b/fs/proc/array.c index 89600fd..81818ad 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -412,10 +412,11 @@ static int do_task_stat(struct seq_file *m, struct pid_namespace *ns, mm = get_task_mm(task); if (mm) { vsize = task_vsize(mm); - if (permitted) { - eip = KSTK_EIP(task); - esp = KSTK_ESP(task); - } + /* + * 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). + */ } get_task_comm(tcomm, task);