Skip to content

Commit 49ccf2c

Browse files
Yang Shictmarinas
authored andcommitted
arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place
The commit 5de1950 ("mm: resolve faulty mmap_region() error path behaviour") moved vm flags validation before fop->mmap for file mappings. But when commit 25c17c4 ("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: 25c17c4 ("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]>
1 parent 40384c8 commit 49ccf2c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

arch/arm64/include/asm/mman.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#ifndef BUILD_VDSO
88
#include <linux/compiler.h>
99
#include <linux/fs.h>
10+
#include <linux/hugetlb.h>
1011
#include <linux/shmem_fs.h>
1112
#include <linux/types.h>
1213

@@ -44,7 +45,7 @@ static inline unsigned long arch_calc_vm_flag_bits(struct file *file,
4445
if (system_supports_mte()) {
4546
if (flags & (MAP_ANONYMOUS | MAP_HUGETLB))
4647
return VM_MTE_ALLOWED;
47-
if (shmem_file(file))
48+
if (shmem_file(file) || is_file_hugepages(file))
4849
return VM_MTE_ALLOWED;
4950
}
5051

fs/hugetlbfs/inode.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ static int hugetlbfs_file_mmap(struct file *file, struct vm_area_struct *vma)
113113
* way when do_mmap unwinds (may be important on powerpc
114114
* and ia64).
115115
*/
116-
vm_flags_set(vma, VM_HUGETLB | VM_DONTEXPAND | VM_MTE_ALLOWED);
116+
vm_flags_set(vma, VM_HUGETLB | VM_DONTEXPAND);
117117
vma->vm_ops = &hugetlb_vm_ops;
118118

119119
ret = seal_check_write(info->seals, vma);

0 commit comments

Comments
 (0)