From patchwork Fri Jan 12 14:19:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 10161009 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 9E77A602D8 for ; Fri, 12 Jan 2018 14:20:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8129725D9E for ; Fri, 12 Jan 2018 14:20:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 73D8628475; Fri, 12 Jan 2018 14:20:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from mother.openwall.net (mother.openwall.net [195.42.179.200]) by mail.wl.linuxfoundation.org (Postfix) with SMTP id A36C42894D for ; Fri, 12 Jan 2018 14:20:30 +0000 (UTC) Received: (qmail 3526 invoked by uid 550); 12 Jan 2018 14:20:01 -0000 Mailing-List: contact kernel-hardening-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Delivered-To: mailing list kernel-hardening@lists.openwall.com Received: (qmail 3454 invoked from network); 12 Jan 2018 14:19:59 -0000 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=jiDAXPLxrjQgBlZ3gdmZQWjgI+4zJnSUA1mBpuHPBbo=; b=hgJPd1WoZqzvOBtmpFxg2m+hGdn+ZUZQrtxOz9kZs6l1JXnCsuV0iIDtyw0OUbD4t+ 2LMvamokOTbQOIwe0CLDKIRVDlLa4g5s2CPehnvjG1uYJ48eizK8awslOrW+G2WgXphh ooEjcJ7Foigl/lj5VerQOubYB3j5pQTrHgsm4sFg7C2bnpU80AGP7pqDAtFbh3YsGyJi 378hemchs6+VNbdFBzYRvptb/OMRhB/Tz9fi0q8473VsDV+jkZLpV3pPZAdo5aoXZfq5 Blkscth3kmPSlukb5Ntt2tENdbcbUChDfYkYPdNFlehsQ+BGaCysVTJ7QGt/zbcSS6pL dj2Q== X-Gm-Message-State: AKwxyteWvoCyIcYMH9GAUvw0vG6+LcykMeEBYQGPIkuvTA8zo9/udMCX giV8j6YmQ610M7/4vFwRG3Xul+/iKYM= X-Google-Smtp-Source: ACJfBotTEvJldoAbPQ3J4fedw0jmd7o1CMQWqeTYKA8xTAF5y+Zr/xW8G0gyeT0kvC1tLbhyLG1z2A== X-Received: by 10.25.154.147 with SMTP id c141mr13811943lfe.116.1515766787973; Fri, 12 Jan 2018 06:19:47 -0800 (PST) From: Alexander Popov To: kernel-hardening@lists.openwall.com, Kees Cook , PaX Team , Brad Spengler , Ingo Molnar , Andy Lutomirski , Tycho Andersen , Laura Abbott , Mark Rutland , Ard Biesheuvel , Borislav Petkov , Thomas Gleixner , "H . Peter Anvin" , Peter Zijlstra , "Dmitry V . Levin" , x86@kernel.org, alex.popov@linux.com Date: Fri, 12 Jan 2018 17:19:26 +0300 Message-Id: <1515766769-9120-4-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515766769-9120-1-git-send-email-alex.popov@linux.com> References: <1515766769-9120-1-git-send-email-alex.popov@linux.com> Subject: [kernel-hardening] [PATCH RFC v7 3/6] x86/entry: Erase kernel stack in syscall_trace_enter() X-Virus-Scanned: ClamAV using ClamSMTP Make STACKLEAK erase kernel stack after ptrace/seccomp/auditing not to leave any sensitive information on the stack for the syscall code. This code is modified from Brad Spengler/PaX Team's code in the last public patch of grsecurity/PaX based on our understanding of the code. Changes or omissions from the original code are ours and don't reflect the original grsecurity/PaX code. Signed-off-by: Alexander Popov --- arch/x86/entry/common.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/x86/entry/common.c b/arch/x86/entry/common.c index d7d3cc2..cd38727 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -45,6 +45,12 @@ __visible inline void enter_from_user_mode(void) static inline void enter_from_user_mode(void) {} #endif +#ifdef CONFIG_GCC_PLUGIN_STACKLEAK +asmlinkage void erase_kstack(void); +#else +static void erase_kstack(void) {} +#endif + static void do_audit_syscall_entry(struct pt_regs *regs, u32 arch) { #ifdef CONFIG_X86_64 @@ -127,6 +133,7 @@ static long syscall_trace_enter(struct pt_regs *regs) do_audit_syscall_entry(regs, arch); + erase_kstack(); return ret ?: regs->orig_ax; }