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: 10156699 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 8A2BB60231 for ; Thu, 11 Jan 2018 02:20:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 77420286D4 for ; Thu, 11 Jan 2018 02:20:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6B1A9286D6; Thu, 11 Jan 2018 02:20:43 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D8EBC286D4 for ; Thu, 11 Jan 2018 02:20:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754112AbeAKCUl (ORCPT ); Wed, 10 Jan 2018 21:20:41 -0500 Received: from mail-pf0-f194.google.com ([209.85.192.194]:42168 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754154AbeAKCTh (ORCPT ); Wed, 10 Jan 2018 21:19:37 -0500 Received: by mail-pf0-f194.google.com with SMTP id d23so8820pfe.9 for ; Wed, 10 Jan 2018 18:19:36 -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=jiowmpYdSOPoeYVCnJT7LIcKy/ifWIlXHocgnfbWNVXOuxzMUVYo9SIyupz2fITiMF 8NS2w4yqHxVq0ZoBk/Q56pKbhF1ZlkPWODV8K7jW9wYBjvaAaMFSWHsVD1J+sCQ6R7/9 0Nf/qsTpvZHIKAwlZKPDH4dcM4sXgDQ1Kwk+hYw65DXUoT8qVKtdNHhTASwBj4IfvqVt sk5wh9lYMR3QACtrrsojcIVfKVLzrYHuPfO94O08ca3kl5ADMVlueKp8OzMyl0gl8eXS R5unTf2hKs+5Rwty6Kg9datmYyuRceZ4bUlyAmLBoqleMqTnYLQ/IGmVAqjpqS9RE72f TIiQ== X-Gm-Message-State: AKwxytdSJ1ahvVaoScF5n8LCi0zfYiR9++3JsiQbmFchoWWWTgmcBqC2 wSvb5yCPDGMfW4yFQNaelhKunw== 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 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, Linus Torvalds , David Windsor , Alexander Viro , Andrew Morton , Andy Lutomirski , Christoph Hellwig , Christoph Lameter , "David S. Miller" , Laura Abbott , Mark Rutland , "Martin K. Petersen" , Paolo Bonzini , 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 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> Sender: linux-fsdevel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fsdevel@vger.kernel.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) \ ({ \