From patchwork Wed Sep 20 20:45:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kees Cook X-Patchwork-Id: 9962561 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 A222160208 for ; Wed, 20 Sep 2017 20:56:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9216529224 for ; Wed, 20 Sep 2017 20:56:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 86F702923B; Wed, 20 Sep 2017 20:56:30 +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 0531529224 for ; Wed, 20 Sep 2017 20:56: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=WacL6MVjEx2K2EV+sKm8usGg9y6L0GYJshvFBfHsvDc=; b=lrIfF4xkmgQPrlW5xD2HcjO/y3 Epkg2urDSaaL+ZIkRWpQhAX469UJQ8RixdA003W1D0la1zkK9piTIMKpMHX1HKCZkf11fMaKNadmx TSXG+Spe8itEOk+t4H5IwbVcJ9bYpmj5yGu0FxmXmrSB89Hi58S4x5xxVmayMAqpUD3qyQMrpDCn5 uD+m8Sda5I/WeXRwMwvMmPz1soL9ewIuc16klEO4UOGUJUXqLQzB0+Kc1XUs28mp4YxHp+1dujqPh m3XDtbtwHVkFI4Bkzx1tpOKwRGBZlYgVfZnCoGH5m4UJSaGY7B55oJTh+PfzYh1ZxKsJmYONLF9PM T0BqZ9Dg==; 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 1dum2m-0005je-Ap; Wed, 20 Sep 2017 20:56:28 +0000 Received: from mail-pf0-x231.google.com ([2607:f8b0:400e:c00::231]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1dulzY-0002Fp-9p for linux-arm-kernel@lists.infradead.org; Wed, 20 Sep 2017 20:53:12 +0000 Received: by mail-pf0-x231.google.com with SMTP id r68so2123743pfj.3 for ; Wed, 20 Sep 2017 13:52:47 -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=TIO9yEqD/ACy+sSJTkZUlH9+FdVlt7R5A85gz6dLfIE=; b=VKhOr/8e+4p36fhU/rdNY9+gKLXidy/g4IRdL7VdVbEup7FB6SwDobbWjQ69F2nyqi 1nKFW4G0xZ+UasY+a65B567S6oC5f06DmWhWQPKhytT0ta1oX9Tc/DE66ab1QIbgjlnP eCuD1Qgb3LfoXIy8HRkTGjYZSb7KvyHbZO90E= 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=TIO9yEqD/ACy+sSJTkZUlH9+FdVlt7R5A85gz6dLfIE=; b=EFIdDjLUXavuyvFzZFecnUj8Eq4d45oQrx42kfQ0LY1/KzI1YJtYUi2gkVyUofIHKL CeCqsA8aPdy7ax4dtNni2WcM5xuOcbA4aZKsZcZyrRyGub9Qn4esZiPIfRVVBA3g4A/t PuEy5ANyAg46m6T9ulxndiPc0itXaKfFH5gb2hYBUShu7Els5P2H09+xbHOvjT37Pq/4 KQxY72+hwXiz012j/U48biNk7rHz9nCurj5UE9hBgfPxDJKpCYWTJTRPZmimIia+HnqX iw6DlLZlFJrc/1N2FC6OTKQe69pD/6jt+IAY4PT43SBInwSl7FHV+H/Zx0g6ahwuqg9w Q1Wg== X-Gm-Message-State: AHPjjUjMl5h1oHVSIhNRjl3bFqDlLSl1OAfvzpFTwXyG1j4m4DPraDP0 q2qityylEDud0ICf7p4jZTUd6A== X-Google-Smtp-Source: AOwi7QB/HEyBIJSiSs2cFJxXLELjSpOxcBXaP2aEHVK2B2TTBd+YM3iOeKcwz8uMGg8jQLHF7Fp4MA== X-Received: by 10.99.105.130 with SMTP id e124mr3440485pgc.420.1505940767514; Wed, 20 Sep 2017 13:52:47 -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 d124sm8414572pfc.42.2017.09.20.13.52.45 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 Sep 2017 13:52:46 -0700 (PDT) From: Kees Cook To: linux-kernel@vger.kernel.org Subject: [PATCH v3 28/31] arm64: Implement thread_struct whitelist for hardened usercopy Date: Wed, 20 Sep 2017 13:45:34 -0700 Message-Id: <1505940337-79069-29-git-send-email-keescook@chromium.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1505940337-79069-1-git-send-email-keescook@chromium.org> References: <1505940337-79069-1-git-send-email-keescook@chromium.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170920_135308_554777_BA9C2E67 X-CRM114-Status: GOOD ( 11.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: 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, netdev@vger.kernel.org, linux-fsdevel@vger.kernel.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 0df64a6a56d4..e190f9901aef 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_ARCH_VMAP_STACK diff --git a/arch/arm64/include/asm/processor.h b/arch/arm64/include/asm/processor.h index 29adab8138c3..759c4d90ac7f 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) \ ({ \