]> Git Repo - linux.git/commitdiff
arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place
authorYang Shi <[email protected]>
Tue, 19 Nov 2024 20:09:14 +0000 (12:09 -0800)
committerCatalin Marinas <[email protected]>
Mon, 2 Dec 2024 11:48:14 +0000 (11:48 +0000)
The commit 5de195060b2e ("mm: resolve faulty mmap_region() error path
behaviour") moved vm flags validation before fop->mmap for file
mappings.  But when commit 25c17c4b55de ("hugetlb: arm64: add mte support")
was rebased on top of it, the hugetlbfs part was missed.  Mmapping
hugetlbfs file may not have MAP_HUGETLB set.

Fixes: 25c17c4b55de ("hugetlb: arm64: add mte support")
Signed-off-by: Yang Shi <[email protected]>
Reviewed-by: Catalin Marinas <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Catalin Marinas <[email protected]>
arch/arm64/include/asm/mman.h
fs/hugetlbfs/inode.c

index 1d53022fc7e1f96719bea342d0f3b6c08421158b..21df8bbd2668a2febd7abc6a7f98f2c5bbe1ebde 100644 (file)
@@ -7,6 +7,7 @@
 #ifndef BUILD_VDSO
 #include <linux/compiler.h>
 #include <linux/fs.h>
+#include <linux/hugetlb.h>
 #include <linux/shmem_fs.h>
 #include <linux/types.h>
 
@@ -44,7 +45,7 @@ static inline unsigned long arch_calc_vm_flag_bits(struct file *file,
        if (system_supports_mte()) {
                if (flags & (MAP_ANONYMOUS | MAP_HUGETLB))
                        return VM_MTE_ALLOWED;
-               if (shmem_file(file))
+               if (shmem_file(file) || is_file_hugepages(file))
                        return VM_MTE_ALLOWED;
        }
 
index a4441fb77f7c16f32b9df3e6268e4e7d97b7a162..90f883d6b8fd88b9f70def1c18aef530e3b8f1a4 100644 (file)
@@ -113,7 +113,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
         * way when do_mmap unwinds (may be important on powerpc
         * and ia64).
         */
-       vm_flags_set(vma, VM_HUGETLB | VM_DONTEXPAND | VM_MTE_ALLOWED);
+       vm_flags_set(vma, VM_HUGETLB | VM_DONTEXPAND);
        vma->vm_ops = &hugetlb_vm_ops;
 
        ret = seal_check_write(info->seals, vma);
This page took 0.06421 seconds and 4 git commands to generate.