Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7CCDF4D0A05 for ; Sun, 18 Oct 2026 15:24:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792337060; cv=none; b=JMvjsiHG3J/zUYuOTIOQfFCQrPdjvXgu+Rb0bsTU+79pBORCqIwGU3JtDsgzcYsKiTr8IMeToQ1goQn1kvzXcdXjbtAhm7fTBs5GyyiZ37baQ8sO/y8m4jq8FnE5zoNw8KcmEibd3QRJbrpxRNHLFePJDR0kXN3hJ24QCtIYBpQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1792337060; c=relaxed/simple; bh=JN+N1lT2WajIRvu6dPlvI/pigRM2kuNxfNS2cfEeoyc=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=XaSfT5hPFDqPWEDQ/GU66emyOAbWoJbMoTx0bKFit+v1/ppoSvg9T7hNrsQGZF7DsM9JZ77CdnE+dGVoMUDHczSQjxNXbbCVl5aZKZOmAZ5JRxQ5ckLjob93y/Cyhd+dR9k+HpCFAF/96UCuBaWYj97GvXYDJW0czVn5jEQzplU= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b=UPm9up5k; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linuxfoundation.org header.i=@linuxfoundation.org header.b="UPm9up5k" Received: by smtp.kernel.org (Postfix) with ESMTPSA id A70791F000C4; Sun, 18 Oct 2026 15:24:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linuxfoundation.org; s=korg; t=1792337058; bh=ALeMZ8HpJjNYPABj9sscyleE8NcbtmRy5JVCuIR0LxA=; h=From:To:Cc:Subject:Date:Reply-To; b=UPm9up5kmBEyR4Fgj60eoTF+BdfTIwHaiSJTjiTHFhVqxrbt0QEFlP0vImGN1JQ38 Z6vSgZECbjIgADMT7dghgGVmRFkVwD0iPz9jYZ9xY25WK9vyV/Cto1O0uy+WVgNfAk JGwuvAz8TRJ7DZWNkyUq5dtEttMNynFS3RxflS8s= From: Greg Kroah-Hartman To: linux-cve-announce@vger.kernel.org Cc: Greg Kroah-Hartman Subject: CVE-2026-98507: mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish Date: Sun, 18 Oct 2026 17:16:11 +0200 Message-ID: <2026101819-CVE-2026-98507-07bc@gregkh> X-Mailer: git-send-email 2.56.0 Reply-To: , Precedence: bulk X-Mailing-List: linux-cve-announce@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-Developer-Signature: v=1; a=openpgp-sha256; l=7486; i=gregkh@linuxfoundation.org; h=from:subject:message-id; bh=gav/SDEIm1vepHRpFjkhkqqjYoxItXqrAo4MVJWsnXE=; b=owGbwMvMwCRo6H6F97bub03G02pJDFlXHrXfviekOkl0g33NuUmt/BrzGlo1Njz58DKKx+LxA i0hLsv+jlgWBkEmBlkxRZYv23iO7q84pOhlaHsaZg4rE8gQBi5OAZhI5S2GeTrnrpnsrWb4sTz5 cmq5wKb/K4o4zzHMMzcquHs8zfqo5y+zG/XTbx7S3XDoIAA= X-Developer-Key: i=gregkh@linuxfoundation.org; a=openpgp; fpr=F4B60CC5BF78C2214A313DCB3147D40DDB2DFB29 Content-Transfer-Encoding: 8bit From: Greg Kroah-Hartman Description =========== In the Linux kernel, the following vulnerability has been resolved: mm/rmap: fix missing barrier between anon_vma init and vma->anon_vma publish On arm64 server, we find that a task trying to grab the anon_vma lock triggers hungtask. INFO: task main:2354726 blocked for more than 120 seconds. Tainted: G E 5.10.0-0021.aarch64 #1 "echo 0 > /proc/sys/kernel/hung_task_timeout_secs" disables this message. task:main state:D stack: 0 pid:2354726 ppid:2350673 flags:0x00000a01 Call trace: __switch_to+0x7c/0xbc __schedule+0x3b4/0x8a0 schedule+0x50/0xe0 rwsem_down_write_slowpath+0x3cc/0x6cc down_write+0x60/0x260 __anon_vma_prepare+0x6c/0x210 do_anonymous_page+0x258/0x660 handle_pte_fault+0x188/0x214 __handle_mm_fault+0x1b0/0x380 handle_mm_fault+0xf4/0x284 do_page_fault+0x19c/0x494 do_translation_fault+0xcc/0xf8 do_mem_abort+0x48/0xac el0_da+0x44/0x80 el0_sync_handler+0x88/0xb4 el0_sync+0x160/0x180 After analyzing the vmcore, we found the anon_vma->root->rwsem.count is -1. There is another anon_vma whose anon_vma->root->rwsem.count is 1, the anon_vma->root->rwsem.owner shows the lock is held, but the stack of the task shows the task doesn't hold the anon_vma lock. After adding more debugging info, we found __anon_vma_prepare() reuses anon_vma and triggers the UAF of anon_vma->root due to missing memory barrier, leading to locking and unlocking two different anon_vma->root, thus leading to an anon_vma will never be unlocked, and another anon_vma couldn't be locked anymore. This race requires two adjacent VMAs that are not merged but are anon_vma-compatible (e.g., they differ in VMA_ACCESS_FLAGS that can be changed by mprotect()). Two threads fault on each VMA concurrently, both calling __anon_vma_prepare() with only mmap_lock held for reading. THREAD A THREAD B __anon_vma_prepare __anon_vma_prepare find_mergeable_anon_vma() -> NULL anon_vma = anon_vma_alloc(); anon_vma->root = anon_vma; // the two stores may be reordered vma->anon_vma = anon_vma; // finds A's anon_vma anon_vma = find_mergeable_anon_vma(vma); anon_vma_lock_write(anon_vma); // may still see the old root down_write(&anon_vma->root->rwsem); anon_vma_unlock_write(anon_vma); // see the new root, never unlock old up_write(&anon_vma->root->rwsem); thread A triggers page fault and calls __anon_vma_prepare() to prepare anon_vma for the faulting vma. __anon_vma_prepare() allocates and initializes a new anon_vma, and then publishes it to the vma with a plain store. anon_vma_prepare() only requires the mmap_lock to be held for reading, so two threads can fault on adjacent VMAs at the same time. While thread A publishes a new anon_vma, thread B could find the anon_vma via find_mergeable_anon_vma() and then locks anon_vma->root->rwsem. The store to anon_vma->root in anon_vma_alloc() and the store to vma->anon_vma can be reordered. The anon_vma_lock_write() and spin_lock() only provide acquire semantics, which do not prevent prior stores from being reordered after them. The release semantics of the corresponding spin_unlock() and anon_vma_unlock_write() come too late, the store to vma->anon_vma is already published before they take effect. As a result, thread B can observe the following order: vma->anon_vma = anon_vma; anon_vma->root = anon_vma; The anon_vma slab is SLAB_TYPESAFE_BY_RCU, so a newly allocated anon_vma may reuse memory from a previously freed one. The constructor (anon_vma_ctor) does not reset anon_vma->root, and __put_anon_vma() doesn't clear it either, so the old root value persists until anon_vma_alloc() overwrites it. If that store isn't visible, thread B reads a root that points to the old anon_vma and locks it. As a result, thread B can call anon_vma_lock_write() with the old root, and call anon_vma_unlock_write() with the new root, leading to an anon_vma will never be unlocked, and another anon_vma couldn't be locked anymore (its count is dropped from 0 to -1 due to wrong unlock). To fix it, change the plain store `vma->anon_vma = anon_vma` to store release, so that the fields of anon_vma are visible before anon_vma is published to vma->anon_vma. At read side, the load of anon_vma and anon_vma->root have address dependency. According to Documentation/memory-barriers.txt and some investigations, only Alpha needs address-dependency barriers and it has been handled by READ_ONCE() in reusable_anon_vma(). We reproduced this issue in v5.10 with KSM enabled. The kernel doesn't merge commit cf7e7a3503df ("mm: prevent KSM from breaking VMA merging for new VMAs"), so there are many adjacent VMAs that aren't merged but are compatible for anon_vma. Without this fix, our production environment could reproduce this issue about 2-5 times each month. After adding a smp_mb() before anon_vma_lock_write(anon_vma) in __anon_vma_prepare(), which is different to this patch, this issue hasn't been reproduced for one month. The Linux kernel CVE team has assigned CVE-2026-98507 to this issue. Affected and fixed versions =========================== Issue introduced in 2.6.36 with commit 5c341ee1dfc8fe69d66b1c8b19e463c6d7201ae1 and fixed in 6.12.112 with commit a500df43cde075f6ea4b8bae495d89f2c35b3e16 Issue introduced in 2.6.36 with commit 5c341ee1dfc8fe69d66b1c8b19e463c6d7201ae1 and fixed in 6.18.55 with commit 4cef512a955e4008ae4436a4fc97726976df1fdf Issue introduced in 2.6.36 with commit 5c341ee1dfc8fe69d66b1c8b19e463c6d7201ae1 and fixed in 7.2.9 with commit d348a715380bfcc6a611bdf722169d53fd01e735 Issue introduced in 2.6.36 with commit 5c341ee1dfc8fe69d66b1c8b19e463c6d7201ae1 and fixed in 7.3-rc5 with commit b6ac0b3f6013c168f22cad97e79967accacb08e1 Please see https://www.kernel.org for a full list of currently supported kernel versions by the kernel community. Unaffected versions might change over time as fixes are backported to older supported kernel versions. The official CVE entry at https://cve.org/CVERecord/?id=CVE-2026-98507 will be updated if fixes are backported, please check that for the most up to date information about this issue. Affected files ============== The file(s) affected by this issue are: mm/rmap.c mm/vma.c Mitigation ========== The Linux kernel CVE team recommends that you update to the latest stable kernel version for this, and many other bugfixes. Individual changes are never tested alone, but rather are part of a larger kernel release. Cherry-picking individual commits is not recommended or supported by the Linux kernel community at all. If however, updating to the latest release is impossible, the individual changes to resolve this issue can be found at these commits: https://git.kernel.org/stable/c/a500df43cde075f6ea4b8bae495d89f2c35b3e16 https://git.kernel.org/stable/c/4cef512a955e4008ae4436a4fc97726976df1fdf https://git.kernel.org/stable/c/d348a715380bfcc6a611bdf722169d53fd01e735 https://git.kernel.org/stable/c/b6ac0b3f6013c168f22cad97e79967accacb08e1