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: 9926329 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 3C66260375 for ; Mon, 28 Aug 2017 21:44:49 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2FA14283C7 for ; Mon, 28 Aug 2017 21:44:49 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2369B287D5; Mon, 28 Aug 2017 21:44:49 +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=-2.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id A60AA283C7 for ; Mon, 28 Aug 2017 21:44:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=BfxX45ue2chpBc/JCFSNYonQkCLAT9qCx+kjAOggPes=; b=aru0kpTsQyEQogIfnOY0GkXwM3 y/JtnYXGrkFf2WxMdOGYe3og2ZwuI5gpVntxyqiyhdup7BIdMu/3bBoaXkbiqn+0QOa9oOQw9YRan MsfhQYY4vRS6lUHjvEYSJQl70DBmu6zMXfnWNJb8GnB0ZitzLtjnV+8O9MWrQMYRpCqjG0Y504S5r 9kedyYkLrllnqe6eSb5HvnG9nARgH+7nQXfSQKJfoUUX/B3Ioguw03KzyQoH1rudgXcWh+2VrYPx3 jR3Yn9teLTCQYtYu8fN1VhfxDEBBpThHHDPqcsR8ue8SuywfjnEgUCIsRpzbL7nSSvlNNsRf2xZPq f2LcL3CA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1dmRps-0004lw-Ua; Mon, 28 Aug 2017 21:44:44 +0000 Received: from mail-pg0-x230.google.com ([2607:f8b0:400e:c05::230]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dmRpS-0004Pe-DY for linux-arm-kernel@lists.infradead.org; Mon, 28 Aug 2017 21:44:21 +0000 Received: by mail-pg0-x230.google.com with SMTP id 83so4978672pgb.4 for ; Mon, 28 Aug 2017 14:43:58 -0700 (PDT) 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=ExA839lQjiG4yhKAnK6kIJwJPsepk4UTXt1UgTrm44RYglF44Hz0OaoH3pHTvI36th r+LLgx6w1rQiLh90tphG0csz88u0sDz+wrOEzOdRQy+gj9/OB/OvgRhCrB/3ePZrohCN X8LNYYvygQ8KrnuYLS8aE4EKqg/BCX0+rxBBkwwasmTmaf2bqF2yCAroKPajUyV5jlGX pSkFB9RKBrIB3VCp5MIBnxavZ3RkHA8A2gn6V4Sxvgtq+EIbbnz0xr+MCpGpk7UpoArL XNFzcSy8x+EDTa8n2PjrFFLveXvQQa7kXw4+T8Mfr93twXi51WPjzIQWwsymzWolsrns WCVg== X-Gm-Message-State: AHYfb5hbniROfhItiiWskQatek6I7HljZ9q8RBSwV0cLda8jh8Evyi1g a7pgqHizyfRBd+qahYYa+Q== X-Received: by 10.99.121.66 with SMTP id u63mr1906838pgc.386.1503956637707; Mon, 28 Aug 2017 14:43:57 -0700 (PDT) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id w2sm1894017pgt.93.2017.08.28.14.43.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 28 Aug 2017 14:43:54 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH v2 28/30] arm64: Implement thread_struct whitelist for hardened usercopy 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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170828_144418_705421_030F9A59 X-CRM114-Status: GOOD ( 11.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Windsor , Kees Cook , linux-mm@kvack.org, "Peter Zijlstra \(Intel\)" , Catalin Marinas , kernel-hardening@lists.openwall.com, Will Deacon , Dave Martin , Christian Borntraeger , James Morse , linux-arm-kernel@lists.infradead.org, Ingo Molnar , zijun_hu MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org 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) \ ({ \