Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp2475740imj; Mon, 18 Feb 2019 06:40:34 -0800 (PST) X-Google-Smtp-Source: AHgI3IZVbxuq41ROGpIOocBCTtbks7yQThNj02GqGafnIK//4k4qLXg2/p93Z1ttXlr3rgKbMOpV X-Received: by 2002:a17:902:5a5:: with SMTP id f34mr25810731plf.161.1550500834653; Mon, 18 Feb 2019 06:40:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550500834; cv=none; d=google.com; s=arc-20160816; b=hMk3J0H92haB+HPZpzWX6AcbzEy7JQfmfBIF34gjN8kvTVCJuLbiEtJPPIFgnl9Qm+ exTCinDlKREMksZbExfDOmKVB/N5qBfbE40Jg6x1FODQUgnMiug2ZkDsF4W2Q9qx6CfM bFYiMvyZMyOMrQpXwUnRWwgEBJ821bUbc03qf8mwPctJCOFYWwB4aIxhosamk3qux7I3 kGQ09/Wi+wgfc/morqIPcS5G0kdgchuEPo3kDovOT8izd8tpFi1nAWpHCcnY/8wFWNXc eJFMtX29xzbw7YkjnGaI9HxLrvvtKLJ34UGFTqamlxj8aCAK3N1QevHxzyFmTyoftMP5 U7fQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XItUgyuk3JAWuqVYID2y3nkXiwVoIVtWFOJm/ch6MIo=; b=uDkBtb9n7tb2AbBF04mi2fu+eLmSg4Vqy/ZruhHeL+0AJjQpIOUXrg741Gf1CGCy7k 0Ukz/qLA6y8+69dFknWzaPrfvMk6fy0L96wc1sOut4w7aAqwjEEosSfO1h5r7o0kFrn2 yw877jDnYrkd3ynCUPiQi6osdyxhjW6kEALPWWQik53WbBpFlOLzxUdi7H65jXpiAR1j i52wo35SyzlzcBik/FV+uLMhm4dbao5qYlkkFG0aUUiALiZhDwBnOKhf5bSWpPAFE8Qk Jb93a5eCM4B/o+0nJgw4dRHorJk/0zGVAdjZBb0drZKVItLHhFDUebO+u92SqRB2+inR j7Pg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=1+LhP6FK; 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 v10si13615007plp.424.2019.02.18.06.40.18; Mon, 18 Feb 2019 06:40:34 -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; dkim=pass header.i=@kernel.org header.s=default header.b=1+LhP6FK; 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 S1733182AbfBRNyZ (ORCPT + 99 others); Mon, 18 Feb 2019 08:54:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:34226 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1733151AbfBRNyT (ORCPT ); Mon, 18 Feb 2019 08:54:19 -0500 Received: from localhost (5356596B.cm-6-7b.dynamic.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 377CA20842; Mon, 18 Feb 2019 13:54:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1550498058; bh=CiJjSjLZ0k2upHtqjVBs6SwsOM1wQho2ho0/6xV+1dc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1+LhP6FK3Wf8pcTHC0S3ozGlC6L63UyTEfQ1FzdlDhyKb95zQmPGa7cpgM88vW93M Z+aVDbkMKfjVAM3+YA7Nl9IzkeT2biFDL1IFym9ZW2O+OO1XQaRHpHWRekw585qEqo hEIRpZn3Oaa030wxAcqjJL9HOYvwjfpxtj1Ujktc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Julien Thierry , Russell King , "David A. Long" , Sasha Levin Subject: [PATCH 4.14 10/62] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Mon, 18 Feb 2019 14:43:16 +0100 Message-Id: <20190218133506.710093576@linuxfoundation.org> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190218133505.801423074@linuxfoundation.org> References: <20190218133505.801423074@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. ------------------ Commit 621afc677465db231662ed126ae1f355bf8eac47 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. Porting commit c2f0ad4fc089cff8 ("arm64: uaccess: Prevent speculative use of the current addr_limit"). Signed-off-by: Julien Thierry Signed-off-by: Russell King Signed-off-by: David A. Long Reviewed-by: Julien Thierry Signed-off-by: Sasha Levin --- arch/arm/include/asm/uaccess.h | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/arch/arm/include/asm/uaccess.h b/arch/arm/include/asm/uaccess.h index 4140be431087..7d19584f5c39 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -69,6 +69,14 @@ extern int __put_user_bad(void); static inline void set_fs(mm_segment_t fs) { 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(); + modify_domain(DOMAIN_KERNEL, fs ? DOMAIN_CLIENT : DOMAIN_MANAGER); } -- 2.19.1