Received: by 10.192.165.156 with SMTP id m28csp228665imm; Tue, 17 Apr 2018 09:09:49 -0700 (PDT) X-Google-Smtp-Source: AIpwx49PJ2pJkaI7KT0qBtnchIbb3pV7bd6/4XGLL1hqpwPEi2GaTbP9Qu+MpYj+io5dmUMK3bQR X-Received: by 10.98.56.144 with SMTP id f138mr2523434pfa.173.1523981389491; Tue, 17 Apr 2018 09:09:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1523981389; cv=none; d=google.com; s=arc-20160816; b=REtWbScw1Ussao+Aqm7tNKRRDW2UbrwcjpLbzW5tfuuqfoS2zOaXyv830rNDOX5JHF DWhcRbYKhH8bsYM6aIP0nz35n5gTBDPT0Yfxk7XRGYQjnagNYP4jDSpK5zNol0rL3ska MD8+Puki/DZ4M+/tonHpEYHql9nw4IKtZUr+TzUZP2AKaWFsnF6f0wfDb3WMQscw5vly et3Qgz9UoEWnw1mkwVq/2z17nh/M7wDLdgW+VmIPEp60FUQ7pX+bpxqKhkEhWdGFL2H3 XESML5GTrwy6EkmV16WweNH6f75XcAOFtaNZva3xc+KBV7dT3ghvUW1FmNYe51om5RuT ZmVw== 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=VmYK7I/sW6epTUOOanYxNK5UpAiAK4Kh9veI24oAQtY=; b=YbG6OUej7gBNiy8gFKkUNAfeMLucVWZ/KGxoCWq72n3gHR3vuEWmNPBbFQ7p7K7ltZ LcU45vxEK6n+mdYO+1osgx+U+ZTYxRVvjjBoihgo0C470j2ZNQz9EK5pJ0t/mafw6oVW a6j7id6yLDM1+4jRbdYPO5xOOHkad04x2Jz9XeN8JcvAv6mmKdjXBQEDmCaIYQLg/pMp GT4LuRBSEpJ5z4LHTTF8rXnfYfOoqcoY3wc0zBAqRbghN2MRgQ4TbGw4qQUugamHvtFA 1PFXVYahRSZDTq7oiZOtQbomVec84CMbqgIYqwMZJWzKtggk5FqCXNgnckWjqa+4pQJ8 nMOA== 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 y72si13204471pfi.46.2018.04.17.09.09.35; Tue, 17 Apr 2018 09:09:49 -0700 (PDT) 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 S1755439AbeDQQI0 (ORCPT + 99 others); Tue, 17 Apr 2018 12:08:26 -0400 Received: from mail.linuxfoundation.org ([140.211.169.12]:35478 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755405AbeDQQIX (ORCPT ); Tue, 17 Apr 2018 12:08:23 -0400 Received: from localhost (unknown [46.44.180.42]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 23601E3A; Tue, 17 Apr 2018 16:08:21 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Greg Kroah-Hartman , Mark Rutland , Will Deacon , Catalin Marinas , Greg Hackmann Subject: [PATCH 4.9 16/66] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Tue, 17 Apr 2018 17:58:49 +0200 Message-Id: <20180417155646.551501269@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180417155645.868055442@linuxfoundation.org> References: <20180417155645.868055442@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Mark Rutland From: Will Deacon commit c2f0ad4fc089cff81cef6a13d04b399980ecbfcc 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: Mark Rutland [v4.9 backport] Tested-by: Greg Hackmann 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 @@ -68,6 +68,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(); + + /* * Enable/disable UAO so that copy_to_user() etc can access * kernel memory with the unprivileged instructions. */