Received: by 10.223.185.116 with SMTP id b49csp7392837wrg; Thu, 1 Mar 2018 04:58:54 -0800 (PST) X-Google-Smtp-Source: AG47ELtP7GXSac7yjnUu/3LaFDzHsMRjyUiTFcaZxPU3z6QLLZhVmEdyy2eyZKty/gkN7j0ASt4K X-Received: by 10.99.55.11 with SMTP id e11mr1480455pga.237.1519909134722; Thu, 01 Mar 2018 04:58:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519909134; cv=none; d=google.com; s=arc-20160816; b=ZKgoiA9800IEkuQ4DhuOrVhCYziiTLUk4h21ywPZG+MWMFTYjIeT27DSuSDvXOmF1I G+BcbklbTb/PK7kPZNqvFe7o9643YMWRIrXleW4BsnERqON2zd3+LRrMuqAqqICbXbUg U0Yyp/8TGek37yRfeZNYlktbPt68GgJarH7dNAQetSkb5uF7ga1PFdMtoiLodWTPATFF QwtbhdL9jQjkF06i+zUiaQiMs9PP/aGZTqQtXIQ+do+kuzE0kHZJd6uk4XqAgqC6R7Nb UcbNaRIRpzVyc9Xj5+HfNOooaidpCn79vEfkLjGJSZx5qpENpblKrKOEDG/QuzbipyEn o+QA== 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:arc-authentication-results; bh=B9j5UF0uESTYsHgGAtUITtbvy9Mt1eVCWXup4v2dg9E=; b=jTKD3qiHqz+e1o8QLX463+ix2jx1jCTFFzkzTpdP3w+hUB6712CeEcBvzOJnnbPioj hJhLD2jim3rf19Jp7Hy3wnTLM/ymQeVOlRY/1liILV4v0O4dJnblm3YRPgAAJwgpynJ6 kvzadrMeLzId58hFDaextsrDEIOVv9ACrQgMPnV0g4RyJ13J2Gdd6Xtxd9XLcH0z+fby I4k77JeU/gOiQ7UOIZ8e/Q8Jedfpgx+aOH38mHj1hr7yF78RRhajYvx1ApEoAAQfF2io kTI3/5g6P5Ckpl+LAWTunGUa4xcyvAK3FbjhM3mT5DteeKNqmZzsdPgtdpQ0Z2TLRxOP qbaQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=L/9E5Ltp; 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 k8-v6si3021978pli.490.2018.03.01.04.58.39; Thu, 01 Mar 2018 04:58:54 -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=L/9E5Ltp; 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 S1030784AbeCAM46 (ORCPT + 99 others); Thu, 1 Mar 2018 07:56:58 -0500 Received: from mail-pl0-f65.google.com ([209.85.160.65]:34554 "EHLO mail-pl0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030545AbeCAM4z (ORCPT ); Thu, 1 Mar 2018 07:56:55 -0500 Received: by mail-pl0-f65.google.com with SMTP id u13-v6so3594424plq.1 for ; Thu, 01 Mar 2018 04:56:54 -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=B9j5UF0uESTYsHgGAtUITtbvy9Mt1eVCWXup4v2dg9E=; b=L/9E5LtpJm2HVM2hM3oZ4BRU2ItlnylsxSkB+i33/7KgxxYnknzyJd7p/POIFigpYd TEKeg92LwkyH/j9FPEJZUVnwTG9Rsypub2fGgBV80aHn9kjh5aE66gPNJncuu4LJ7w0/ IrZ66XFjwkpfm64Q1AWGMJ3lHm4MFNt2vaRhA= 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=B9j5UF0uESTYsHgGAtUITtbvy9Mt1eVCWXup4v2dg9E=; b=toyvw6udMxxpJL5gNpnuCoJIxPmKU0R/GF0iKIVTFHyau03syYe5Mv/7r/Pxz7YjTH w/AB3y5hOHcJORK9Bqy9KN4VgagXeHGMU1ZX0fuDtJeq+YmlcIDeNf+S9HEz88D/UWWh RH0f16KgWjlSebyLJKPSLwwSS7wd3Oidjdam4Teaem0gkznRuzFzu4QfTKylvWySr3gu yAccDGBplo7vRwtWnjdD7ecMh7EyRluh5KerJG2D+t1gd62d46WOw1YartfpoGxxIsCT UKoaGd76CNUTn6UA3I/hmLimv2MUk/X/TdHW1qWkRz8sFdkOt3Vkc1L4uIPZA7xikomO eyyw== X-Gm-Message-State: APf1xPASBbGQx05CpS7zKyBb4vRuRkSXetVCeBCWlrbKyNit5EikOxV2 yf60zmLR0wkP++OUSHidjAUkMA== X-Received: by 2002:a17:902:7182:: with SMTP id b2-v6mr1823353pll.331.1519909014428; Thu, 01 Mar 2018 04:56:54 -0800 (PST) Received: from localhost.localdomain (176.122.172.82.16clouds.com. [176.122.172.82]) by smtp.gmail.com with ESMTPSA id x4sm2289655pfb.46.2018.03.01.04.56.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 01 Mar 2018 04:56:53 -0800 (PST) From: Alex Shi To: Marc Zyngier , Will Deacon , Ard Biesheuvel , Catalin Marinas , stable@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: Alex Shi Subject: [PATCH 13/45] arm64: uaccess: Prevent speculative use of the current addr_limit Date: Thu, 1 Mar 2018 20:53:50 +0800 Message-Id: <1519908862-11425-14-git-send-email-alex.shi@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1519908862-11425-1-git-send-email-alex.shi@linaro.org> References: <1519908862-11425-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 --- 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