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 BB599C433F5 for ; Thu, 23 Dec 2021 09:41:22 +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=RGo+AsmAYk4ieX1RqwXkUffr3WuCM3pPZwBIgp9I0j4=; b=r7N/aniZn+iAZM WQH+QNqV3nU1vsrut6VQ4f1TEU6coTt5OJuBOT8LZihw8o+0gWNkjHWhKOkec2dK9BQafjovut61t yrAqiCph/xYpVJ+YnuwZHihFWpWnNTFhH4n4a5UTEBzP4rI2va6Hc0NJx5PvTEP1q2vV/119RnGtE MzZSmQldiRejjmbgz6TCFgliEsFERSAHDkbjQqa+LXE2DCXta6Vh1Ys3zZPPGeZ5E9R48v/ElG7X7 zsOcPPRf7PMlq+fU58CSlYm4A9WVklEopFfEvkbRpK9eafifAgy5hmuUDOV0RePm5bI3UGnni5k4w RKzlVME55QHMdFMIBFgg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0KZs-00CP1v-EU; Thu, 23 Dec 2021 09:40:00 +0000 Received: from mail-pj1-x1031.google.com ([2607:f8b0:4864:20::1031]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1n0KZo-00CP1T-P8 for linux-arm-kernel@lists.infradead.org; Thu, 23 Dec 2021 09:39:58 +0000 Received: by mail-pj1-x1031.google.com with SMTP id gj24so4638375pjb.0 for ; Thu, 23 Dec 2021 01:39:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=tqqW0YXwYS+PrryinMSQLkMbpx+A+M160AMu9GnNYAA=; b=Z69+nlBB7KIdBiC7HlF0bDnflvt7jIe5nVScTHD9E4vX9Zhg0lMKmBWPTLlSlKkOBd BA27JcyVLFbSK2LUpKjqY53a7EsVssk1XcsmSaoAwyPbAJjtoS2YxvdoRTx5fzVk42Co GmmGqPusTOCnWLVJPRWzNYb76k9U4B3EY68QTIxt4QUrChOvR2ZBZxHz1+TRPU1igKFW ul7aWTbdpfL8SuYQ+4mG9lt9XzA90QxTnFAsELMKh1TFyrBO5ok7jHxV5ikbVdYgHmoP Maq7sGmkYCA0IXtlMXlRTTVQsE7/sD8Rr4BQwSu8tXzTrm6D2XX+awELwjH9TSYncQGc QKvg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=tqqW0YXwYS+PrryinMSQLkMbpx+A+M160AMu9GnNYAA=; b=ZkPv2wKHq+tz5mbzvIt2Rm7KqHtItr6c49xEoUzf7KAwWRxki6xjk+F3wICmwv2PUu 2av/NqlnuRuCg1n0BcJ0Pf7+SMtT4df5vRM1dIOVG19q9KNnhWl1e6ZCPwtzfmR4MHsV WueO0SAr6dOK5P4Kof5ThUHsZrItGmUxMx1OkiyyVoE0qw826hLor3jDMIJTk6rO9aYG OeZTioPQZtv8syeT2sp760uF7+qxPhkRJg1KJbcpRu1tAi1rCkHM4Pq/hXqX7XFDm7np 5KwfCK6F95Aqs8UVLwikp7J1WPnX3Qt1EvGib5xtG08E3Lu+W75S6nA52Pg0Ei+BNNxr zojQ== X-Gm-Message-State: AOAM531e6U648GoTy4KQXzfBaxafXjYGNSjZQt+u749KyTbof4iPqrqs MEKdM4swNZaxLxwivu+KTg== X-Google-Smtp-Source: ABdhPJy2INeGvWZ5morCcrotlSbu819ZRjvLJDwahokJqC6OfQa0Ee2BV8+sKUglQDg6Wq8SLf9vKw== X-Received: by 2002:a17:90a:1bc1:: with SMTP id r1mr1887739pjr.66.1640252395094; Thu, 23 Dec 2021 01:39:55 -0800 (PST) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id s34sm5956494pfg.198.2021.12.23.01.39.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 01:39:54 -0800 (PST) Date: Thu, 23 Dec 2021 17:39:49 +0800 From: Pingfan Liu To: Catalin Marinas 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: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211223_013956_863008_6CA6A300 X-CRM114-Status: GOOD ( 23.77 ) 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 Wed, Dec 22, 2021 at 01:02:44PM +0000, Catalin Marinas wrote: > 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. > Yes, I make the some mistake as [1/2] > > 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. > Yes. > > 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. > Right. I will make clear the kernel_{entry/_exit} part. Appreciate for your help again. Thanks, Pingfan _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel