]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/commitdiff
5.10-stable patches
authorGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 15:15:48 +0000 (16:15 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 21 Feb 2025 15:15:48 +0000 (16:15 +0100)
added patches:
arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch

queue-5.10/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch [new file with mode: 0644]
queue-5.10/series

diff --git a/queue-5.10/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch b/queue-5.10/arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch
new file mode 100644 (file)
index 0000000..41e14ab
--- /dev/null
@@ -0,0 +1,63 @@
+From stable+bounces-118464-greg=kroah.com@vger.kernel.org Thu Feb 20 16:59:39 2025
+From: Catalin Marinas <catalin.marinas@arm.com>
+Date: Thu, 20 Feb 2025 15:58:01 +0000
+Subject: arm64: mte: Do not allow PROT_MTE on MAP_HUGETLB user mappings
+To: <stable@vger.kernel.org>, Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+Cc: yang@os.amperecomputing.com, Naresh Kamboju <naresh.kamboju@linaro.org>
+Message-ID: <20250220155801.1731061-1-catalin.marinas@arm.com>
+
+From: Catalin Marinas <catalin.marinas@arm.com>
+
+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: <stable@vger.kernel.org> # 5.10.x-6.12.x
+Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org>
+Signed-off-by: Catalin Marinas <catalin.marinas@arm.com>
+Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
+---
+
+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;
+ }
index 39d1e3b59af28d97f76a1a8bd07088cdd7530a4d..2900a11f8964a08e66a4fda8eff2f4dbe7b3e796 100644 (file)
@@ -323,3 +323,4 @@ ima-fix-use-after-free-on-a-dentry-s-dname.name.patch
 vlan-introduce-vlan_dev_free_egress_priority.patch
 vlan-move-dev_put-into-vlan_dev_uninit.patch
 nvme-pci-fix-multiple-races-in-nvme_setup_io_queues.patch
+arm64-mte-do-not-allow-prot_mte-on-map_hugetlb-user-mappings.patch