* + mm-consistently-validate-vma-state-after-mmap-hooks-fix.patch added to mm-unstable branch
@ 2026-10-07 21:53 Andrew Morton
0 siblings, 0 replies; only message in thread
From: Andrew Morton @ 2026-10-07 21:53 UTC (permalink / raw)
To: mm-commits, vbabka, pfalcato, ljs, liam, jannh, okerixx, akpm
The patch titled
Subject: mm/vma: keep the unlinked VMA off the file across unmap on mmap hook failure
has been added to the -mm mm-unstable branch. Its filename is
mm-consistently-validate-vma-state-after-mmap-hooks-fix.patch
This patch will shortly appear at
https://git.kernel.org/pub/scm/linux/kernel/git/akpm/25-new.git/tree/patches/mm-consistently-validate-vma-state-after-mmap-hooks-fix.patch
This patch will later appear in the mm-unstable branch at
git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
Before you just go and hit "reply", please:
a) Consider who else should be cc'ed
b) Prefer to cc a suitable mailing list as well
c) Ideally: find the original patch on the mailing list and do a
reply-to-all to that, adding suitable additional cc's
*** Remember to use Documentation/process/submit-checklist.rst when testing your code ***
The -mm tree is included into linux-next via various
branches at git://git.kernel.org/pub/scm/linux/kernel/git/akpm/mm
and is updated there most days
------------------------------------------------------
From: Oleg Keri <okerixx@gmail.com>
Subject: mm/vma: keep the unlinked VMA off the file across unmap on mmap hook failure
Date: Wed, 7 Oct 2026 21:47:08 +0200
Since commit 2ceb21171dd9 ("mm: consistently validate VMA state after
mmap[_prepare] hooks"), the mmap error path clears vma->vm_file only
after unmap_region(), so free_pgtables() unlinks the never-linked VMA
and drops i_mmap_writable. Once it goes negative, every later shared
writable mmap of that file fails with -EPERM until reboot.
Clear vm_file across unmap_region() only, so that free_pgtables() does
not unlink a VMA that was never linked to the file, and restore it for
vma_close(): when the hook succeeded and the validation failed, the
driver's close() still runs and may use vma->vm_file.
Link: https://lore.kernel.org/20261007194708.2009-1-okerixx@gmail.com
Fixes: 2ceb21171dd9 ("mm: consistently validate VMA state after mmap[_prepare] hooks")
Signed-off-by: Oleg Keri <okerixx@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Cc: Lorenzo Stoakes <ljs@kernel.org>
Cc: Liam R. Howlett <liam@infradead.org>
Cc: Vlastimil Babka <vbabka@kernel.org>
Cc: Jann Horn <jannh@google.com>
Cc: Pedro Falcato <pfalcato@suse.de>
---
mm/vma.c | 3 +++
1 file changed, 3 insertions(+)
--- a/mm/vma.c~mm-consistently-validate-vma-state-after-mmap-hooks-fix
+++ a/mm/vma.c
@@ -2626,12 +2626,15 @@ static int __mmap_new_file_vma(struct mm
map->vm_file = vma->vm_file;
if (error) {
+ struct file *file = vma->vm_file;
UNMAP_STATE(unmap, vmi, vma, vma->vm_start, vma->vm_end,
map->prev, map->next);
+ vma->vm_file = NULL;
vma_iter_set(vmi, vma->vm_end);
/* Undo any partial mapping done by a device driver. */
unmap_region(&unmap);
+ vma->vm_file = file;
/* Only safe once unmapped. */
vma_close(vma);
_
Patches currently in -mm which might be from okerixx@gmail.com are
mm-consistently-validate-vma-state-after-mmap-hooks-fix.patch
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2026-10-07 21:53 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 21:53 + mm-consistently-validate-vma-state-after-mmap-hooks-fix.patch added to mm-unstable branch Andrew Morton
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.