From patchwork Thu Jan 13 21:08:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrew Morton X-Patchwork-Id: 531968 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36790C433F5 for ; Thu, 13 Jan 2022 21:08:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234861AbiAMVI0 (ORCPT ); Thu, 13 Jan 2022 16:08:26 -0500 Received: from ams.source.kernel.org ([145.40.68.75]:46356 "EHLO ams.source.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229543AbiAMVIZ (ORCPT ); Thu, 13 Jan 2022 16:08:25 -0500 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 ams.source.kernel.org (Postfix) with ESMTPS id 3808BB82380; Thu, 13 Jan 2022 21:08:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id B48DAC36AE3; Thu, 13 Jan 2022 21:08:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linux-foundation.org; s=korg; t=1642108103; bh=VFEtRmkBG783GINGo9/2Ud9BDYd4r8hnGCuCp07GMII=; h=Date:From:To:Subject:From; b=L8uDT9U03hOWlkKVNRR0KD2LqUt+loTw57UDqHw5H5KBtpfzfqVSFlzoyf5P4gkGB vLjSIXd+jijG8Btm04bmFZEjihSXeDVacrVSv35bs8Vt+AveZZ3RJBb8pIizBaqZ9c lbatvP9ZDdfzXpSLT8WHsY3dDpa5p5sdSX59HhbY= Date: Thu, 13 Jan 2022 13:08:22 -0800 From: akpm@linux-foundation.org To: agruenba@redhat.com, catalin.marinas@arm.com, dsterba@suse.com, josef@toxicpanda.com, mm-commits@vger.kernel.org, stable@vger.kernel.org, viro@zeniv.linux.org.uk, will@kernel.org, willy@infradead.org Subject: [to-be-updated] arm64-add-support-for-sub-page-faults-user-probing.patch removed from -mm tree Message-ID: <20220113210822.dPjzRdu-S%akpm@linux-foundation.org> User-Agent: s-nail v14.8.16 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org The patch titled Subject: arm64: add support for sub-page faults user probing has been removed from the -mm tree. Its filename was arm64-add-support-for-sub-page-faults-user-probing.patch This patch was dropped because an updated version will be merged ------------------------------------------------------ From: Catalin Marinas Subject: arm64: add support for sub-page faults user probing With MTE, even if the pte allows an access, a mismatched tag somewhere within a page can still cause a fault. Select ARCH_HAS_SUBPAGE_FAULTS if MTE is enabled and implement probe_user_writeable(). Link: https://lkml.kernel.org/r/20211124192024.2408218-3-catalin.marinas@arm.com Fixes: a48b73eca4ce ("btrfs: fix potential deadlock in the search ioctl") Signed-off-by: Catalin Marinas Cc: Al Viro Cc: Andreas Gruenbacher Cc: David Sterba Cc: Josef Bacik Cc: Matthew Wilcox Cc: Will Deacon Cc: Signed-off-by: Andrew Morton --- arch/arm64/Kconfig | 1 arch/arm64/include/asm/uaccess.h | 33 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) --- a/arch/arm64/include/asm/uaccess.h~arm64-add-support-for-sub-page-faults-user-probing +++ a/arch/arm64/include/asm/uaccess.h @@ -479,4 +479,37 @@ static inline int __copy_from_user_flush } #endif +#ifdef CONFIG_ARCH_HAS_SUBPAGE_FAULTS +static inline size_t __mte_probe_user_range(const char __user *uaddr, + size_t size) +{ + const char __user *end = uaddr + size; + int err = 0; + char val; + + uaddr = PTR_ALIGN_DOWN(uaddr, MTE_GRANULE_SIZE); + while (uaddr < end) { + /* + * A read is sufficient for MTE, the caller should have probed + * for the pte write permission. + */ + __raw_get_user(val, uaddr, err); + if (err) + return end - uaddr; + uaddr += MTE_GRANULE_SIZE; + } + (void)val; + + return 0; +} + +static inline size_t probe_user_writable(const void __user *uaddr, + size_t size) +{ + if (!system_supports_mte()) + return 0; + return __mte_probe_user_range(uaddr, size); +} +#endif /* CONFIG_ARCH_HAS_SUBPAGE_FAULTS */ + #endif /* __ASM_UACCESS_H */ --- a/arch/arm64/Kconfig~arm64-add-support-for-sub-page-faults-user-probing +++ a/arch/arm64/Kconfig @@ -1777,6 +1777,7 @@ config ARM64_MTE depends on AS_HAS_LSE_ATOMICS # Required for tag checking in the uaccess routines depends on ARM64_PAN + select ARCH_HAS_SUBPAGE_FAULTS select ARCH_USES_HIGH_VMA_FLAGS help Memory Tagging (part of the ARMv8.5 Extensions) provides