From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754913AbdCWWqV (ORCPT ); Thu, 23 Mar 2017 18:46:21 -0400 Received: from mail-pg0-f41.google.com ([74.125.83.41]:35070 "EHLO mail-pg0-f41.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751365AbdCWWqT (ORCPT ); Thu, 23 Mar 2017 18:46:19 -0400 Date: Thu, 23 Mar 2017 15:46:16 -0700 From: Kees Cook To: Ingo Molnar Cc: Robert =?utf-8?B?xZp3acSZY2tp?= , Andy Lutomirski , linux-kernel@vger.kernel.org Subject: [PATCH] lib/syscall: Clear return values when no stack Message-ID: <20170323224616.GA92694@beast> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit aa1f1a639621 ("lib/syscall: Pin the task stack in collect_syscall()") added logic to handle a process stack not existing, but left sp and pc uninitialized, which can be later reported via /proc/$pid/syscall for zombie processes, potentially exposing kernel memory to userspace. Zombie /proc/$pid/syscall before: -1 0xffffffff9a060100 0xffff92f42d6ad900 Zombie /proc/$pid/syscall after: -1 0x0 0x0 Reported-by: Robert Święcki Fixes: aa1f1a639621 ("lib/syscall: Pin the task stack in collect_syscall()") Cc: stable@vger.kernel.org # v4.9+ Signed-off-by: Kees Cook --- lib/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/syscall.c b/lib/syscall.c index 17d5ff5fa6a3..2c6cd1b5c3ea 100644 --- a/lib/syscall.c +++ b/lib/syscall.c @@ -12,6 +12,7 @@ static int collect_syscall(struct task_struct *target, long *callno, if (!try_get_task_stack(target)) { /* Task has no stack, so the task isn't in a syscall. */ + *sp = *pc = 0; *callno = -1; return 0; } -- 2.7.4 -- Kees Cook Pixel Security