Received: by 10.223.185.116 with SMTP id b49csp2316227wrg; Thu, 15 Feb 2018 09:43:38 -0800 (PST) X-Google-Smtp-Source: AH8x226q2Ze1Ct8YNQtPD93afo2xIh6JA3E+su1KWLWEdR/x86Tlbj/J6Ba4La2En4Hg9h/onACJ X-Received: by 2002:a17:902:5a5:: with SMTP id f34-v6mr3299993plf.134.1518716618640; Thu, 15 Feb 2018 09:43:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518716618; cv=none; d=google.com; s=arc-20160816; b=JvB9bzLbpzqc7YUMOnt4enxhPPl9DPOpokbTGmvR9QIWkYgxAGZAO05dW8/gbVXTXH KFGpoGvCvFhO5BqVUdEDwpIhZtuc64oPlS38D98zEzdJ6Xmh6I+AWSmHlpn4aG37ishA 6l6SAaINCZsf9d7Q5sCciSLuWIiJUH+2LWr2LXmP32qVO+ITeN5oosaVYXb7lIuVGiMH 1Giq/YUoHZR5GD0LYR1FQKSLE4mdUngS4fiLPPaw91mj7umXYM1M+XW17Zo/Z+GQCTYB 4gchSdOA84dJtIjguWsA4XPvdSRfXdFOq6/q8SQPiedUR0BxJ9mgNdaGn9TXBM/piXRL lo6g== 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=/JkuDiqwJctpYIHlkaeE6r1apPGr6jXcXb15xLTx6eg=; b=l+LZ4Q/kDcJncFOPGzcAoCQ9eHSray+sG5xTyWfmhmmNS+Q0n5QMVDiqOM3LU8vtdi VwPrPMj5Ns3vhLh+J0eMq5T58XMhRzWDeiipidrFPJOx727FCy++ejxj1PnBnNgn9J8/ PjYuyW7p6gSjL0nrC74Z4m71hYDSOdnUmwtpqxSx1xwaW5dt6vFQCR+iuGUHQ7OyvWOa Xx5KFRAtCcnv4IyBvfG6PGMsZE6BIiRA3dlhuI1P8i+SpTWI6qQp5LWAXGmc8b3gGruY NAb0f1NMyzBX2MRsUItLE4iqtDFBUVa0ijkBZPU2NSokbQkZH90FSZDiEjZoY+1DwoiZ WBSw== 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 e5-v6si3403045plb.566.2018.02.15.09.43.24; Thu, 15 Feb 2018 09:43:38 -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 S1164578AbeBOPcP (ORCPT + 99 others); Thu, 15 Feb 2018 10:32:15 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:56306 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1164491AbeBOPcM (ORCPT ); Thu, 15 Feb 2018 10:32:12 -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 EF4AFF8C; Thu, 15 Feb 2018 15:32:11 +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 , Ard Biesheuvel Subject: [PATCH 4.14 061/195] [Variant 1/Spectre-v1] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 15 Feb 2018 16:15:52 +0100 Message-Id: <20180215151708.779414870@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 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: Ard Biesheuvel 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);