From patchwork Tue Jan 9 20:55:59 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 10153305 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 08E15602CA for ; Tue, 9 Jan 2018 20:57:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F29A524B48 for ; Tue, 9 Jan 2018 20:57:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E6B52251F4; Tue, 9 Jan 2018 20:57:31 +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 2874F24B48 for ; Tue, 9 Jan 2018 20:57:30 +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=e1sXyxoLF+2EYghB324CIyRP9M Y95wF6XngV6L0O7OABRSg/JzxAlLnLyWT0DXLCwjaOxfiwxLbR7Rfj132rcVJIWfaV+4H209aHgVe wPTY2IdoIOefQijBAZd5CSCRIrUlbpuCJ/ybqBOLcSn7zTlo5D4CWiSrv1tOESh2gMygi5kJSQl4F Z28J6FpMhHhICTl2u4viwdqeNxnqWpYhv/fQuM7pF/2F2obTGIHNFZUk+BvaX4zEdT6QqLX9ZLCtt fodCfL2fMRa2JONBnahfAX7SEAEDjRc3RxbS01vmfgB9J1OEh8auFC6lNk5n6jKkJwQZ1Sm+SVOLJ 640mz4WA==; 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 1eZ0xb-0002qu-II; Tue, 09 Jan 2018 20:57:27 +0000 Received: from mail-pg0-x243.google.com ([2607:f8b0:400e:c05::243]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eZ0xW-0002gL-9H for linux-arm-kernel@lists.infradead.org; Tue, 09 Jan 2018 20:57:25 +0000 Received: by mail-pg0-x243.google.com with SMTP id j2so7608548pgv.3 for ; Tue, 09 Jan 2018 12:57:11 -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=JtWFazFc5VjbyOeXDiDnb5TX4DHjcItSJuBrq4/1mvG1d+U4NVtbr1LmRD02gtsffL vfIG4ErwwRsItop3vNNjwy6kkZrpbB0Dom5iYesM27I7gaVAYDF5t0ZzD0L8nMWcIRZL Bry/+6cVdfLYlJfzZbdhKWjRN72za4Y/AulKM= 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=bPLEqYTp2PoWN6EDjjivITNAa7VpiJd5Di7Bgkyr2ZZa/c4x+cV8MOeYC/MT+NmZQZ DLzV9Vkh9bkrpYpvX0/YTBg1/RseLoOG2JJ5jJZePSTRKVr4RfYEd+o6a5UPeVzEeyq/ 73pdydTUnOFhCF/udlFgnp1ZpUVJO2rBHuSThWBeTCQlUSMm4BYO9ERrgppcnPsTJ9AH sOnF8GYOK36cgNiEA+qMuorAgk5xSU/CceJD60i/nJOKOkNq2ha6EjfcGBymTpYZ5Z6e sac5LArPvf39inx7AAkKGA741FM9ztQGkH4e52vD1FUEA1bepKgW6xAmPOscK7AWOntw iCpw== X-Gm-Message-State: AKwxytcUW0cEvfbKpst17XotE/NUaJ72SPiWHH2JtBDIY6lhkWfxge6P zzbwmoV5gT6DoYGRcXw0z5/dJw== X-Google-Smtp-Source: ACJfBostUrlzca7of50Q2Oydt8wA0k/T1bsVtveR59xCxk90HCxm9BlA8k+ATSu/ZbIQ2tgs4HIAcA== X-Received: by 10.84.168.196 with SMTP id f62mr2982092plb.23.1515531431444; Tue, 09 Jan 2018 12:57:11 -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 r1sm33077082pfg.98.2018.01.09.12.57.06 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 09 Jan 2018 12:57:10 -0800 (PST) From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH 30/36] arm64: Implement thread_struct whitelist for hardened usercopy Date: Tue, 9 Jan 2018 12:55:59 -0800 Message-Id: <1515531365-37423-31-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1515531365-37423-1-git-send-email-keescook@chromium.org> References: <1515531365-37423-1-git-send-email-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180109_125722_343989_093373D6 X-CRM114-Status: GOOD ( 12.49 ) 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) \ ({ \