Received: by 2002:ac0:946b:0:0:0:0:0 with SMTP id j40csp1086976imj; Thu, 14 Feb 2019 00:44:49 -0800 (PST) X-Google-Smtp-Source: AHgI3IYLjtM66HicT6cTVmZ3KX6divdAT7iyyYt3HIwGIo0UDQ+rGGu0un4h0DdHM7+o6E9rYWjL X-Received: by 2002:a62:4b11:: with SMTP id y17mr2927744pfa.124.1550133889380; Thu, 14 Feb 2019 00:44:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550133889; cv=none; d=google.com; s=arc-20160816; b=kUTzKsc4piZ8R8HLTUJEetdrAnY3h1H6bJQQKWOXks76HxqZ6kvI4CopVscLd9UnCZ 3qtlCu3ClHuEYpDPhdJOcs5P1r0jSiDt7uIgcVc+MqJagH7syKYnxDMnGl7gvCwTzIY8 /fySzF+Qepx5viR870Jkv65konR+YnjV2iT7bEnMrsBV9NZp8ODm6Wj5mQ3dyheqJyfk ih/614DBzPCdu5KY5WbG2TP/bCSWesx8ZOWy1KPYeiR88jBjjR7avGDkYz/AxciYSpdh Qof0AQX+XGtMgK12EN2ueZNihjiL4p6tTj6YZZti9GA4290HdUei20FxWsepaW94ZWUh mstg== 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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=zKNFkMhuC3gFt+/k0RjCIS7A3dLBfENEnE7dmo36MDP6zJJK8rDQwrk2OHSwWpsuJ8 G4KYJA2Yh107zsXbWZUqp717ZpdAaYOu6UDlMxa/Jkml8KGwzYw9uHCrfAeFxASsHF7S dGjlJSI8Cgm65ds3M0sgt69J0MHXMXUsjN8V8CPC2fejvDneOK8QVyaVJARMjq1nGb3B 7DH5v5MdYmjl4L2/UhxHByCf48mpqeHWAagB9sT/Nw8jKFziYCRX+A8EExT05ux0oSj2 zjkeFJCB/tZJIp8xKgJcsGPMWEYIPvspZ4laYB1gPsPuyYuGrq6hYc2lwXSoEmkuvF2L MiNw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gQABb81M; 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 g3si1763826pgi.443.2019.02.14.00.44.33; Thu, 14 Feb 2019 00:44:49 -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=gQABb81M; 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 S2436772AbfBMVck (ORCPT + 99 others); Wed, 13 Feb 2019 16:32:40 -0500 Received: from mail-qt1-f193.google.com ([209.85.160.193]:34969 "EHLO mail-qt1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2436736AbfBMVcf (ORCPT ); Wed, 13 Feb 2019 16:32:35 -0500 Received: by mail-qt1-f193.google.com with SMTP id p48so4495707qtk.2 for ; Wed, 13 Feb 2019 13:32:34 -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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=gQABb81MbKQBlmSXhqJWQfg/1AxyC7N9oosWf++hMdAGIruAgpqJYldwUqM1bmB6Jr dulsq1OpTXHG1i2jGcQeuZyZIpjlKNdKfSMyrS0u+NAnjSlxqj7zZ3qkDJYNjUsmUrJF zigsHfdtmvf3MT0gwEA2vuSBKY4RwNgfY025WHBxSsYe2wuncmOQ88OE0GyPQcL58ysd 4e65OoRDhrMM69gcPZUaLEQEaHinHgZEFhvilAAmkSckKd5/7GedCqUALyP0aiq2Fvxn HNIc7JEQhrKke9sonMbxjJlaZ3nPYoqJqcssm1/sMCPDAFExEk7IVkLGZUSwo359avMR lWKQ== 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=dQLK2/rrLChjZCacrkpff81URBJeOtphw+yxRdVdzZ4=; b=bi2w7uZEG7k6hNM2rU29fdy/ClZbdMwqiiwY+lUMlooZT5PejDZv9l1y6fWwDqHemq T2AiHNC3jGsaC8f3rFdOvbYU9eOCvWWckkBTaA/2+UvdRdrCiIjhKBAEmvpFNJGXFfxz i8WXhJ59Qbtiel3pLTLq428enl5z2zHrAzLYW59+D3HMnW9qKsuOwgS8wL2e8Hz6I2Xy T+ATRc05OX6u/OXa0JMh2beE5hhSgh8KZSAUofu0C1AnZ1wjvid3hktEeGUc1G+1SYt2 1lZaMFia1J1Sn5kjGhr5LQpu1yxAxUOHfKT4OCqgeUKKRQk5asl4NcfEt8yHjSgrr5bB /r4g== X-Gm-Message-State: AHQUAua6m67NEe3sFtRaVNQFkr8R8tVyiPycN+bbAkF5Odm1VggmnKGl flhUtw3QSJjQkLCn7LZWvTOK2g== X-Received: by 2002:ac8:341a:: with SMTP id u26mr205865qtb.211.1550093554162; Wed, 13 Feb 2019 13:32:34 -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 8sm382675qtr.7.2019.02.13.13.32.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 13 Feb 2019 13:32:33 -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.19 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Wed, 13 Feb 2019 16:32:12 -0500 Message-Id: <20190213213223.916-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190213213223.916-1-dave.long@linaro.org> References: <20190213213223.916-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 5451e1f05a19..d65ef85fc617 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