Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.1 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8ACCAC43612 for ; Thu, 10 Jan 2019 17:52:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5F41D20685 for ; Thu, 10 Jan 2019 17:52:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (1024-bit key) header.d=linaro.org header.i=@linaro.org header.b="MdjX6xpI" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729480AbfAJRwC (ORCPT ); Thu, 10 Jan 2019 12:52:02 -0500 Received: from mail-qt1-f194.google.com ([209.85.160.194]:42573 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730549AbfAJRwC (ORCPT ); Thu, 10 Jan 2019 12:52:02 -0500 Received: by mail-qt1-f194.google.com with SMTP id d19so14275685qtq.9 for ; Thu, 10 Jan 2019 09:52:01 -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=MdjX6xpIGP1iEyzIL4h+6OjyUFUzScmNRQb1WbwVJ6aOg6Xye+66YrBdM8u5tnT4VQ SrzCJMU6eH/jEhIfQEXrQ78TSlDp/CYp6FfEU6DDXrmFzUZYjeJWhECd+hbrjy5X7o0W p+WZq++ciOEGXMBCar7ZAjljSLc1b0ru6Fb40= 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=YIrw7NDOjf/xCY+0vADtOPYPgohcKrLgmiRh3VgNqdSb0+WNchKOen8MOkW0mkwQgI lucRD7gebQG3b+Q/Yck6aHCm8lMSlGlF6wxEgX+EghNoWoFJq7sz84Qqpd5EkbIE2w5r 2fs/5wwNqGpmY6u83F0QAwgpUvzdE3KN4S1VAF/g5pZDmmZRTzokHCLCZgiPf1LDLx8N W1Tr04JWImPJNWL/2V8GvtqcelruiEE00MGw5KqdYIkL/BTJIWFyjpLen6iPKB0u6xyB SjreYKPvFIlbzl7rJ2lQvvuY7xRFVp7dRAPX4VbjTCAqzXR82BygEy7X8ujyYGo/BWPO uqFw== X-Gm-Message-State: AJcUuke2ftGGmN6FyBCBK7zTBpty5SbnwOiAzleeVPEGMdLp1GmFN7Xx rfbBwycCfonAoH6L/1rZf0/1TN2WCjU= X-Google-Smtp-Source: ALg8bN7TjTLGNkajmfmOrVprL0m/k+WGLGwyM4ZTwT3sKkxg+w2oyZiwZtOxJ/HACjXjFCHQg1lkXQ== X-Received: by 2002:ad4:510f:: with SMTP id g15mr10969603qvp.46.1547142721287; Thu, 10 Jan 2019 09:52:01 -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 b8sm41815904qka.79.2019.01.10.09.51.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 10 Jan 2019 09:52:00 -0800 (PST) From: David Long To: stable@vger.kernel.org, Russell King - ARM Linux , Florian Fainelli , Julien Thierry , Tony Lindgren , Marc Zyngier , Mark Rutland Cc: Greg KH , Mark Brown Subject: [PATCH 4.14 06/17] ARM: 8794/1: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 10 Jan 2019 12:51:39 -0500 Message-Id: <20190110175150.5239-7-dave.long@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190110175150.5239-1-dave.long@linaro.org> References: <20190110175150.5239-1-dave.long@linaro.org> Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@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