[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <91d9f81c-b971-4764-8f21-4011023628c0@sirena.org.uk>
Date: Mon, 28 Oct 2024 21:05:33 +0000
From: Mark Brown <broonie@...nel.org>
To: Lorenzo Stoakes <lorenzo.stoakes@...cle.com>
Cc: Linus Torvalds <torvalds@...ux-foundation.org>,
"Liam R. Howlett" <Liam.Howlett@...cle.com>,
Andrew Morton <akpm@...ux-foundation.org>,
Vlastimil Babka <vbabka@...e.cz>, Jann Horn <jannh@...gle.com>,
linux-kernel@...r.kernel.org, linux-mm@...ck.org,
Peter Xu <peterx@...hat.com>, linux-arm-kernel@...ts.infradead.org,
Catalin Marinas <catalin.marinas@....com>,
Will Deacon <will@...nel.org>,
Aishwarya TCV <Aishwarya.TCV@....com>
Subject: Re: [PATCH hotfix 6.12 v2 4/8] mm: resolve faulty mmap_region()
error path behaviour
On Mon, Oct 28, 2024 at 08:43:08PM +0000, Lorenzo Stoakes wrote:
> +/*
> + * We check VMA flag validity early in the mmap() process, however this can
> + * cause issues for arm64 when using MTE, which requires that it be used with
> + * shmem and in this instance and only then is VM_MTE_ALLOWED set permitting
> + * this operation.
> + *
> + * To avoid having to tear down a partially complete mapping we do this ahead of
> + * time.
> + */
> +static vm_flags_t arch_adjust_flags(struct file *file, vm_flags_t vm_flags)
> +{
> + if (!IS_ENABLED(CONFIG_ARM64))
> + return vm_flags;
> +
> + if (shmem_file(file))
> + return vm_flags | VM_MTE_ALLOWED;
> +}
This doesn't build:
mm/mmap.c:1595:1: error: non-void function does not return a value in all control paths [-Werror,-Wreturn-type]
1595 | }
| ^
with that corrected:
diff --git a/mm/mmap.c b/mm/mmap.c
index d1ab4301c671..cea051c5fef3 100644
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -1587,11 +1587,10 @@ static unsigned long __mmap_region(struct file *file, unsigned long addr,
*/
static vm_flags_t arch_adjust_flags(struct file *file, vm_flags_t vm_flags)
{
- if (!IS_ENABLED(CONFIG_ARM64))
- return vm_flags;
+ if (IS_ENABLED(CONFIG_ARM64) && shmem_file(file))
+ vm_flags |= VM_MTE_ALLOWED;
- if (shmem_file(file))
- return vm_flags | VM_MTE_ALLOWED;
+ return vm_flags;
}
unsigned long mmap_region(struct file *file, unsigned long addr,
the relevant tests all pass for me.
Tested-by: Mark Brown <broonie@...nel.org>
I'd have expected arch_adjust_flags() to be something overridden by the
arch headers (probably like arch_calc_vm_prot_bits() and friends), but
if this is juat a short lived fix it's probably not worth the trouble.
Download attachment "signature.asc" of type "application/pgp-signature" (489 bytes)
Powered by blists - more mailing lists