]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
x86/vdso: Fix incorrect size in munmap() on map_vdso() failure
authorGuilherme Giacomo Simoes <trintaeoitogc@gmail.com>
Sun, 3 May 2026 19:16:09 +0000 (16:16 -0300)
committerThomas Gleixner <tglx@kernel.org>
Tue, 19 May 2026 14:36:34 +0000 (16:36 +0200)
In map_vdso(), if a failure occurs during the installation of the VVAR
mappings, the error path attempts to clean up previously allocated mappings
using do_munmap(). However, the cleanup for the VVAR mapping is incorrectly
using image->size (the size of the vDSO text) instead of the actual size
allocated for the VVAR area.

Replace the incorrect do_munmap() image->size parameter with the constant
VDSO_NR_PAGES * PAGE_SIZE. Ensure the unmap size exactly matches the size
used during the vdso_install_vvar_mapping() phase to provide a symmetrical
and complete teardown of the memory region.

Fixes: e93d2521b27f ("x86/vdso: Split virtual clock pages into dedicated mapping")
Signed-off-by: Guilherme Giacomo Simoes <trintaeoitogc@gmail.com>
Signed-off-by: Thomas Gleixner <tglx@kernel.org>
Reviewed-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Link: https://patch.msgid.link/20260503191609.551817-1-trintaeoitogc@gmail.com
arch/x86/entry/vdso/vma.c

index a6bfcc8243cd91cc5b0547d74dd42c97835a90b8..d903bce24f15d434953f18b21d034611aa42b1ed 100644 (file)
@@ -178,7 +178,7 @@ static int map_vdso(const struct vdso_image *image, unsigned long addr)
        if (IS_ERR(vma)) {
                ret = PTR_ERR(vma);
                do_munmap(mm, text_start, image->size, NULL);
-               do_munmap(mm, addr, image->size, NULL);
+               do_munmap(mm, addr, VDSO_NR_PAGES * PAGE_SIZE, NULL);
                goto up_fail;
        }