Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp98077imj; Thu, 14 Feb 2019 16:10:31 -0800 (PST) X-Google-Smtp-Source: AHgI3IaQZ2B7iimHWjNucrOcnQqMZIOM6kODxownAiZnsj4XRWP4AhyHHezBKDKi8+5UNNqARnzE X-Received: by 2002:a62:12d5:: with SMTP id 82mr6903321pfs.255.1550189431217; Thu, 14 Feb 2019 16:10:31 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550189431; cv=none; d=google.com; s=arc-20160816; b=Z96nGS8SvUrWAuN2C1WwTxJCh3MQzh6fOehExcZz4RCOvLimQi3Csv2rxmIsMjNw73 HoxPFte3IeE05QimfT6kZ6BB4b10JYKGkTrxDTnWW8XiUkK4KIcAhOJDLFusUwiPyLUS sC6/wbT6Bu3ZfRyDhc72DTs+W0iGd3vPB886ksZGdLC5WGkVE6Sqwad/2APv5MblBz2z DExicL9sX61HIer15xXeAZ+u5FbxEGCQeSOzZGnoPdnBr4C8Grdt2I+LhDKQ4mYWOZUW tHLHs0zZgBAFTbHHaE6fv/2jtXx+ISltCyBK45oiUupMdYXwwSf1uW27XAkDh8RHhiXF cAbA== 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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=q5nlV88WPwOe4yYIhaex8aX5AkMTkP5FxhRWEAekyVsAA9wBrlRRxuZSHA/FcgoHVY gj+Ia7UpMTHkj3pr6SYLuV2jjJm8KMf4uGFumvqWIM59G2l3hTsyVWLVdDyonPav+L3/ yiITHwUcq3glBwhES0Nb8xVlCHwO/9yvM+dIuAscVb8VUr1UGVnWGfAse8EsxlgoSfkc GX0mvqWbBASlKTy7Ma9Lqi+++3mxaa9OJN4hbWZ5eeOB1yA4zBlKieh8EFSVaBLlbqt4 xoWxs6IecliGmnM1ux+mH7kdDKDs+pujDkJeWTxiSpC/0gP8qe+SlazUOG1/dCWeLSSN e7tQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=miavcMRK; 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 h191si928310pgc.302.2019.02.14.16.10.15; Thu, 14 Feb 2019 16:10:31 -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=miavcMRK; 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 S2407353AbfBNOvT (ORCPT + 99 others); Thu, 14 Feb 2019 09:51:19 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:43921 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2407285AbfBNOtk (ORCPT ); Thu, 14 Feb 2019 09:49:40 -0500 Received: by mail-qt1-f193.google.com with SMTP id y4so7064859qtc.10 for ; Thu, 14 Feb 2019 06:49:40 -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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=miavcMRKjxTTt1NnXSs9S5SIgv6tQi9tuaM3o7X7tprvmlvmHyoXop5aflXJXeIkxx do6zn2NQHvlyFLkcgrVE8GxZj3wMi/CVz+CAeO2sqXb6/JH+94dcqoo6axIotNkQff+y nS0SpEGNhIyWDYBl0wL/nOf4e/jaDpfvwpp1OV/osZTnnbxkBW83unDmtBBHN/lQA1w6 9pC94Au9Z8viUxDsy4X6o/h3vdSZrDOs3mAZ8WYwEDDgb7YDGS3LA1ga3UIJ4UFLuCRp wz7fH4hU0moX1giYjpcsYQlvD6N7pgpZWQN/iAIubXQpPjWD3vN9huAkB0S0ACkixiWv n+Lg== 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=zCTqVlx5Etjzo5hueWu7ypOoXoXF8xnytS5XFeEjaGs=; b=K8adXS4FImQZJW9LnE8VG9tB7oHegKRuFtC6b+fEuZ8ETBzs4WH6XkIZBUTsSlBUJo x9DI5Mzi1B0e7mqZ3eJOG+Tmy3kLkhK3XneK935UyKoDOenqJtroMBwQAHH6TK9KtQk2 gwdSc8hw8DksgL/BPwLey/GxQ704D6Fjc2q/4CbRXuYp+ONlLz2Mm7S5uS5z+KOwAtfN dtwh3hHtXjD9/FInNaHnbVCqjI2Wyxel6jgwnTu4Zvj6xAzPFzYaz7BNMy0X6JHDIWLs DN8yUs35agY6POspSZGvX6YTMDSFM63XHfj7atxzsU1ye+pb7KoMw/cphgi7ieFQwP1n cm0Q== X-Gm-Message-State: AHQUAuaOAvxikv/1Fn+e5GFvjesBZHPHwkRsHzRKM+EOf2pLhiJ9uLbz hoyFEoc/VoW0YSqG5UnJumclTg== X-Received: by 2002:ac8:26ea:: with SMTP id 39mr3372612qtp.351.1550155779753; Thu, 14 Feb 2019 06:49:39 -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 k66sm1498919qkc.25.2019.02.14.06.49.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 Feb 2019 06:49:39 -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.9 05/16] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 14 Feb 2019 09:49:19 -0500 Message-Id: <20190214144930.27539-6-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190214144930.27539-1-dave.long@linaro.org> References: <20190214144930.27539-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 7b17460127fd..9ae888775743 100644 --- a/arch/arm/include/asm/uaccess.h +++ b/arch/arm/include/asm/uaccess.h @@ -99,6 +99,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