]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mm/mremap: correctly account old mapping after MREMAP_DONTUNMAP remap
authorLorenzo Stoakes <lorenzo.stoakes@oracle.com>
Mon, 13 Oct 2025 16:58:36 +0000 (17:58 +0100)
committerAndrew Morton <akpm@linux-foundation.org>
Wed, 15 Oct 2025 04:28:07 +0000 (21:28 -0700)
commitf02bd2e94bf9a7ae3894a878c2b88b51e7444de6
treef93c8b5722e7d6d8662abb20323575a41e1bfbfb
parenta47a216343d6ffc39471238eb143fecc704065f5
mm/mremap: correctly account old mapping after MREMAP_DONTUNMAP remap

Commit b714ccb02a76 ("mm/mremap: complete refactor of move_vma()")
mistakenly introduced a new behaviour - clearing the VM_ACCOUNT flag of
the old mapping when a mapping is mremap()'d with the MREMAP_DONTUNMAP
flag set.

While we always clear the VM_LOCKED and VM_LOCKONFAULT flags for the old
mapping (the page tables have been moved, so there is no data that could
possibly be locked in memory), there is no reason to touch any other VMA
flags.

This is because after the move the old mapping is in a state as if it were
freshly mapped.  This implies that the attributes of the mapping ought to
remain the same, including whether or not the mapping is accounted.

Link: https://lkml.kernel.org/r/20251013165836.273113-1-lorenzo.stoakes@oracle.com
Signed-off-by: Lorenzo Stoakes <lorenzo.stoakes@oracle.com>
Fixes: b714ccb02a76 ("mm/mremap: complete refactor of move_vma()")
Reviewed-by: Pedro Falcato <pfalcato@suse.de>
Cc: Jann Horn <jannh@google.com>
Cc: Liam Howlett <liam.howlett@oracle.com>
Cc: Vlastimil Babka <vbabka@suse.cz>
Cc: <stable@vger.kernel.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
mm/mremap.c