Received: by 10.223.185.116 with SMTP id b49csp2253082wrg; Thu, 15 Feb 2018 08:48:21 -0800 (PST) X-Google-Smtp-Source: AH8x225mC9AEMDL3kyfwE31+0YSMhk+k3yTYl+svT4U29rudFZhW/8/ZRbuVCCK5ky48YTdJt91H X-Received: by 10.101.77.134 with SMTP id p6mr2660614pgq.230.1518713301461; Thu, 15 Feb 2018 08:48:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518713301; cv=none; d=google.com; s=arc-20160816; b=d3DxtbdF5NKpgsvlAzPoc6mvsbIwxhmAm0rBRcXdzDc9Bk97OzdYUCV+K3W8NYzEPK 05xNcgMo6YczUeCv6ZZIH/yjbHa7c87tG3WxDPq0IQROYREOckdgptZxzrAMrZZao/s3 2ohaZgnV5gUc+ahBFjMrSG2GOSPSoZQVIQes1skKSo17P2hC5H/FHE+JZz1zn17/5UbM Ft8OTaYJieXNzu3VWqfR8mBIEargpf2dEpzUDKf+s1bnXjvjZCYnui1LFkQvdxsmtQXh ClCwyuvdmlYVZsg8h5Ucd8cZdCRJuuziNlXTbFihzfOOfXPvBjilFOdf64VzxSZUh90c yYhQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=XCw9XrlCjMKahc480yOzSNP6690JVebfaU33W0vL5TE=; b=eyed/UEcx0iYKGawuyRxh8SGmnIeyLuR1WNeBlBlMuRbvOjGzjghNCB60OMr6S/5PI 1vWQXllwAHy9PnVMFS94Ve2NQtEeakkIfV6Lh0daPzdfTnYBaBKilqXfQznU9DEaHUfC +TdU0G3Jk6bgmzvHMZtLNqxhusUHrIM4SEWhIKQk5VgrxXiiUmj7F7yyvve0Ht4sX8Fg QM3TRTKPqv1YCdj33m1DTjHfcxAAD24cZTGiHiDHaSQ/HGfwRLX6CK1DToHLwKYIK+JM 2V03tVimQaJbAaFCGK8/JjCQxxbToB2q0A68nEgyAn1e3y5jQ+Mbrf2ibeC8Esxtd5OU 0ICQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l72si331513pfk.307.2018.02.15.08.48.06; Thu, 15 Feb 2018 08:48:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1426415AbeBOQpu (ORCPT + 99 others); Thu, 15 Feb 2018 11:45:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:60314 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1423849AbeBOPlE (ORCPT ); Thu, 15 Feb 2018 10:41:04 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 639FE1146; Thu, 15 Feb 2018 15:41:03 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Catalin Marinas Subject: [PATCH 4.15 057/202] [Variant 1/Spectre-v1] arm64: futex: Mask __user pointers prior to dereference Date: Thu, 15 Feb 2018 16:15:57 +0100 Message-Id: <20180215151716.256293611@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151712.768794354@linuxfoundation.org> References: <20180215151712.768794354@linuxfoundation.org> User-Agent: quilt/0.65 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.15-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon Commit 91b2d3442f6a upstream. The arm64 futex code has some explicit dereferencing of user pointers where performing atomic operations in response to a futex command. This patch uses masking to limit any speculative futex operations to within the user address space. Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/futex.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) --- a/arch/arm64/include/asm/futex.h +++ b/arch/arm64/include/asm/futex.h @@ -48,9 +48,10 @@ do { \ } while (0) static inline int -arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *uaddr) +arch_futex_atomic_op_inuser(int op, int oparg, int *oval, u32 __user *_uaddr) { int oldval = 0, ret, tmp; + u32 __user *uaddr = __uaccess_mask_ptr(_uaddr); pagefault_disable(); @@ -88,15 +89,17 @@ arch_futex_atomic_op_inuser(int op, int } static inline int -futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *uaddr, +futex_atomic_cmpxchg_inatomic(u32 *uval, u32 __user *_uaddr, u32 oldval, u32 newval) { int ret = 0; u32 val, tmp; + u32 __user *uaddr; - if (!access_ok(VERIFY_WRITE, uaddr, sizeof(u32))) + if (!access_ok(VERIFY_WRITE, _uaddr, sizeof(u32))) return -EFAULT; + uaddr = __uaccess_mask_ptr(_uaddr); uaccess_enable(); asm volatile("// futex_atomic_cmpxchg_inatomic\n" " prfm pstl1strm, %2\n"