From patchwork Mon Aug 28 21:35:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9926369 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 5068A60329 for ; Mon, 28 Aug 2017 21:55:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 45460287DC for ; Mon, 28 Aug 2017 21:55:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39DEA287E0; Mon, 28 Aug 2017 21:55:01 +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.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID 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 4C6CC287DC for ; Mon, 28 Aug 2017 21:54:59 +0000 (UTC) Received: (qmail 1509 invoked by uid 550); 28 Aug 2017 21:54:04 -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 1456 invoked from network); 28 Aug 2017 21:54:03 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=GadUb0SS45UYQs1NlQGI/wJicE7T6pVi5Y4C82OugeU=; b=AuxoKJeqlSUFIfR+GjyVUrj3Xz1OG/zVA3PkZgTX6VUYLLNyDHqPg9tDieFah+5O4N GaWQxSIs6/5qUxIl7Be5ZEMYOB57dioWWxZdnkN6fZGUtXI/UI3w0XpQ4qPxNaR1IedH oM1Yb5Er4iHAsxgAK9m84GZQaZRf16LOeVdxw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=GadUb0SS45UYQs1NlQGI/wJicE7T6pVi5Y4C82OugeU=; b=sLnikPzLCu7rMYKX++vGtxmU1T3LEFACAIPFIhM0SmgSzbRJaR0SXbx+8y2qNtF+i4 PXJWcgCA8EwYbN2JiXvT2QPOgBuXIBA8zobeZeX4kTxED5tculTKi70YxMiNWXtd+xwL FTaNn4o8yom+FntqO6mh12iSnufp7+o2e4dn1pFvKhZXJ9wW3sNiMsAQsBs1jH6+zpNO uHfCYo8a2zFM7ValJ0Bs/l+8yL9lTjEntGkSIPiKBkGCpQF3zFYGTTsNtKDkp3RSvaKa kpnn9Rd6o2AFFWqGz1C3Z/dXXVQlBoNtBRGI0GGl29LoLB0b5E2jXIctAv410aLJdIie BPkA== X-Gm-Message-State: AHYfb5i5mwS328QVaNtdQsVXlhguDU4CKM38Nw6ZRL+BzG97EnSnVRly 3hWSOfxDbsLONDbo X-Received: by 10.99.120.71 with SMTP id t68mr1819796pgc.177.1503957232246; Mon, 28 Aug 2017 14:53:52 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Thomas Gleixner , Ingo Molnar , "H. Peter Anvin" , x86@kernel.org, Borislav Petkov , Andy Lutomirski , Mathias Krause , linux-mm@kvack.org, kernel-hardening@lists.openwall.com, David Windsor Date: Mon, 28 Aug 2017 14:35:08 -0700 Message-Id: <1503956111-36652-28-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503956111-36652-1-git-send-email-keescook@chromium.org> References: <1503956111-36652-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v2 27/30] x86: Implement thread_struct whitelist for hardened usercopy X-Virus-Scanned: ClamAV using ClamSMTP This whitelists the FPU register state portion of the thread_struct for copying to userspace, instead of the default entire struct. Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: x86@kernel.org Cc: Borislav Petkov Cc: Andy Lutomirski Cc: Mathias Krause Signed-off-by: Kees Cook Acked-by: Rik van Riel --- arch/x86/Kconfig | 1 + arch/x86/include/asm/processor.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig index 781521b7cf9e..a8793721483c 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -113,6 +113,7 @@ config X86 select HAVE_ARCH_MMAP_RND_COMPAT_BITS if MMU && COMPAT select HAVE_ARCH_COMPAT_MMAP_BASES if MMU && COMPAT select HAVE_ARCH_SECCOMP_FILTER + select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_ARCH_TRANSPARENT_HUGEPAGE_PUD if X86_64 diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h index 028245e1c42b..dc52ba90f090 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -481,6 +481,14 @@ struct thread_struct { */ }; +/* Whitelist the FPU state from the task_struct for hardened usercopy. */ +static inline void arch_thread_struct_whitelist(unsigned long *offset, + unsigned long *size) +{ + *offset = offsetof(struct thread_struct, fpu.state); + *size = fpu_kernel_xstate_size; +} + /* * Thread-synchronous status. *