From patchwork Thu Jan 11 02:03:05 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10156679 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 AF18E60231 for ; Thu, 11 Jan 2018 02:19:57 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9AE552874E for ; Thu, 11 Jan 2018 02:19:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8DE0028750; Thu, 11 Jan 2018 02:19: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.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,RCVD_IN_DNSWL_MED 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 B8E712874E for ; Thu, 11 Jan 2018 02:19:56 +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=+CfYNL5lAR8Fw7l8St4KK473NuIZncaE4rdA3orYA8c=; b=SmFoaLw6/4oGGmjLqEQfpy13XB Uwxrcp74dfVNs6kcUhlZYS6fF1bIIjdtYHpas2YJqafL7M4llHEZaBrvSqVIPf7BSfUjHBQTXgk+F U5bGwBnP2lLREu2VXs+YtbmBuwAihHssBf5Ib5ISsZBGyyl5UJBwI4c7zl7nCXI2K6na3QiGofZZQ KOKR6CWiLCwCN3y1jqxDx/Qvh2tJGPCM5S0YuLYF/TQaiZCnKsmO+1ibEZsY7AyS4JP701dunwU7u c9nxm/gcGMoR0hT6UfOZrmZVoUcxpY0V7iQJtSRzcE5yT4bUbGvgylTnJo/De6QRD/4vdF1yLNR2U D/IZe8NQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eZSTB-0007BH-2e; Thu, 11 Jan 2018 02:19:53 +0000 Received: from mail-pf0-x242.google.com ([2607:f8b0:400e:c00::242]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZST5-000788-K7 for linux-arm-kernel@lists.infradead.org; Thu, 11 Jan 2018 02:19:51 +0000 Received: by mail-pf0-x242.google.com with SMTP id t12so8765pfg.2 for ; Wed, 10 Jan 2018 18:19:37 -0800 (PST) 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=R68S45ZD6nXTAu+U1gPs/804W7IpHXuRTraDAv2wolo=; b=mKc7ezit1wJouOzKX3aT5zG5/NZ0LcZq/VnRPyzBOXHDrwqzQFcoVXYXQhVnEDAaAp VsXhVpnVGaq//rpaYxo2UWHUXGeyjpeRw812BLudrpVyFxwML0VkTsSk2P5JSXNwalvJ x5cCnHv7MosPFiLMfle+BoyUsjWKA4+h5BjoU= 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=R68S45ZD6nXTAu+U1gPs/804W7IpHXuRTraDAv2wolo=; b=FcEPc/SnFKmkT0cH62dxpI2QguyiDP+OVJ9q7OqEkuesB3IsaGRTB3OC9STvPtNFLq T/H4SodOYiIAmsxr+F+u3G68QMjhUt/t2M8bbPMb4jRD/oj9cPiOWjYZyxX9vsF0Xn9s 65ZyD+Dj9p34UyqvL0o5ZYrmfOu80IovQWHIO362doVEted2K8KbBWG2XPOZZKJ78hyB r+ff1g3CTgC6Mad2uEPggTt8Iag2cp9VhYF6HrA2TNNzFT6EvIyXIEZuNh7Ds1rdUsqJ /WUEvvL66tZVCGV2MxZHLcBP4Cwa8wgbNgKrQuTlGD8WF9kXU4C/drDz/T8rIuePBt2Z OK5A== X-Gm-Message-State: AKwxytemQUdceU7m66RpSoVC23en0CsBaXVn2RbwaU2syOpqEwag4rEt 8RhyeTzYVa5XE5jYvMzx0rcVrw== X-Google-Smtp-Source: ACJfBotziSKsiNcTbabVmfivLCqpMQD8AcYK9MO1MUnDnMNbMpO8l5IBE4ydf4K1QK24/6kEVb8QWw== X-Received: by 10.98.102.4 with SMTP id a4mr1810243pfc.210.1515637176539; Wed, 10 Jan 2018 18:19:36 -0800 (PST) Received: from www.outflux.net (173-164-112-133-Oregon.hfc.comcastbusiness.net. [173.164.112.133]) by smtp.gmail.com with ESMTPSA id k130sm37090205pfc.100.2018.01.10.18.19.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 10 Jan 2018 18:19:33 -0800 (PST) From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH 33/38] arm64: Implement thread_struct whitelist for hardened usercopy Date: Wed, 10 Jan 2018 18:03:05 -0800 Message-Id: <1515636190-24061-34-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> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180110_181947_750800_77FF98F4 X-CRM114-Status: GOOD ( 12.54 ) 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: Mark Rutland , Jan Kara , kernel-hardening@lists.openwall.com, "Peter Zijlstra \(Intel\)" , Catalin Marinas , Will Deacon , Rik van Riel , linux-mm@kvack.org, Christoph Lameter , Ingo Molnar , zijun_hu , linux-arch@vger.kernel.org, Christoph Hellwig , Christian Borntraeger , Laura Abbott , Dave Martin , David Windsor , Kees Cook , Marc Zyngier , Dave Kleikamp , Alexander Viro , Andy Lutomirski , linux-arm-kernel@lists.infradead.org, Luis de Bethencourt , "Martin K. Petersen" , netdev@vger.kernel.org, Matthew Garrett , James Morse , linux-fsdevel@vger.kernel.org, Paolo Bonzini , Andrew Morton , Linus Torvalds , "David S. Miller" , Christoffer Dall 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 a93339f5178f..c84477e6a884 100644 --- a/arch/arm64/Kconfig +++ b/arch/arm64/Kconfig @@ -90,6 +90,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_ARCH_VMAP_STACK diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 023cacb946c3..e58a5864ec89 100644 --- a/arch/arm64/include/asm/processor.h +++ b/arch/arm64/include/asm/processor.h @@ -113,6 +113,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) \ ({ \