Received: by 10.223.185.116 with SMTP id b49csp3498500wrg; Mon, 26 Feb 2018 00:38:32 -0800 (PST) X-Google-Smtp-Source: AH8x226nEF5yo8GTJlU1RyP6lR021iIHPzsbQNCbbvz7WnbF6fbMF7bBDnU0WgT3eLDoQET8Olxm X-Received: by 10.98.171.24 with SMTP id p24mr9835730pff.71.1519634312018; Mon, 26 Feb 2018 00:38:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519634311; cv=none; d=google.com; s=arc-20160816; b=fNSvZi3ohMjrZB3yZJfDluVN092y3tNqLes6JVGCERVxVIz4xbTuH+rcXWtHmK20// IJ0KW+HMepbiWUMurU9+rGMAad+FR6pVTMCEJmy4HKVzHhrr2eE27zEbMHzIKVEHmuOt YaSRvP+YURDcQLfSb/QSyt3vvb01Sa3yg+5LuZofg/xVYN5IrO6ZVs+rziJNxUfNWkQ+ mRHZlwvOBtY3FP1kUviSOMgAyhR+hXXLPDXDB8hnvaojf6nsOEYrXJVVvBQDVLPLVQ5U 9oRISxzZGt9rH4VjOdUYF21DXnZUwDUK5n4nhY7pNnlnGtP3Oc1B//YaEUdimvPjCbeA ra/A== 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:to:from:dkim-signature:arc-authentication-results; bh=XoltgftvsVb6cg5EoqmIT2rqheB1dI0xAlZ6dp7AzjE=; b=MikrICAlhvKbMJW+iQeDutfBIOsr4ZLTqhfkKvemNUic0Qwqsb+7p8hpijkaPrB6ZJ orDEQOrSJuF2wyt+5aGiVaLc8cBakFyeRAoUMQ2Tl6KmLnG5lz2ewHOFJ5bnq71hJoTw Tg+WHKvcs6wHLuGpsjTpOBuMamqRENWoBYJM7fOVThypreyIZTuToG+2JSaOEXF3BRcX FUjJ4pE0shpXaVhRheiloyy9NssTB297pf79cpwpSVETXjx4+dIqzyusF0zMCXNKiMGL DnTOH0Z62wKjMe9oJACdb04CfOb8y6+hzT3gnLcKqEDa9LgxS7zt4Uq3MoWdSxM7A3t/ p90g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Gwp5XxQ5; 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 n20si5270671pgv.214.2018.02.26.00.38.17; Mon, 26 Feb 2018 00:38: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=Gwp5XxQ5; 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 S1752455AbeBZIWt (ORCPT + 99 others); Mon, 26 Feb 2018 03:22:49 -0500 Received: from mail-pg0-f66.google.com ([74.125.83.66]:42877 "EHLO mail-pg0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752449AbeBZIWn (ORCPT ); Mon, 26 Feb 2018 03:22:43 -0500 Received: by mail-pg0-f66.google.com with SMTP id y8so5905259pgr.9 for ; Mon, 26 Feb 2018 00:22:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:subject:date:message-id:in-reply-to:references; bh=XoltgftvsVb6cg5EoqmIT2rqheB1dI0xAlZ6dp7AzjE=; b=Gwp5XxQ5/4x2yaA+PNjtbUdklQAqRcBSTLsVH2yEcJ82PNXHXaU0l1ySt5nIRcTuGK 4R8cZTxwdd6iUCur12qIqRiJc0U+vm8Jf79x2yclDajkrNKApkZ5eqzGc2z55Hev20Vq n6jl9CmDbpIxQFDB6z2DjMxnVnJbEOp22qwQo= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=XoltgftvsVb6cg5EoqmIT2rqheB1dI0xAlZ6dp7AzjE=; b=EujGS2/mW5dboMXU2CeUxSzz90ADYlgqHuKmNu9j/Gwe3FceAIGEEDNVt38dWUyOAk vpm6od7VG1E6llI2p9VhaJc3ZwusZWadK1TgyR3o187Dv0D4qZDlkyD+Hwl/S0txfuxQ 50+Bcff2di6qor8N2f3A7NYAfSgeMMntKjzysSE0EwDtzV4DgqYkgZ4E56by/vJZq0f4 yXAmpie46tlZ1+fOwbiTgIcui/d5Jbf1zOWEE8xvaC+i9dIhsZZFXlSDMwVkkrZ+xqY/ kB/Qmi6bFznzX8p4GRSPtLs81WUu6MKPgqvsqamB3tIIsfS9tIr7+mQhmonFQRiJLpLg qU1g== X-Gm-Message-State: APf1xPBCBtvmttTOiumBvnuwqGc5fNLIJ/rOSFtDsffQZt2BM1eeoMaU +WwX1pFdMln0ORZ5Nhm1PP6Wig== X-Received: by 10.99.5.197 with SMTP id 188mr7795225pgf.196.1519633362563; Mon, 26 Feb 2018 00:22:42 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id o86sm1422706pfi.87.2018.02.26.00.22.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Mon, 26 Feb 2018 00:22:42 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org (moderated list:ARM64 PORT (AARCH64 ARCHITECTURE)), linux-kernel@vger.kernel.org (open list) Subject: [PATCH 13/52] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Mon, 26 Feb 2018 16:19:47 +0800 Message-Id: <1519633227-29832-14-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> References: <1519633227-29832-1-git-send-email-alex.shi@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Will Deacon commit c2f0ad4fc089 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. Reviewed-by: Mark Rutland Signed-off-by: Will Deacon Signed-off-by: Catalin Marinas Signed-off-by: Alex Shi Conflicts: no set_thread_flag(TIF_FSCHECK) in arch/arm64/include/asm/uaccess.h --- arch/arm64/include/asm/uaccess.h | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h index 3531fec..00025c5 100644 --- a/arch/arm64/include/asm/uaccess.h +++ b/arch/arm64/include/asm/uaccess.h @@ -71,6 +71,13 @@ 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(); + + /* * Enable/disable UAO so that copy_to_user() etc can access * kernel memory with the unprivileged instructions. */ -- 2.7.4