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 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 smtp.lore.kernel.org (Postfix) with ESMTPS id 36328C433F5 for ; Wed, 22 Dec 2021 13:04:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References: Message-ID:Subject:Cc: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=1duLsc8BqThbd9AKAXaRWxTbCyyt+iaftgwdddCVqWo=; b=mqFg6gHrqHnzOy dOr/35SJ4z6fReS2JIKxMbUIUwJfsyPs5BIR8JvOM2gopEnoFrlscUNolwBrpkCyRx9yqDpK9emTo p45+GNaEHKOTE5vOrigW9Jq29FdRPP139DmrkSyANZd3/6cZUnpX6D45im+tEvIs2ShBN8lyAuAcE WSJIoPwR0XcXrPAmm1+Tj8L5Av4ERosovGmYLEcqI/Wq3dx0QvSOfwleMoS3zxYKy49D2m8h9pxP2 0i1fdy+zShXNz3B51wBzaNAcOGjdw1swOK2ja5N/8NU/rtV7PoxpV9aOHiOEdt/qHOMYlnnIm2Uto 2NE7zItMBcIu3QlXOpfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n01Gg-00ANpR-0x; Wed, 22 Dec 2021 13:02:54 +0000 Received: from dfw.source.kernel.org ([2604:1380:4641:c500::1]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n01Gb-00ANoU-TG for linux-arm-kernel@lists.infradead.org; Wed, 22 Dec 2021 13:02:51 +0000 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 66D6F61A7B; Wed, 22 Dec 2021 13:02:49 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 81552C36AE5; Wed, 22 Dec 2021 13:02:47 +0000 (UTC) Date: Wed, 22 Dec 2021 13:02:44 +0000 From: Catalin Marinas To: Pingfan Liu Cc: linux-arm-kernel@lists.infradead.org, Will Deacon , Mark Rutland , Vincenzo Frascino , Andrey Konovalov , Arnd Bergmann Subject: Re: [PATCH 2/2] arm64: uaccess: disable preempt during uaccess PSTATE.{PAN,TCO} Message-ID: References: <20211221134242.98877-1-kernelfans@gmail.com> <20211221134242.98877-2-kernelfans@gmail.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20211221134242.98877-2-kernelfans@gmail.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211222_050250_007112_B056F2A2 X-CRM114-Status: GOOD ( 21.69 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Tue, Dec 21, 2021 at 09:42:42PM +0800, Pingfan Liu wrote: > For the pair of > uaccess_enable_privileged()/uaccess_disable_privileged(), if preemption > happens, the exposure of the access to user space by another code piece > is unexpected. How can this happen? We set PAN on exception entry. > For the pair of > __uaccess_enable_tco_async()/__uaccess_disable_tco_async(), the change > of PSTATE.TCO is exposed unexpectedly. As above, we disable TCO on exception entry. > For the two cases, simply disable preemption to fix the issue. > > Signed-off-by: Pingfan Liu > Cc: Catalin Marinas > Cc: Will Deacon > Cc: Mark Rutland > Cc: Vincenzo Frascino > Cc: Andrey Konovalov > Cc: Arnd Bergmann > To: linux-arm-kernel@lists.infradead.org > --- > arch/arm64/include/asm/uaccess.h | 15 +++++++++++---- > 1 file changed, 11 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/uaccess.h b/arch/arm64/include/asm/uaccess.h > index 406888877bbd..37d5531f210d 100644 > --- a/arch/arm64/include/asm/uaccess.h > +++ b/arch/arm64/include/asm/uaccess.h > @@ -193,14 +193,18 @@ static inline void __uaccess_enable_tco(void) > */ > static inline void __uaccess_disable_tco_async(void) > { > - if (system_uses_mte_async_or_asymm_mode()) > - __uaccess_disable_tco(); > + if (system_uses_mte_async_or_asymm_mode()) { > + __uaccess_disable_tco(); > + preempt_enable(); > + } > } > > static inline void __uaccess_enable_tco_async(void) > { > - if (system_uses_mte_async_or_asymm_mode()) > + if (system_uses_mte_async_or_asymm_mode()) { > + preempt_disable(); > __uaccess_enable_tco(); > + } > } As with the previous patch, disabling preemption prior to a might_sleep() is wrong. -- Catalin _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel