arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place
PATCH 1/1 arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place
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.
--- arch/arm64/include/asm/mman.h | 3 ++- fs/hugetlbfs/inode.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)
arch/arm64/include/asm/mman.h +2 -1
@@ -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 ; }
fs/hugetlbfs/inode.c +1 -1
@@ -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);
Signature · 1 line
2.41.0
Quoted 8 lines · Yang Shi
The commit
5de195060b2e("mm: resolve faultymmap_region()error path behaviour") moved vm flags validation beforefop->mmapfor file mappings. But when commit25c17c4b55de("hugetlb: arm64: add mte support") was rebased on top of it, the hugetlbfs part was missed. Mmapping hugetlbfs file may not haveMAP_HUGETLBset.Fixes 25c17c4b55de ("hugetlb: arm64: add mte support")Signed-off-by Yang Shi <[email protected]>
Since 5de195060b2e went into -rc7 and my arm64 tree was based on -rc1, I did not test this combination. The patch looks fine, so:
So I either merge it via the arm64 tree at -rc1 or Linus picks it up and applies it directly during the merging window. Both options are fine, it's not essential that MTE + hugetlbfs works at -rc1. Adding Linus and Andrew in case they have any preference (and leaving the patch in place below).
Thanks,
Catalin
Quoted 40 lines
--- arch/arm64/include/asm/mman.h | 3 ++- fs/hugetlbfs/inode.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)arch/arm64/include/asm/mman.h +2
-1@@ -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 ; }fs/hugetlbfs/inode.c +1
-1@@ -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);
Quoted 12 lines · Catalin Marinas
Quoted 8 lines · Yang Shi
The commit
5de195060b2e("mm: resolve faultymmap_region()error path behaviour") moved vm flags validation beforefop->mmapfor file mappings. But when commit25c17c4b55de("hugetlb: arm64: add mte support") was rebased on top of it, the hugetlbfs part was missed. Mmapping hugetlbfs file may not haveMAP_HUGETLBset.Fixes 25c17c4b55de ("hugetlb: arm64: add mte support")Signed-off-by Yang Shi <[email protected]>Since
5de195060b2ewent into -rc7 and my arm64 tree was based on -rc1, I did not test this combination. The patch looks fine, so:
Quoted 7 lines
Reviewed-by Catalin Marinas <[email protected]>So I either merge it via the arm64 tree at -rc1 or Linus picks it up and applies it directly during the merging window. Both options are fine, it's not essential that MTE + hugetlbfs works at -rc1. Adding Linus and Andrew in case they have any preference (and leaving the patch in place below).
Thanks, Catalin. Either way is fine to me too.
Quoted 45 lines
Thanks,
Catalin
Quoted 40 lines
--- arch/arm64/include/asm/mman.h | 3 ++- fs/hugetlbfs/inode.c | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-)arch/arm64/include/asm/mman.h +2
-1@@ -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 ; }fs/hugetlbfs/inode.c +1
-1@@ -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);
Quoted 8 lines · Yang Shi
The commit
5de195060b2e("mm: resolve faultymmap_region()error path behaviour") moved vm flags validation beforefop->mmapfor file mappings. But when commit25c17c4b55de("hugetlb: arm64: add mte support") was rebased on top of it, the hugetlbfs part was missed. Mmapping hugetlbfs file may not haveMAP_HUGETLBset.[...]
Applied to arm64 (for-next/fixes), thanks!
[1/1] arm64: mte: set VM_MTE_ALLOWED for hugetlbfs at correct place
https://git.kernel.org/arm64/c/49ccf2c3cafb
Signature · 1 line
Catalin