From: Greg Kroah-Hartman Date: Fri, 21 Feb 2025 15:16:03 +0000 (+0100) Subject: 5.15-stable patches X-Git-Tag: v6.6.80~34 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9a701ce8fc8f4394eb91aaca8f8127f16517faad;p=thirdparty%2Fkernel%2Fstable-queue.git 5.15-stable patches added patches: arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch --- diff --git a/queue-5.15/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch b/queue-5.15/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch new file mode 100644 index 0000000000..41e14ab2be --- /dev/null +++ b/queue-5.15/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch @@ -0,0 +1,63 @@ +From stable+bounces-118464-greg=kroah.com@vger.kernel.org Thu Feb 20 16:59:39 2025 +From: Catalin Marinas +Date: Thu, 20 Feb 2025 15:58:01 +0000 +Subject: arm64: mte: Do not allow PROT_MTE on MAP_HUGETLB user mappings +To: , Greg Kroah-Hartman +Cc: yang@os.amperecomputing.com, Naresh Kamboju +Message-ID: <20250220155801.1731061-1-catalin.marinas@arm.com> + +From: Catalin Marinas + +PROT_MTE (memory tagging extensions) is not supported on all user mmap() +types for various reasons (memory attributes, backing storage, CoW +handling). The arm64 arch_validate_flags() function checks whether the +VM_MTE_ALLOWED flag has been set for a vma during mmap(), usually by +arch_calc_vm_flag_bits(). + +Linux prior to 6.13 does not support PROT_MTE hugetlb mappings. This was +added by commit 25c17c4b55de ("hugetlb: arm64: add mte support"). +However, earlier kernels inadvertently set VM_MTE_ALLOWED on +(MAP_ANONYMOUS | MAP_HUGETLB) mappings by only checking for +MAP_ANONYMOUS. + +Explicitly check MAP_HUGETLB in arch_calc_vm_flag_bits() and avoid +setting VM_MTE_ALLOWED for such mappings. + +Fixes: 9f3419315f3c ("arm64: mte: Add PROT_MTE support to mmap() and mprotect()") +Cc: # 5.10.x-6.12.x +Reported-by: Naresh Kamboju +Signed-off-by: Catalin Marinas +Signed-off-by: Greg Kroah-Hartman +--- + +Hi Greg, + +This patch applies cleanly on top of the stable-rc/linux-6.12.y to +5.10.y LTS, so I'm only sending it once. It's not for 6.13 onwards since +those kernels support hugetlbfs with MTE. + +Thanks, + +Catalin + + arch/arm64/include/asm/mman.h | 9 ++++++--- + 1 file changed, 6 insertions(+), 3 deletions(-) + +--- a/arch/arm64/include/asm/mman.h ++++ b/arch/arm64/include/asm/mman.h +@@ -31,9 +31,12 @@ static inline unsigned long arch_calc_vm + * backed by tags-capable memory. The vm_flags may be overridden by a + * filesystem supporting MTE (RAM-based). + */ +- if (system_supports_mte() && +- ((flags & MAP_ANONYMOUS) || shmem_file(file))) +- return VM_MTE_ALLOWED; ++ if (system_supports_mte()) { ++ if ((flags & MAP_ANONYMOUS) && !(flags & MAP_HUGETLB)) ++ return VM_MTE_ALLOWED; ++ if (shmem_file(file)) ++ return VM_MTE_ALLOWED; ++ } + + return 0; + } diff --git a/queue-5.15/series b/queue-5.15/series index c2f169228d..e851ed8705 100644 --- a/queue-5.15/series +++ b/queue-5.15/series @@ -431,3 +431,4 @@ x86-i8253-disable-pit-timer-0-when-not-in-use.patch revert-btrfs-avoid-monopolizing-a-core-when-activating-a-swap-file.patch btrfs-avoid-monopolizing-a-core-when-activating-a-swap-file.patch pps-fix-a-use-after-free.patch +arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch