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.2 required=3.0 tests=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 1199BC3A5A4 for ; Fri, 30 Aug 2019 09:40:59 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id D6EA723427 for ; Fri, 30 Aug 2019 09:40:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727729AbfH3Jk6 (ORCPT ); Fri, 30 Aug 2019 05:40:58 -0400 Received: from foss.arm.com ([217.140.110.172]:57328 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726480AbfH3Jk6 (ORCPT ); Fri, 30 Aug 2019 05:40:58 -0400 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 Cc: stable@vger.kernel.org, Julien Thierry , linux-arm-kernel@lists.infradead.org, Catalin Marinas , Marc Zyngier , Will Deacon , Russell King , Vincent Guittot , mark.brown@arm.com 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-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.1+11 (2f07cb52) (2018-12-01) Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.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 >