Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1184191imj; Thu, 14 Feb 2019 02:35:38 -0800 (PST) X-Google-Smtp-Source: AHgI3IaLi6YW5ux995p9ve0YxK4KD/vYjhIZMHTABKTolGXZzNWTXu+0RbBbo3HDtRl0zZEEiNfk X-Received: by 2002:a17:902:264:: with SMTP id 91mr3464189plc.108.1550140538153; Thu, 14 Feb 2019 02:35:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550140538; cv=none; d=google.com; s=arc-20160816; b=CGmYHbM6Uwu2wuq7poSqZhqZbdz1O+p4ONXyC8b0JXh/k/juYrCZ9h8w5G6KqtQO3C 6RrwxUSYan00BTV97k1/cCpEdVo1lWZ2m0bVYewY7yack6oxKUDiOpTIMortSCnDRugn +VCrqr57qtnfr9o+Cy6Y3V4XKnVGzjQ8DbrCoOSN64rMbZm/rrp34cueoteXIzd/HhcW GDHRqV3AcGIaIsufcYf/gY1N0HAJ4ssohiGucwKVll2THsyh0cqSPsIdeEpML9bknEo2 JLBQ8VqRRBtqud4apFOgp630b14qKsHkzJPtAQQhe5SwpDmYWYCPiyfWVQyhhbZZqGI1 KpBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=Udn5iWs8z7xZOkjK8EjH96pqcHpekECiVveyHFgw0sQWnnX0g0cbTyyumWXtIu5/0e TKdyIcdGiUVw+SmxNLfS4XiPlz/Wt94n1XaEG7HfriqxZ4MAK4ogscPVG3bj26ylm8+6 CR8Te9hCPq8Phd3oOmtQaIzpvQENsBO5SYrdCOlS264yNbkxiMGKl9WSf2RlAqnVXx0Z 5oy7Uc4Q9PHjI13SOiLbF59W0cT5HnZDepCaH8sQpNivCWaVANI/zmhUQ6W5DuVKxYA1 Efz619VqhvtxLNoZNvm/0MbMUas0k49fm6r4ub5LqwG3nYu3pGFemHCGJ5MZqAdczBiC TkYw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=jG9k1VfQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b5si1957365pgw.377.2019.02.14.02.35.22; Thu, 14 Feb 2019 02:35: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; dkim=pass header.i=@linaro.org header.s=google header.b=jG9k1VfQ; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2393898AbfBNCLt (ORCPT + 99 others); Wed, 13 Feb 2019 21:11:49 -0500 Received: from mail-qk1-f193.google.com ([209.85.222.193]:39328 "EHLO mail-qk1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2393918AbfBNCKe (ORCPT ); Wed, 13 Feb 2019 21:10:34 -0500 Received: by mail-qk1-f193.google.com with SMTP id x6so2706295qki.6 for ; Wed, 13 Feb 2019 18:10:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=jG9k1VfQvhqa9stEBXoUgTnHpRsxJKHOyYG1WWAXTdx1CMzgOPJoBBGUK3dDuJh7Jt InBZGJo4lOLCvI5fafIqykZup//rOWKm1rhQbXJI6Cgp0A6/3aWXP39Wln9mMvJ9Rmj5 CzZIFCn1jm0BLYVKl0ftmtfkThwrB67I7iaifVBZG9noOu3KrdPiKNUIqQGHodhc3emd BzthAd+xwHF/wbv+FojoZDOaJHpKD+uLtVrcZFAJkNxjV4KdU5P4H040Mt0tR7UMl4wI 3wCjfWy0XONYeVhoqKFxSKt5W8XA69GqUoUNvM00LDjQZPvUvKQcNPVV+g+E8CU8Pp6y lGKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=hBL7Wb0KdnmLsxeoxyLW0Tbkce8RSkol6PC9Ygx296g=; b=cKLgQeFarJ8YNs7fLi0BWaz4BfvMwWJI998X7VaUE3uM1JPSbCqwPhCcIUhP5NRKrV oOSflaDSMI8HC3PU5quemrDsvoGDk8gVbrv9gBLIDHbj/lSRPL7GG2oS2fF4lt5MAyWH 5s1NNfgPlZ7AfmEMA5kuEo2JA1xBllJAsCOj3xPIfZiYDmxmezrszp/KDbokmJD0rPkW zPS+zHVOViC1jKTrWnZ2Cr91l2LMHbO/mJaIOwq9XjUoJuJLZBhgqARh1E1snUBdnQ4b pMPFUfmj+UMckG8lb3U+PDEjKJibiqllc56EkcQHUr4/MAW0wIFQwqoGL8Z26PwBDpt9 36kw== X-Gm-Message-State: AHQUAuaWDTjiDhi2q3YDtJRd5lmvChj+q3kE7P1/TxRXF298QHr7ozOE EyJPqgwxoVFwWAeEqecxvoZpUg== X-Received: by 2002:a37:4145:: with SMTP id o66mr920551qka.129.1550110233070; Wed, 13 Feb 2019 18:10:33 -0800 (PST) Received: from localhost.localdomain (pool-72-71-243-63.cncdnh.fast00.myfairpoint.net. [72.71.243.63]) by smtp.googlemail.com with ESMTPSA id d63sm1091575qka.22.2019.02.13.18.10.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 18:10:32 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Greg KH , Mark Rutland Cc: Will Deacon , Mark Brown , linux-kernel@vger.kernel.org Subject: [PATCH 4.14 V2 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Wed, 13 Feb 2019 21:10:11 -0500 Message-Id: <20190214021022.5313-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214021022.5313-1-dave.long@linaro.org> References: <20190214021022.5313-1-dave.long@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Julien Thierry 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 --- 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.17.1