From patchwork Thu Jan 11 02:03:04 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10156599 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 F3513605BA for ; Thu, 11 Jan 2018 02:12:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E278E2874B for ; Thu, 11 Jan 2018 02:12:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D71B12874F; Thu, 11 Jan 2018 02:12:57 +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 0A0322874B for ; Thu, 11 Jan 2018 02:12:56 +0000 (UTC) Received: (qmail 29974 invoked by uid 550); 11 Jan 2018 02:10:09 -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 28662 invoked from network); 11 Jan 2018 02:09:56 -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=Y8wOaQenhPDXpfYr64+UYLO/jtGe9o88/mqZHyWGwNa83OnM/w9MB8q3jbFPALEr9V ihZLC80DGdpoph76T2YjqqSk7HRLZ1POmaCzd0Il/dJYvLAP7oEUNUmiHRnMUf0BDatU ai+CzHp5purojpli1PfQzIZD69ahEfF9mRN8E= 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=MsfaeghxSBjR8hArsQt1SqB4TIVdJY+YwSRv0pwtNq8JjoDEVAdG78R2FdGePqJCaq Scjv9JHePxH/mv606B751CgtaRZItCqphmn1K+5YJ4z6aNdE2EOD4XXNSvjoiOVHAo9O SvMY01jRhjZOucXyop1zFCBTXg972Gn9JP04BveDkkLR/nMeZAqmDQ5x4M6fAcNXz8H5 25x9Ao7EoxTReiOaM32QkFFxm1E9Y/8y+khAxeHfGU3o0f0wkhNhf6+5t+nu+dNLS5h7 AMi5XcghGdU3iFhkGd20J6xxFMKkZw0XziTgnv7XRjOOnOUTBWu/avCWp76Jw4Pr+hDy ZnZg== X-Gm-Message-State: AKGB3mJ1GjijMv0U7Ajcn7l/J6UsI1YZiv8tdPfEU1SpW4I63fYrGwK+ hOg+o7IL/E+BZwVfpudcrlO4sQ== X-Google-Smtp-Source: ACJfBovS24igyT2XzoMcvjZNQqI9EoeH192KISCxqN3rC58Ta8jcmK0GwK0Ms/rwCeF/AbzsF+IGUg== X-Received: by 10.101.77.195 with SMTP id q3mr16451740pgt.436.1515636584898; Wed, 10 Jan 2018 18:09:44 -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: Wed, 10 Jan 2018 18:03:04 -0800 Message-Id: <1515636190-24061-33-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515636190-24061-1-git-send-email-keescook@chromium.org> References: <1515636190-24061-1-git-send-email-keescook@chromium.org> Subject: [kernel-hardening] [PATCH 32/38] 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. *