Received: by 10.223.185.116 with SMTP id b49csp395764wrg; Fri, 16 Feb 2018 00:27:44 -0800 (PST) X-Google-Smtp-Source: AH8x2257ob0WRWhb5QTgu54PYjB385cj3WkFnLCYHBblY/jmFhWEvPuX9Tua17C0v0R1rZo1zMOD X-Received: by 2002:a17:902:5501:: with SMTP id f1-v6mr5109309pli.50.1518769664397; Fri, 16 Feb 2018 00:27:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518769664; cv=none; d=google.com; s=arc-20160816; b=Bc2wrIZ6ba2kDam/i6BkjEtQUBhsNrgJ1rcePTgMs3vJMO5aMGGYLesxOFla9G8zAL pjUBIifJ8WZg1Kx/BUvWZiYkIJwljOKHgT6dg9v7whuYiQFVI1oVKPZET+QWmqdMi9VB dJ4+k6DEKneY43xnoZrAa/+HnIKNwtUYgGhj6tpbFSe2yqYKddveHuYPPQ9a3jhniOfN GDoFnplc746mkn9/1zUhO6Z5X/+zl7iQ07h87ObjId2yFESDuUAAh8vyG0t9lL2k7c3C DgZ4HsC5Dn9dzEcebLHnX7rX8yBNlMi2/K3kj5HR9mcHLCyLnEvCZAXqbpZnyJgMmKe4 +PLg== 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=IhS5h/2pJOl4wpPWQ6EWO227xTLkCvGNTvjDjJI3dWY=; b=oIqWCUo+pRkwpuoq/0qJPVTVHgaliCyqzWhIhcqHDM3BHRlHe4zum8nukRLnIVXA2J WUTgMg2uhGGkFuWekTFNb2fwuJVYpoWJobtzGgx3IFoqV4t18z5hZf+SYdL5Y38fU4C1 gYce37NVK99c3PJSxdtDUr8sESii5m5iv34z7thXlriSbx2kUplPwStZPIvqJ9mT0Sq0 dv0MY7hGPizKLREkwn/DpQbx4k+nNO+5keQqHSd0EBWuhcg18gVfPsB32vrczqHecPs0 XYKLxCmic5AabzEhgLciz0C/0i4UF4nZybKSs6PDYmTE3xstEcU0jFKrfgoDVg18FyFh 2zTw== 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 w17-v6si4405481plp.44.2018.02.16.00.27.30; Fri, 16 Feb 2018 00:27:44 -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 S1425894AbeBOQ2w (ORCPT + 99 others); Thu, 15 Feb 2018 11:28:52 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:33372 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1424201AbeBOPmk (ORCPT ); Thu, 15 Feb 2018 10:42:40 -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 45BB91076; Thu, 15 Feb 2018 15:42:39 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Mark Rutland , Will Deacon , Catalin Marinas Subject: [PATCH 4.15 054/202] [Variant 1/Spectre-v1] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 15 Feb 2018 16:15:54 +0100 Message-Id: <20180215151716.092760265@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 c2f0ad4fc089 upstream. A mispredicted conditional call to set_fs could result in the wrong addr_limit being forwarded under speculation to a subsequent access_ok check, potentially forming part of a spectre-v1 attack using uaccess routines. This patch prevents this forwarding from taking place, but putting heavy barriers in set_fs after writing the addr_limit. Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Greg Kroah-Hartman --- arch/arm64/include/asm/uaccess.h | 7 +++++++ 1 file changed, 7 insertions(+) --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -42,6 +42,13 @@ static inline void set_fs(mm_segment_t f { current_thread_info()->addr_limit = fs; + /* + * Prevent a mispredicted conditional call to set_fs from forwarding + * the wrong address limit to access_ok under speculation. + */ + dsb(nsh); + isb(); + /* On user-mode return, check fs is correct */ set_thread_flag(TIF_FSCHECK);