CVE-2025-37988 (GCVE-0-2025-37988)
Vulnerability from cvelistv5
Published
2025-05-20 17:09
Modified
2025-05-26 05:25
Severity ?
VLAI Severity ?
EPSS score ?
Summary
In the Linux kernel, the following vulnerability has been resolved:
fix a couple of races in MNT_TREE_BENEATH handling by do_move_mount()
Normally do_lock_mount(path, _) is locking a mountpoint pinned by
*path and at the time when matching unlock_mount() unlocks that
location it is still pinned by the same thing.
Unfortunately, for 'beneath' case it's no longer that simple -
the object being locked is not the one *path points to. It's the
mountpoint of path->mnt. The thing is, without sufficient locking
->mnt_parent may change under us and none of the locks are held
at that point. The rules are
* mount_lock stabilizes m->mnt_parent for any mount m.
* namespace_sem stabilizes m->mnt_parent, provided that
m is mounted.
* if either of the above holds and refcount of m is positive,
we are guaranteed the same for refcount of m->mnt_parent.
namespace_sem nests inside inode_lock(), so do_lock_mount() has
to take inode_lock() before grabbing namespace_sem. It does
recheck that path->mnt is still mounted in the same place after
getting namespace_sem, and it does take care to pin the dentry.
It is needed, since otherwise we might end up with racing mount --move
(or umount) happening while we were getting locks; in that case
dentry would no longer be a mountpoint and could've been evicted
on memory pressure along with its inode - not something you want
when grabbing lock on that inode.
However, pinning a dentry is not enough - the matching mount is
also pinned only by the fact that path->mnt is mounted on top it
and at that point we are not holding any locks whatsoever, so
the same kind of races could end up with all references to
that mount gone just as we are about to enter inode_lock().
If that happens, we are left with filesystem being shut down while
we are holding a dentry reference on it; results are not pretty.
What we need to do is grab both dentry and mount at the same time;
that makes inode_lock() safe *and* avoids the problem with fs getting
shut down under us. After taking namespace_sem we verify that
path->mnt is still mounted (which stabilizes its ->mnt_parent) and
check that it's still mounted at the same place. From that point
on to the matching namespace_unlock() we are guaranteed that
mount/dentry pair we'd grabbed are also pinned by being the mountpoint
of path->mnt, so we can quietly drop both the dentry reference (as
the current code does) and mnt one - it's OK to do under namespace_sem,
since we are not dropping the final refs.
That solves the problem on do_lock_mount() side; unlock_mount()
also has one, since dentry is guaranteed to stay pinned only until
the namespace_unlock(). That's easy to fix - just have inode_unlock()
done earlier, while it's still pinned by mp->m_dentry.
References
Impacted products
{ "containers": { "cna": { "affected": [ { "defaultStatus": "unaffected", "product": "Linux", "programFiles": [ "fs/namespace.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "lessThan": "4f435c1f4c48ff84968e2d9159f6fa41f46cf998", "status": "affected", "version": "6ac392815628f317fcfdca1a39df00b9cc4ebc8b", "versionType": "git" }, { "lessThan": "a61afd54826ac24c2c93845c4f441dbc344875b1", "status": "affected", "version": "6ac392815628f317fcfdca1a39df00b9cc4ebc8b", "versionType": "git" }, { "lessThan": "d4b21e8cd3d7efa2deb9cff534f0133e84f35086", "status": "affected", "version": "6ac392815628f317fcfdca1a39df00b9cc4ebc8b", "versionType": "git" }, { "lessThan": "0d039eac6e5950f9d1ecc9e410c2fd1feaeab3b6", "status": "affected", "version": "6ac392815628f317fcfdca1a39df00b9cc4ebc8b", "versionType": "git" } ] }, { "defaultStatus": "affected", "product": "Linux", "programFiles": [ "fs/namespace.c" ], "repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git", "vendor": "Linux", "versions": [ { "status": "affected", "version": "6.5" }, { "lessThan": "6.5", "status": "unaffected", "version": "0", "versionType": "semver" }, { "lessThanOrEqual": "6.6.*", "status": "unaffected", "version": "6.6.89", "versionType": "semver" }, { "lessThanOrEqual": "6.12.*", "status": "unaffected", "version": "6.12.26", "versionType": "semver" }, { "lessThanOrEqual": "6.14.*", "status": "unaffected", "version": "6.14.5", "versionType": "semver" }, { "lessThanOrEqual": "*", "status": "unaffected", "version": "6.15", "versionType": "original_commit_for_fix" } ] } ], "cpeApplicability": [ { "nodes": [ { "cpeMatch": [ { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.6.89", "versionStartIncluding": "6.5", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.12.26", "versionStartIncluding": "6.5", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.14.5", "versionStartIncluding": "6.5", "vulnerable": true }, { "criteria": "cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*", "versionEndExcluding": "6.15", "versionStartIncluding": "6.5", "vulnerable": true } ], "negate": false, "operator": "OR" } ] } ], "descriptions": [ { "lang": "en", "value": "In the Linux kernel, the following vulnerability has been resolved:\n\nfix a couple of races in MNT_TREE_BENEATH handling by do_move_mount()\n\nNormally do_lock_mount(path, _) is locking a mountpoint pinned by\n*path and at the time when matching unlock_mount() unlocks that\nlocation it is still pinned by the same thing.\n\nUnfortunately, for \u0027beneath\u0027 case it\u0027s no longer that simple -\nthe object being locked is not the one *path points to. It\u0027s the\nmountpoint of path-\u003emnt. The thing is, without sufficient locking\n-\u003emnt_parent may change under us and none of the locks are held\nat that point. The rules are\n\t* mount_lock stabilizes m-\u003emnt_parent for any mount m.\n\t* namespace_sem stabilizes m-\u003emnt_parent, provided that\nm is mounted.\n\t* if either of the above holds and refcount of m is positive,\nwe are guaranteed the same for refcount of m-\u003emnt_parent.\n\nnamespace_sem nests inside inode_lock(), so do_lock_mount() has\nto take inode_lock() before grabbing namespace_sem. It does\nrecheck that path-\u003emnt is still mounted in the same place after\ngetting namespace_sem, and it does take care to pin the dentry.\nIt is needed, since otherwise we might end up with racing mount --move\n(or umount) happening while we were getting locks; in that case\ndentry would no longer be a mountpoint and could\u0027ve been evicted\non memory pressure along with its inode - not something you want\nwhen grabbing lock on that inode.\n\nHowever, pinning a dentry is not enough - the matching mount is\nalso pinned only by the fact that path-\u003emnt is mounted on top it\nand at that point we are not holding any locks whatsoever, so\nthe same kind of races could end up with all references to\nthat mount gone just as we are about to enter inode_lock().\nIf that happens, we are left with filesystem being shut down while\nwe are holding a dentry reference on it; results are not pretty.\n\nWhat we need to do is grab both dentry and mount at the same time;\nthat makes inode_lock() safe *and* avoids the problem with fs getting\nshut down under us. After taking namespace_sem we verify that\npath-\u003emnt is still mounted (which stabilizes its -\u003emnt_parent) and\ncheck that it\u0027s still mounted at the same place. From that point\non to the matching namespace_unlock() we are guaranteed that\nmount/dentry pair we\u0027d grabbed are also pinned by being the mountpoint\nof path-\u003emnt, so we can quietly drop both the dentry reference (as\nthe current code does) and mnt one - it\u0027s OK to do under namespace_sem,\nsince we are not dropping the final refs.\n\nThat solves the problem on do_lock_mount() side; unlock_mount()\nalso has one, since dentry is guaranteed to stay pinned only until\nthe namespace_unlock(). That\u0027s easy to fix - just have inode_unlock()\ndone earlier, while it\u0027s still pinned by mp-\u003em_dentry." } ], "providerMetadata": { "dateUpdated": "2025-05-26T05:25:11.548Z", "orgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "shortName": "Linux" }, "references": [ { "url": "https://git.kernel.org/stable/c/4f435c1f4c48ff84968e2d9159f6fa41f46cf998" }, { "url": "https://git.kernel.org/stable/c/a61afd54826ac24c2c93845c4f441dbc344875b1" }, { "url": "https://git.kernel.org/stable/c/d4b21e8cd3d7efa2deb9cff534f0133e84f35086" }, { "url": "https://git.kernel.org/stable/c/0d039eac6e5950f9d1ecc9e410c2fd1feaeab3b6" } ], "title": "fix a couple of races in MNT_TREE_BENEATH handling by do_move_mount()", "x_generator": { "engine": "bippy-1.2.0" } } }, "cveMetadata": { "assignerOrgId": "416baaa9-dc9f-4396-8d5f-8c081fb06d67", "assignerShortName": "Linux", "cveId": "CVE-2025-37988", "datePublished": "2025-05-20T17:09:20.765Z", "dateReserved": "2025-04-16T04:51:23.976Z", "dateUpdated": "2025-05-26T05:25:11.548Z", "state": "PUBLISHED" }, "dataType": "CVE_RECORD", "dataVersion": "5.1", "vulnerability-lookup:meta": { "nvd": "{\"cve\":{\"id\":\"CVE-2025-37988\",\"sourceIdentifier\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\",\"published\":\"2025-05-20T18:15:45.673\",\"lastModified\":\"2025-05-21T20:24:58.133\",\"vulnStatus\":\"Awaiting Analysis\",\"cveTags\":[],\"descriptions\":[{\"lang\":\"en\",\"value\":\"In the Linux kernel, the following vulnerability has been resolved:\\n\\nfix a couple of races in MNT_TREE_BENEATH handling by do_move_mount()\\n\\nNormally do_lock_mount(path, _) is locking a mountpoint pinned by\\n*path and at the time when matching unlock_mount() unlocks that\\nlocation it is still pinned by the same thing.\\n\\nUnfortunately, for \u0027beneath\u0027 case it\u0027s no longer that simple -\\nthe object being locked is not the one *path points to. It\u0027s the\\nmountpoint of path-\u003emnt. The thing is, without sufficient locking\\n-\u003emnt_parent may change under us and none of the locks are held\\nat that point. The rules are\\n\\t* mount_lock stabilizes m-\u003emnt_parent for any mount m.\\n\\t* namespace_sem stabilizes m-\u003emnt_parent, provided that\\nm is mounted.\\n\\t* if either of the above holds and refcount of m is positive,\\nwe are guaranteed the same for refcount of m-\u003emnt_parent.\\n\\nnamespace_sem nests inside inode_lock(), so do_lock_mount() has\\nto take inode_lock() before grabbing namespace_sem. It does\\nrecheck that path-\u003emnt is still mounted in the same place after\\ngetting namespace_sem, and it does take care to pin the dentry.\\nIt is needed, since otherwise we might end up with racing mount --move\\n(or umount) happening while we were getting locks; in that case\\ndentry would no longer be a mountpoint and could\u0027ve been evicted\\non memory pressure along with its inode - not something you want\\nwhen grabbing lock on that inode.\\n\\nHowever, pinning a dentry is not enough - the matching mount is\\nalso pinned only by the fact that path-\u003emnt is mounted on top it\\nand at that point we are not holding any locks whatsoever, so\\nthe same kind of races could end up with all references to\\nthat mount gone just as we are about to enter inode_lock().\\nIf that happens, we are left with filesystem being shut down while\\nwe are holding a dentry reference on it; results are not pretty.\\n\\nWhat we need to do is grab both dentry and mount at the same time;\\nthat makes inode_lock() safe *and* avoids the problem with fs getting\\nshut down under us. After taking namespace_sem we verify that\\npath-\u003emnt is still mounted (which stabilizes its -\u003emnt_parent) and\\ncheck that it\u0027s still mounted at the same place. From that point\\non to the matching namespace_unlock() we are guaranteed that\\nmount/dentry pair we\u0027d grabbed are also pinned by being the mountpoint\\nof path-\u003emnt, so we can quietly drop both the dentry reference (as\\nthe current code does) and mnt one - it\u0027s OK to do under namespace_sem,\\nsince we are not dropping the final refs.\\n\\nThat solves the problem on do_lock_mount() side; unlock_mount()\\nalso has one, since dentry is guaranteed to stay pinned only until\\nthe namespace_unlock(). That\u0027s easy to fix - just have inode_unlock()\\ndone earlier, while it\u0027s still pinned by mp-\u003em_dentry.\"},{\"lang\":\"es\",\"value\":\"En el kernel de Linux, se ha resuelto la siguiente vulnerabilidad: corrige un par de ejecuci\u00f3ns en el manejo de MNT_TREE_BENEATH por do_move_mount() Normalmente do_lock_mount(path, _) est\u00e1 bloqueando un punto de montaje fijado por *path y en el momento en que la coincidencia de unlock_mount() desbloquea esa ubicaci\u00f3n, todav\u00eda est\u00e1 fijado por la misma cosa. Desafortunadamente, para el caso \u0027debajo\u0027 ya no es tan simple: el objeto que se bloquea no es el que *path apunta. Es el punto de montaje de path-\u0026gt;mnt. El problema es que, sin un bloqueo suficiente, -\u0026gt;mnt_parent puede cambiar debajo de nosotros y ninguno de los bloqueos se mantiene en ese punto. Las reglas son * mount_lock estabiliza m-\u0026gt;mnt_parent para cualquier montaje m. * namespace_sem estabiliza m-\u0026gt;mnt_parent, siempre que m est\u00e9 montado. * si se cumple alguna de las anteriores y refcount de m es positivo, se nos garantiza lo mismo para refcount de m-\u0026gt;mnt_parent. namespace_sem se anida dentro de inode_lock(), por lo que do_lock_mount() debe tomar inode_lock() antes de obtener namespace_sem. Vuelve a comprobar que path-\u0026gt;mnt siga montado en el mismo lugar despu\u00e9s de obtener namespace_sem y se encarga de fijar el dentry. Esto es necesario, ya que, de lo contrario, podr\u00edamos terminar con una ejecuci\u00f3n de mount --move (o umount) mientras obten\u00edamos bloqueos; en ese caso, el dentry dejar\u00eda de ser un punto de montaje y podr\u00eda haber sido expulsado por presi\u00f3n de memoria junto con su inodo, algo que no se desea al obtener el bloqueo de ese inodo. Sin embargo, fijar un dentry no es suficiente; el montaje correspondiente tambi\u00e9n est\u00e1 fijado solo por el hecho de que path-\u0026gt;mnt est\u00e1 montado sobre \u00e9l y, en ese momento, no tenemos ning\u00fan bloqueo. Por lo tanto, el mismo tipo de ejecuci\u00f3n podr\u00eda terminar con todas las referencias a ese montaje eliminadas justo cuando estamos a punto de entrar en inode_lock(). Si esto ocurre, el sistema de archivos se apaga mientras mantenemos una referencia dentry; los resultados no son muy alentadores. Necesitamos obtener dentry y mount simult\u00e1neamente; esto hace que inode_lock() sea seguro *y* evita el problema de que el sistema de archivos se apague bajo nuestra supervisi\u00f3n. Despu\u00e9s de obtener namespace_sem, verificamos que path-\u0026gt;mnt siga montado (lo que estabiliza su -\u0026gt;mnt_parent) y comprobamos que siga montado en el mismo lugar. Desde ese punto hasta la ejecuci\u00f3n correspondiente de namespace_unlock(), tenemos la garant\u00eda de que el par mount/dentry que obtuvimos tambi\u00e9n est\u00e1 fijado al ser el punto de montaje de path-\u0026gt;mnt, por lo que podemos eliminar discretamente tanto la referencia dentry (como hace el c\u00f3digo actual) como la de mnt; esto es correcto en namespace_sem, ya que no eliminamos las referencias finales. Esto resuelve el problema en do_lock_mount(); unlock_mount() tambi\u00e9n tiene uno, ya que se garantiza que dentry permanecer\u00e1 fijado solo hasta la ejecuci\u00f3n de namespace_unlock(). Esto es f\u00e1cil de solucionar: solo hay que hacer inode_unlock() antes, mientras todav\u00eda est\u00e1 fijado por mp-\u0026gt;m_dentry.\"}],\"metrics\":{},\"references\":[{\"url\":\"https://git.kernel.org/stable/c/0d039eac6e5950f9d1ecc9e410c2fd1feaeab3b6\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/4f435c1f4c48ff84968e2d9159f6fa41f46cf998\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/a61afd54826ac24c2c93845c4f441dbc344875b1\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"},{\"url\":\"https://git.kernel.org/stable/c/d4b21e8cd3d7efa2deb9cff534f0133e84f35086\",\"source\":\"416baaa9-dc9f-4396-8d5f-8c081fb06d67\"}]}}" } }
Loading…
Loading…
Sightings
Author | Source | Type | Date |
---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or seen somewhere by the user.
- Confirmed: The vulnerability is confirmed from an analyst perspective.
- Exploited: This vulnerability was exploited and seen by the user reporting the sighting.
- Patched: This vulnerability was successfully patched by the user reporting the sighting.
- Not exploited: This vulnerability was not exploited or seen by the user reporting the sighting.
- Not confirmed: The user expresses doubt about the veracity of the vulnerability.
- Not patched: This vulnerability was not successfully patched by the user reporting the sighting.
Loading…
Loading…