From patchwork Wed Sep 20 20:45:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9962521 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 466B060208 for ; Wed, 20 Sep 2017 20:53:38 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 394062920C for ; Wed, 20 Sep 2017 20:53:38 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2DE5E29239; Wed, 20 Sep 2017 20:53:38 +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 2BF6E2920C for ; Wed, 20 Sep 2017 20:53:37 +0000 (UTC) Received: (qmail 32574 invoked by uid 550); 20 Sep 2017 20:53:02 -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 32457 invoked from network); 20 Sep 2017 20:53:00 -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=3R7ykMo1QDcA1DAxnObdCr3lt2DuNxplS/riESPOmSw=; b=dxDjjsJKG6tiuJdzmEL/zoU3X2165vcSwqEhop0ZLqP8hfPf4qjbIECJQxebRfYulx +SJyEU/5q/oXGrAnkGdaFJpRURBTwcEzi5BDsSbA0Spfo4Ulv5ULOYKHxTaKKPann02U WvvuAbE+vSVwiGJTtezQJ3+baW1SY95yizyZs= 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=3R7ykMo1QDcA1DAxnObdCr3lt2DuNxplS/riESPOmSw=; b=URJyoNrKe4Ufuc2xPU+0ru0hURjMn9uMmap9B/m+mLxB70RbLcCQWbXzhBH4+P35H/ ne+/eHPfURDHK9tUlLXGQNq+CyfJ0EEN62wQ/tlR09axCAUQkUcmAs25Akfqsn2qd9mP C0BLqOTsSlDEbZpM7T0eoUe8r+Ik8duDNZ0MwvyPDbzLP3y2olNSq4E6khKaCfIXeg/l dX08e4IvuYvQJ6wJfQFyKbl8hZXxNeOwrJFRX84RMasr0aOWkohNylr7cPqdzp8xNe62 J1H2inkPEODgU/CJbpXO79GZchfenjx1Vi+DCYdundnCXBEa+G0H23OCIKRzGxge2wFX pqFQ== X-Gm-Message-State: AHPjjUgJI93cR8U5PUTxuabIdMbB9NVwJL4jvG5XCw3oiPyGpciLaNS6 5SXAIUbBJpxQIYB8TTCKH1Eu6w== X-Google-Smtp-Source: AOwi7QBt43NnJbfqZ+d48EKxeh/ATGvZttRyHBJZhh7heLCV726eY9KvHKoAfJmtZ58m/O14HVWhXg== X-Received: by 10.84.240.196 with SMTP id l4mr3311743plt.443.1505940768866; Wed, 20 Sep 2017 13:52:48 -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-fsdevel@vger.kernel.org, netdev@vger.kernel.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com, David Windsor Date: Wed, 20 Sep 2017 13:45:33 -0700 Message-Id: <1505940337-79069-28-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505940337-79069-1-git-send-email-keescook@chromium.org> References: <1505940337-79069-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH v3 27/31] 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 971feac13506..6642e8eaff45 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -114,6 +114,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 3fa26a61eabc..868235b967ed 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -488,6 +488,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. *