From mboxrd@z Thu Jan 1 00:00:00 1970 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=-8.3 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 BFCAAC3A5A4 for ; Fri, 30 Aug 2019 09:41:48 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 90D9C21670 for ; Fri, 30 Aug 2019 09:41:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="qIp0dMeg" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 90D9C21670 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=arm.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:To:From:Date:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=QpBW+Bk3hvxeMU4GA5LVl+XO7qC+jof4xd5nMK7H1lo=; b=qIp0dMegn9bybc elbOantrxt2uYXQNx7S5Wlor9mWo0A9XJ3NZe86lcpqFPsOrT/MaEuu5oqjW0B/c55WgqQf/nDWWi YXz20Ml0yPNTYki7jckhv3pE3p+NbwtTxGrXOO8+E9v0PF4D5T1sgZ8kSH6S612CzAx29MVv/L/54 cSWJ3KDzLCBhcU4vHux01Oh1QWtn8wPHVcDxzdZu8cm/okyh8Q57bbbdgEvsWXeVQJ2fu7xl5x2DM hsuRyhllhOR9zv34kY4B7BqTYkRG3grvLinYMrX8TCcAu6/QkOKH67ksCfVsjFFrfivHZJbrnOKv2 u/25zxnZc9PBWsfVZFqA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i3dPY-0003Uq-Vg; Fri, 30 Aug 2019 09:41:41 +0000 Received: from foss.arm.com ([217.140.110.172]) by bombadil.infradead.org with esmtp (Exim 4.92 #3 (Red Hat Linux)) id 1i3dOs-0002oN-JQ for linux-arm-kernel@lists.infradead.org; Fri, 30 Aug 2019 09:41:00 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id AD9B8344; Fri, 30 Aug 2019 02:40:57 -0700 (PDT) Received: from lakrids.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 59DC43F718; Fri, 30 Aug 2019 02:40:56 -0700 (PDT) Date: Fri, 30 Aug 2019 10:40:54 +0100 From: Mark Rutland To: Viresh Kumar Subject: Re: [PATCH ARM64 v4.4 V3 07/44] arm64: uaccess: Prevent speculative use of the current addr_limit Message-ID: <20190830094053.GG46475@lakrids.cambridge.arm.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190830_024059_189592_B9660DF6 X-CRM114-Status: GOOD ( 14.90 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Julien Thierry , Marc Zyngier , Catalin Marinas , Will Deacon , stable@vger.kernel.org, mark.brown@arm.com, Russell King , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+infradead-linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Aug 29, 2019 at 05:03:52PM +0530, Viresh Kumar wrote: > From: Will Deacon > > commit c2f0ad4fc089cff81cef6a13d04b399980ecbfcc 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: Viresh Kumar Reviewed-by: Mark Rutland [v4.4 backport] Mark. > --- > 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 75363d723262..fc11c50af558 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -62,6 +62,13 @@ extern int fixup_exception(struct pt_regs *regs); > 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(); > } > > #define segment_eq(a, b) ((a) == (b)) > -- > 2.21.0.rc0.269.g1a574e7a288b > _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel