FKIE_CVE-2025-40303
Vulnerability from fkie_nvd - Published: 2025-12-08 01:16 - Updated: 2026-10-14 22:10
Severity
Summary
In the Linux kernel, the following vulnerability has been resolved:
btrfs: ensure no dirty metadata is written back for an fs with errors
[BUG]
During development of a minor feature (make sure all btrfs_bio::end_io()
is called in task context), I noticed a crash in generic/388, where
metadata writes triggered new works after btrfs_stop_all_workers().
It turns out that it can even happen without any code modification, just
using RAID5 for metadata and the same workload from generic/388 is going
to trigger the use-after-free.
[CAUSE]
If btrfs hits an error, the fs is marked as error, no new
transaction is allowed thus metadata is in a frozen state.
But there are some metadata modifications before that error, and they are
still in the btree inode page cache.
Since there will be no real transaction commit, all those dirty folios
are just kept as is in the page cache, and they can not be invalidated
by invalidate_inode_pages2() call inside close_ctree(), because they are
dirty.
And finally after btrfs_stop_all_workers(), we call iput() on btree
inode, which triggers writeback of those dirty metadata.
And if the fs is using RAID56 metadata, this will trigger RMW and queue
new works into rmw_workers, which is already stopped, causing warning
from queue_work() and use-after-free.
[FIX]
Add a special handling for write_one_eb(), that if the fs is already in
an error state, immediately mark the bbio as failure, instead of really
submitting them.
Then during close_ctree(), iput() will just discard all those dirty
tree blocks without really writing them back, thus no more new jobs for
already stopped-and-freed workqueues.
The extra discard in write_one_eb() also acts as an extra safenet.
E.g. the transaction abort is triggered by some extent/free space
tree corruptions, and since extent/free space tree is already corrupted
some tree blocks may be allocated where they shouldn't be (overwriting
existing tree blocks). In that case writing them back will further
corrupting the fs.
References
Impacted products
| Vendor | Product | Version |
|---|
{
"affected": [
{
"affectedData": [
{
"defaultStatus": "unaffected",
"product": "Linux",
"programFiles": [
"fs/btrfs/extent_io.c"
],
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"versions": [
{
"lessThan": "066ee13f05fbd82ada01883e51f0695172f98dff",
"status": "affected",
"version": "13e6c37b989859e70b0d73d3f2cb0aa022159b17",
"versionType": "git"
},
{
"lessThan": "e2b3859067bf012d53c49b3f885fef40624a2c83",
"status": "affected",
"version": "13e6c37b989859e70b0d73d3f2cb0aa022159b17",
"versionType": "git"
},
{
"lessThan": "54a5b5a15588e3b0b294df31474d08a2678d4291",
"status": "affected",
"version": "13e6c37b989859e70b0d73d3f2cb0aa022159b17",
"versionType": "git"
},
{
"lessThan": "2618849f31e7cf51fadd4a5242458501a6d5b315",
"status": "affected",
"version": "13e6c37b989859e70b0d73d3f2cb0aa022159b17",
"versionType": "git"
}
]
},
{
"defaultStatus": "affected",
"product": "Linux",
"programFiles": [
"fs/btrfs/extent_io.c"
],
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"vendor": "Linux",
"versions": [
{
"status": "affected",
"version": "3.10"
},
{
"lessThan": "3.10",
"status": "unaffected",
"version": "0",
"versionType": "semver"
},
{
"lessThanOrEqual": "6.6.*",
"status": "unaffected",
"version": "6.6.117",
"versionType": "semver"
},
{
"lessThanOrEqual": "6.12.*",
"status": "unaffected",
"version": "6.12.58",
"versionType": "semver"
},
{
"lessThanOrEqual": "6.17.*",
"status": "unaffected",
"version": "6.17.8",
"versionType": "semver"
},
{
"lessThanOrEqual": "*",
"status": "unaffected",
"version": "6.18",
"versionType": "original_commit_for_fix"
}
]
}
],
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67"
}
],
"cveTags": [],
"descriptions": [
{
"lang": "en",
"value": "In the Linux kernel, the following vulnerability has been resolved:\n\nbtrfs: ensure no dirty metadata is written back for an fs with errors\n\n[BUG]\nDuring development of a minor feature (make sure all btrfs_bio::end_io()\nis called in task context), I noticed a crash in generic/388, where\nmetadata writes triggered new works after btrfs_stop_all_workers().\n\nIt turns out that it can even happen without any code modification, just\nusing RAID5 for metadata and the same workload from generic/388 is going\nto trigger the use-after-free.\n\n[CAUSE]\nIf btrfs hits an error, the fs is marked as error, no new\ntransaction is allowed thus metadata is in a frozen state.\n\nBut there are some metadata modifications before that error, and they are\nstill in the btree inode page cache.\n\nSince there will be no real transaction commit, all those dirty folios\nare just kept as is in the page cache, and they can not be invalidated\nby invalidate_inode_pages2() call inside close_ctree(), because they are\ndirty.\n\nAnd finally after btrfs_stop_all_workers(), we call iput() on btree\ninode, which triggers writeback of those dirty metadata.\n\nAnd if the fs is using RAID56 metadata, this will trigger RMW and queue\nnew works into rmw_workers, which is already stopped, causing warning\nfrom queue_work() and use-after-free.\n\n[FIX]\nAdd a special handling for write_one_eb(), that if the fs is already in\nan error state, immediately mark the bbio as failure, instead of really\nsubmitting them.\n\nThen during close_ctree(), iput() will just discard all those dirty\ntree blocks without really writing them back, thus no more new jobs for\nalready stopped-and-freed workqueues.\n\nThe extra discard in write_one_eb() also acts as an extra safenet.\nE.g. the transaction abort is triggered by some extent/free space\ntree corruptions, and since extent/free space tree is already corrupted\nsome tree blocks may be allocated where they shouldn\u0027t be (overwriting\nexisting tree blocks). In that case writing them back will further\ncorrupting the fs."
},
{
"lang": "es",
"value": "En el kernel de Linux, la siguiente vulnerabilidad ha sido resuelta:\n\nbtrfs: asegurar que no se escriban metadatos sucios para un sistema de archivos con errores\n\n[ERROR]\nDurante el desarrollo de una caracter\u00edstica menor (asegurar que todas las llamadas a btrfs_bio::end_io() se realicen en contexto de tarea), not\u00e9 un fallo en generic/388, donde las escrituras de metadatos activaron nuevos trabajos despu\u00e9s de btrfs_stop_all_workers().\n\nResulta que puede ocurrir incluso sin ninguna modificaci\u00f3n de c\u00f3digo, solo usando RAID5 para metadatos y la misma carga de trabajo de generic/388 va a activar el uso despu\u00e9s de liberaci\u00f3n.\n\n[CAUSA]\nSi btrfs encuentra un error, el sistema de archivos se marca como error, no se permite ninguna nueva transacci\u00f3n, por lo tanto, los metadatos est\u00e1n en un estado congelado.\n\nPero hay algunas modificaciones de metadatos antes de ese error, y todav\u00eda est\u00e1n en la cach\u00e9 de p\u00e1ginas de inodos del btree.\n\nDado que no habr\u00e1 una confirmaci\u00f3n de transacci\u00f3n real, todos esos folios sucios se mantienen tal cual en la cach\u00e9 de p\u00e1ginas, y no pueden ser invalidados por la llamada a invalidate_inode_pages2() dentro de close_ctree(), porque est\u00e1n sucios.\n\nY finalmente despu\u00e9s de btrfs_stop_all_workers(), llamamos a iput() en el inodo del btree, lo que activa la escritura de esos metadatos sucios.\n\nY si el sistema de archivos est\u00e1 usando metadatos RAID56, esto activar\u00e1 RMW y encolar\u00e1 nuevos trabajos en rmw_workers, que ya est\u00e1 detenido, causando una advertencia de queue_work() y uso despu\u00e9s de liberaci\u00f3n.\n\n[SOLUCI\u00d3N]\nA\u00f1adir un manejo especial para write_one_eb(), que si el sistema de archivos ya est\u00e1 en un estado de error, marque inmediatamente el bbio como fallo, en lugar de realmente enviarlos.\n\nLuego, durante close_ctree(), iput() simplemente descartar\u00e1 todos esos bloques de \u00e1rbol sucios sin realmente escribirlos de vuelta, por lo tanto, no m\u00e1s trabajos nuevos para las colas de trabajo ya detenidas y liberadas.\n\nEl descarte adicional en write_one_eb() tambi\u00e9n act\u00faa como una red de seguridad adicional.\nPor ejemplo, la anulaci\u00f3n de la transacci\u00f3n es activada por algunas corrupciones del \u00e1rbol de extensiones/espacio libre, y dado que el \u00e1rbol de extensiones/espacio libre ya est\u00e1 corrupto, algunos bloques de \u00e1rbol pueden ser asignados donde no deber\u00edan (sobrescribiendo bloques de \u00e1rbol existentes). En ese caso, escribirlos de vuelta corromper\u00e1 a\u00fan m\u00e1s el sistema de archivos."
}
],
"id": "CVE-2025-40303",
"lastModified": "2026-10-14T22:10:00.210",
"metrics": {
"cvssMetricV31": [
{
"cvssData": {
"attackComplexity": "LOW",
"attackVector": "LOCAL",
"availabilityImpact": "HIGH",
"baseScore": 7.8,
"baseSeverity": "HIGH",
"confidentialityImpact": "HIGH",
"integrityImpact": "HIGH",
"privilegesRequired": "LOW",
"scope": "UNCHANGED",
"userInteraction": "NONE",
"vectorString": "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H",
"version": "3.1"
},
"exploitabilityScore": 1.8,
"impactScore": 5.9,
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"type": "Secondary"
}
]
},
"published": "2025-12-08T01:16:02.440",
"references": [
{
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"url": "https://git.kernel.org/stable/c/066ee13f05fbd82ada01883e51f0695172f98dff"
},
{
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"url": "https://git.kernel.org/stable/c/2618849f31e7cf51fadd4a5242458501a6d5b315"
},
{
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"url": "https://git.kernel.org/stable/c/54a5b5a15588e3b0b294df31474d08a2678d4291"
},
{
"source": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"url": "https://git.kernel.org/stable/c/e2b3859067bf012d53c49b3f885fef40624a2c83"
}
],
"sourceIdentifier": "416baaa9-dc9f-4396-8d5f-8c081fb06d67",
"vulnStatus": "Deferred"
}
Loading…
Loading…
Drag nodes to arrange them. Double-click a related vulnerability to open it, or a source to visit its link. The Physics button on the left tunes the layout and the simulation; the legend at the bottom left hides or shows nodes by kind and by sighting type.
Experimental. This forecast is provided for visualization only and may change without notice. Do not use it for operational decisions.
Forecast uses a logistic model when the trend is rising, or an exponential decay model when the trend is falling. Fitted via linearized least squares.
Sightings
| Author | Source | Type | Date | Other |
|---|
Nomenclature
- Seen: The vulnerability was mentioned, discussed, or observed by the user.
- Confirmed: The vulnerability has been validated from an analyst's perspective.
- Published Proof of Concept: A public proof of concept is available for this vulnerability.
- Exploited: The vulnerability was observed as exploited by the user who reported the sighting.
- Patched: The vulnerability was observed as successfully patched by the user who reported the sighting.
- Not exploited: The vulnerability was not observed as exploited by the user who reported the sighting.
- Not confirmed: The user expressed doubt about the validity of the vulnerability.
- Not patched: The vulnerability was not observed as successfully patched by the user who reported the sighting.
Vulnerability timeline
Sightings and recorded dates, grouped by day · UTC
Loading timeline…
Loading…
Loading…
The MITRE ATT&CK techniques below are AI-generated suggestions, inferred from the description of the
vulnerability by the CIRCL/vulnerability-attack-technique-classification-roberta-base
model, served locally by ML-Gateway.
They have not been verified by an analyst and are provided for guidance only.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
The approach is described in our paper Mapping CVEs to MITRE ATT&CK Techniques: A Curated Gold-Set Classifier and the Limits of LLM-Assisted Label Expansion.
Browse all ATT&CK techniques and the vulnerabilities related to each.
Loading…
Related by attack behaviour
Vulnerabilities whose description is nearest to this one in the vector space of the CIRCL/vulnerability-attack-technique-biencoder model. This is a similarity search over the bi-encoder space (plain cosine), not a classification, and it has no measured accuracy.