[PATCH v5 15/25] mm: Allow arm64 mmap(PROT_MTE) on RAM-based files

Catalin Marinas catalin.marinas at arm.com
Wed Jun 24 13:52:34 EDT 2020

Since arm64 memory (allocation) tags can only be stored in RAM, mapping
files with PROT_MTE is not allowed by default. RAM-based files like
those in a tmpfs mount or memfd_create() can support memory tagging, so
update the vm_flags accordingly in shmem_mmap().

Signed-off-by: Catalin Marinas <catalin.marinas at arm.com>
Cc: Andrew Morton <akpm at linux-foundation.org>
 mm/shmem.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/mm/shmem.c b/mm/shmem.c
index a0dbe62f8042..dacee627dae6 100644
--- a/mm/shmem.c
+++ b/mm/shmem.c
@@ -2206,6 +2206,9 @@ static int shmem_mmap(struct file *file, struct vm_area_struct *vma)
 			vma->vm_flags &= ~(VM_MAYWRITE);
+	/* arm64 - allow memory tagging on RAM-based files */
+	vma->vm_flags |= VM_MTE_ALLOWED;
 	vma->vm_ops = &shmem_vm_ops;

More information about the linux-arm-kernel mailing list