Commit 49ccf2c3 authored by Yang Shi's avatar Yang Shi Committed by Catalin Marinas
Browse files

arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place



The commit 5de19506 ("mm: resolve faulty mmap_region() error path
behaviour") moved vm flags validation before fop->mmap for file
mappings.  But when commit 25c17c4b ("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: 25c17c4b ("hugetlb: arm64: add mte support")
Signed-off-by: default avatarYang Shi <yang@os.amperecomputing.com>
Reviewed-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
Link: https://lore.kernel.org/r/20241119200914.1145249-1-yang@os.amperecomputing.com


Signed-off-by: default avatarCatalin Marinas <catalin.marinas@arm.com>
parent 40384c84
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -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;
	}

+1 −1
Original line number Diff line number Diff line
@@ -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);