From patchwork Mon Aug 28 21:35:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9926351 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 D7F0560329 for ; Mon, 28 Aug 2017 21:45:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CCD2D287A5 for ; Mon, 28 Aug 2017 21:45:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1662287D6; Mon, 28 Aug 2017 21:45:58 +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 BDD8F287A5 for ; Mon, 28 Aug 2017 21:45:57 +0000 (UTC) Received: (qmail 9824 invoked by uid 550); 28 Aug 2017 21:44:18 -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 9517 invoked from network); 28 Aug 2017 21:44:09 -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=z107xMALoBZXerkXo+BsT/FJs2CE55bL9chH6/dSnCc=; b=T7kYuan0Kj53G+UqmYR8Q0M+g32Ucc6Hu3eAyRklugRPEJ6OO1H1bDTYwE6g/2Ba+3 Rh37kLJnLPtiUIX6z6B5eqtRkrM48EglwIU/9nMqCOzB9myDivk6uxQvuCNdPDhKJAyI B4bOprJXZ33FP2BxOyOvfk87+UCYrC/6F3LlY= 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=z107xMALoBZXerkXo+BsT/FJs2CE55bL9chH6/dSnCc=; b=m/gPtGDrtzXPThw9yADT50TcjYEeISmDRoLf9PEOIs9GlHkbsEWNI+culTQoinmBfm yxcH0QIgYAmW3NFgNk8EvqVjFr9E4NH5J9bojr2H4W8p3Z9Ran94FX0qV+SqzfsabBYy udmV/d/v81oGri5gnBncUAZIMAegv1LEeKEDHKqb+BwtIeRinMsr4+ytJr1wHzy0O7k5 Kg4YuimCdcAS5HKILzAfI04aRawsSf3mWCH5ZUEQB4pponvPp+TBHOxwk5ZRxRcvrq++ XTxvOMxC2QDEMSnUfVRFqC5KHpFeVTLLpI2vIAEJb4TdNWmmYtKj7xe6GjjKRXZU3i2Y WkWA== X-Gm-Message-State: AHYfb5g5940aXeeGULhrEeDdrfnUF5QTJ0cUPSwCcTLpuv5slVcEArAW fGhPNhAMVArF7j+z X-Received: by 10.99.121.66 with SMTP id u63mr1906838pgc.386.1503956637707; Mon, 28 Aug 2017 14:43:57 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Cc: Kees Cook , Catalin Marinas , Will Deacon , Christian Borntraeger , Ingo Molnar , James Morse , "Peter Zijlstra (Intel)" , Dave Martin , zijun_hu , linux-arm-kernel@lists.infradead.org, linux-mm@kvack.org, kernel-hardening@lists.openwall.com, David Windsor Date: Mon, 28 Aug 2017 14:35:09 -0700 Message-Id: <1503956111-36652-29-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 28/30] arm64: 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 structure. Cc: Catalin Marinas Cc: Will Deacon Cc: Christian Borntraeger Cc: Ingo Molnar Cc: James Morse Cc: "Peter Zijlstra (Intel)" Cc: Dave Martin Cc: zijun_hu Cc: linux-arm-kernel@lists.infradead.org Signed-off-by: Kees Cook --- arch/arm64/Kconfig | 1 + arch/arm64/include/asm/processor.h | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/arch/arm64/Kconfig b/arch/arm64/Kconfig index dfd908630631..b773299bc4e3 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -73,6 +73,7 @@ config ARM64 select HAVE_ARCH_MMAP_RND_BITS select HAVE_ARCH_MMAP_RND_COMPAT_BITS if COMPAT select HAVE_ARCH_SECCOMP_FILTER + select HAVE_ARCH_THREAD_STRUCT_WHITELIST select HAVE_ARCH_TRACEHOOK select HAVE_ARCH_TRANSPARENT_HUGEPAGE select HAVE_ARM_SMCCC diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 64c9e78f9882..799f112e5ff7 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -90,6 +90,14 @@ struct thread_struct { struct debug_info debug; /* debugging */ }; +/* Whitelist the fpsimd_state for copying to userspace. */ +static inline void arch_thread_struct_whitelist(unsigned long *offset, + unsigned long *size) +{ + *offset = offsetof(struct thread_struct, fpsimd_state); + *size = sizeof(struct fpsimd_state); +} + #ifdef CONFIG_COMPAT #define task_user_tls(t) \ ({ \