Received: by 10.223.185.116 with SMTP id b49csp2614309wrg; Thu, 15 Feb 2018 14:41:54 -0800 (PST) X-Google-Smtp-Source: AH8x226bgDrNqKbfkYxjnuFTTX4s+8drFaIopWdVXz400GpcpFyNdDiXS9ImpTeLkrng2aJiV/5E X-Received: by 10.99.144.74 with SMTP id a71mr3400547pge.244.1518734514537; Thu, 15 Feb 2018 14:41:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518734514; cv=none; d=google.com; s=arc-20160816; b=Gt0z9ZsP0Y/MlpqsNluXZ7D1jUCdfaF6l0je61em6ZgYED2e28fJtuOSHFV89l/cJH q4rUugws6lhnr/2/15FgFrR9KIV0E3y9qbGlVZTTAd9WYkv4db61zrVS58RifZ9Hv2Ct 8rdvZ7jLh0ny5q7ZUSjRbBQjoLfzY/Qw+yUV14GsW6mlEJxH4bKXK/cPKFD8YOY2HjWI zULBdjjJyZS4hfXIBy469dSb9lgZjuhNZ5Kooy/bMV9FWTnLvcP6pi4UMtAtitPzgmpk A/5XLve7KJwBUMAyhpAmv3TZQXnbYuoneZ05kXneOEuG5iWWEp0dg9sajYKZD7o8DL9G Zmpw== 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=vlQXjh5/BegbQ8vLxI9If0sFN/u4TIIrm2RInEEKDsk=; b=MHz2jYnQ/B8xPYWX+rYQY/sc38J9mpwi9+uLZzSvumCwDuTlTuU+euZFxfveYkxcAo rWFbTrOYkV3N6xP6YbdbLUnT/iPWcO3Hwi6b9wccT7fWxuN4DmSP1IrH71AJmJoGCbc1 Sol8kAvNESgnrliltfDVGQ1qoorh1HpCHV9EvXO09ppTYeHJX4mLs9DcsUFrXW8IAie2 S59qeBBCnZyqRUHnkcdTX1dE9jne3ZSFKOa9M46npnpNlvy1WaMdmRTRdHm5+/jNVCgm uP5aR474SD8KupnW3znaWXdTLoM7HfF76ujNssLfyP3LQm3TzRDZQ6RXaluUy14Wh52W eSdg== 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 23si477929pfr.333.2018.02.15.14.41.39; Thu, 15 Feb 2018 14:41:54 -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 S1164608AbeBOPcX (ORCPT + 99 others); Thu, 15 Feb 2018 10:32:23 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56350 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164581AbeBOPcU (ORCPT ); Thu, 15 Feb 2018 10:32:20 -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 0102CFEC; Thu, 15 Feb 2018 15:32:19 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Will Deacon , Catalin Marinas , Ard Biesheuvel Subject: [PATCH 4.14 064/195] [Variant 1/Spectre-v1] arm64: futex: Mask __user pointers prior to dereference Date: Thu, 15 Feb 2018 16:15:55 +0100 Message-Id: <20180215151708.910132436@linuxfoundation.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180215151705.738773577@linuxfoundation.org> References: <20180215151705.738773577@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.14-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: Ard Biesheuvel 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"