From patchwork Fri Feb 16 18:10:54 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Popov X-Patchwork-Id: 10225311 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 D070D603EE for ; Fri, 16 Feb 2018 18:12:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BF32229642 for ; Fri, 16 Feb 2018 18:12:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B3A9F29646; Fri, 16 Feb 2018 18:12:05 +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 DA55F29642 for ; Fri, 16 Feb 2018 18:12:04 +0000 (UTC) Received: (qmail 17809 invoked by uid 550); 16 Feb 2018 18:11:31 -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 17643 invoked from network); 16 Feb 2018 18:11:29 -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=8xTH0Qn4FJjVArEZhiC6i5hOYrV8Y7yi6fh09pqZCmU=; b=b4oDlzp9NKL/Lgq7ZFRKJ/46BZ0xUC/pkmWzR7T+DOQmC2E88QoD0g45J4aRtOvdFI gDWrfWPJ6+4sFJj1+Y3wyD2DYQp896XEf0OOyw5McOlPt+CY4NqlY6RqPtr5MyG4WYQf wYZzyeHuABBM6D6vEEdfxI16+ogJTQOTtWaAOuDUg7/tQYmfWY3JE47RIDyVRg4Da8NV gLMTQ1Soj63iuxtt/jOJKXsYWhp8g+u4uRneS/mafTTUZ6N6RxLaBPdlD/25fRqQrLMa 7D/qjhp6x3dKeNIARtctQP4uv+7PWefKOBzWaXwV2pGun/sqR6vOWIg8/zao2Elo1Rr/ 6zYA== X-Gm-Message-State: APf1xPCBXVfOdj1drhkmVQK0ypV/7n+EHf1dtuXh70eiIkaz6bPqIHCd RSNU81wGcOZmvdIa558aICbeAsJY7F4= X-Google-Smtp-Source: AH8x226M/ptpk74Y3Fu+mAXhWFJLu3C3W8xud9A8HO7m+h+i5Gb84vU5SNVK7qyBZurkU+Ort2obMg== X-Received: by 10.25.156.20 with SMTP id f20mr4784863lfe.12.1518804678038; Fri, 16 Feb 2018 10:11:18 -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 Subject: [PATCH RFC v8 3/6] x86/entry: Erase kernel stack in syscall_trace_enter() Date: Fri, 16 Feb 2018 21:10:54 +0300 Message-Id: <1518804657-24905-4-git-send-email-alex.popov@linux.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1518804657-24905-1-git-send-email-alex.popov@linux.com> References: <1518804657-24905-1-git-send-email-alex.popov@linux.com> 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 74f6eee..b4be776 100644 --- a/arch/x86/entry/common.c +++ b/arch/x86/entry/common.c @@ -46,6 +46,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 @@ -128,6 +134,7 @@ static long syscall_trace_enter(struct pt_regs *regs) do_audit_syscall_entry(regs, arch); + erase_kstack(); return ret ?: regs->orig_ax; }