From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933842AbcI3R7Z (ORCPT ); Fri, 30 Sep 2016 13:59:25 -0400 Received: from mail.kernel.org ([198.145.29.136]:40728 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933643AbcI3R7J (ORCPT ); Fri, 30 Sep 2016 13:59:09 -0400 From: Andy Lutomirski To: x86@kernel.org Cc: linux-kernel@vger.kernel.org, Brian Gerst , Borislav Petkov , Jann Horn , Linux API , Linus Torvalds , Kees Cook , Tycho Andersen , Andy Lutomirski , Tetsuo Handa Subject: [PATCH 1/3] proc: Stop reporting eip and esp in /proc/PID/stat Date: Fri, 30 Sep 2016 10:58:56 -0700 Message-Id: X-Mailer: git-send-email 2.7.4 In-Reply-To: References: In-Reply-To: References: Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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, 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. Cc: Tetsuo Handa Cc: Tycho Andersen Cc: Kees Cook Reported-by: Jann Horn Signed-off-by: Andy Lutomirski --- 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 88c7de12197b..1bb1097e73b7 100644 --- a/fs/proc/array.c +++ b/fs/proc/array.c @@ -417,10 +417,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); -- 2.7.4