From patchwork Tue Jan 9 20:55:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10153397 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 B7B1260223 for ; Tue, 9 Jan 2018 21:02:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADEF82018F for ; Tue, 9 Jan 2018 21:02:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A221E24B48; Tue, 9 Jan 2018 21:02:46 +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 A07592018F for ; Tue, 9 Jan 2018 21:02:45 +0000 (UTC) Received: (qmail 9780 invoked by uid 550); 9 Jan 2018 20:57:37 -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 9274 invoked from network); 9 Jan 2018 20:57:22 -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=SnghanDydgQiWkBVQnDglqviTcEmD/40/+04nFn5XG4=; b=Ly4ZPzP6M2N/CZsWHuhiNQCPYDeDWiVLS/z+flvfpjU9COluB0i64AmJLnLqKS+1Me cNU0D4JCJ7MOFWEHxtAglQu3dGPOy86M7Xt9NjOpxpFXRIoE0Xgjef2hjNL/KrG7wTR+ j5h67Y61+adiIhAcbqsnU8jtVD4NlKy01yQOg= 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=SnghanDydgQiWkBVQnDglqviTcEmD/40/+04nFn5XG4=; b=BRSj7fjv0cGMxI5fFovk9dWPFvwm4do53OcexpwEBmABPk062YfGEvs2m3e955pOdg FWkcRrw+fA9oDQ/u4Ma67JxB5kIAu9zTTtFJTrg/Up1mmNwAxw8mH9nJJbxLo5jhbGf3 wY+pOlKsTrClDFQORVuL9bGMtKy1cWTHNl/0iUg7cEeAhAjBEprdarh0yNT1dCaLrguX 3CnwTE+IuJBrRIRGK4WFAbnE37dDhElANvRcjEhLEwjj5N5THs/rUTK+rI4gqC3Be82y hPBR6QCNrEVfYyzG1yRd1AqUzccgZOTzWz0etY35ngxatt3LJwx1Apr+S81ZekcEAPND XrlA== X-Gm-Message-State: AKGB3mJR1UGJ77m0ADDvVBXIDV42Yz1ecFPf/Ul2D6q9DslcObW0Mukx Gg5ZQ5i1elANHuw8/O7BKmCh3g== X-Google-Smtp-Source: ACJfBotbzIJJCjGn+j7YwV72r6jmoE2bUJh4S1YJnqBQhAiSH2rqxBE8r07PIJRpg8IX7LM6mrmH0Q== X-Received: by 10.159.241.1 with SMTP id q1mr8868952plr.378.1515531430969; Tue, 09 Jan 2018 12:57:10 -0800 (PST) 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 , Linus Torvalds , David Windsor , Alexander Viro , Andrew Morton , Christoph Hellwig , Christoph Lameter , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , Christian Borntraeger , Christoffer Dall , Dave Kleikamp , Jan Kara , Luis de Bethencourt , Marc Zyngier , Rik van Riel , Matthew Garrett , linux-fsdevel@vger.kernel.org, linux-arch@vger.kernel.org, netdev@vger.kernel.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com Date: Tue, 9 Jan 2018 12:55:58 -0800 Message-Id: <1515531365-37423-30-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515531365-37423-1-git-send-email-keescook@chromium.org> References: <1515531365-37423-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 29/36] 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 8eed3f94bfc7..9ac4ac1a856b 100644 --- a/arch/x86/Kconfig +++ b/arch/x86/Kconfig @@ -116,6 +116,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 cc16fa882e3e..2b037b7fe0eb 100644 --- a/arch/x86/include/asm/processor.h +++ b/arch/x86/include/asm/processor.h @@ -492,6 +492,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. *