btrfs: fix a race between renames and directory logging
In the Linux kernel, the following vulnerability has been resolved: btrfs: fix a race between renames and directory logging We have a race between a rename and directory inode logging that if it happens and we crash/power fail before the rename completes, the next time the filesystem is mounted, the log replay code will end up deleting the file that was being renamed. This is best explained following a step by step analysis of an interleaving of steps that lead into this situation. Consider the initial conditions: 1) We are at transaction N; 2) We have directories A and B created in a past transaction (< N); 3) We have inode X corresponding to a file that has 2 hardlinks, one in directory A and the other in directory B, so we'll name them as "A/foo_link1" and "B/foo_link2". Both hard links were persisted in a past transaction (< N); 4) We have inode Y corresponding to a file that as a single hard link and is located in directory A, we'll name it as "A/bar". This file was also persisted in a past transaction (< N). The steps leading to a file loss are the following and for all of them we are under transaction N: 1) Link "A/foo_link1" is removed, so inode's X last_unlink_trans field is updated to N, through btrfs_unlink() -> btrfs_record_unlink_dir(); 2) Task A starts a rename for inode Y, with the goal of renaming from "A/bar" to "A/baz", so we enter btrfs_rename(); 3) Task A inserts the new BTRFS_INODE_REF_KEY for inode Y by calling btrfs_insert_inode_ref(); 4) Because the re
- Products
- Kernel
- Affected versions
- Not specified
- Fixed versions
- 6.1.143, 6.12.36, 6.15.5, 6.6.96
- CVEs
- CVE-2025-38365
- Confirmed fixed CVEs
- Not specified
- Updated in this feed
- 4 Nov 2026, 02:58 UTC · Revision 1
Source evidence
btrfs: fix a race between renames and directory logging
core-osv · Original sourcePublished 25 Jul 2025, 12:47 UTC
In the Linux kernel, the following vulnerability has been resolved: btrfs: fix a race between renames and directory logging We have a race between a rename and directory inode logging that if it happens and we crash/power fail before the rename completes, the next time the filesystem is mounted, the log replay code will end up deleting the file that was being renamed. This is best explained following a step by step analysis of an interleaving of steps that lead into this situation. Consider the initial conditions: 1) We are at transaction N; 2) We have directories A and B created in a past transaction (< N); 3) We have inode X corresponding to a file that has 2 hardlinks, one in directory A and the other in directory B, so we'll name them as "A/foo_link1" and "B/foo_link2". Both hard links were persisted in a past transaction (< N); 4) We have inode Y corresponding to a file that as a single hard link and is located in directory A, we'll name it as "A/bar". This file was also persisted in a past transaction (< N). The steps leading to a file loss are the following and for all of them we are under transaction N: 1) Link "A/foo_link1" is removed, so inode's X last_unlink_trans field is updated to N, through btrfs_unlink() -> btrfs_record_unlink_dir(); 2) Task A starts a rename for inode Y, with the goal of renaming from "A/bar" to "A/baz", so we enter btrfs_rename(); 3) Task A inserts the new BTRFS_INODE_REF_KEY for inode Y by calling btrfs_insert_inode_ref(); 4) Because the re
osv:CVE-2025-38365
Kernel
Fixed versions: 6.1.143, 6.6.96, 6.12.36, 6.15.5
Complete source record
{
"id": "3392b1ef70f3b4e5e954a3e49bc25f3319a1b1ad6e5edf6ad30294bf7f1ff12b",
"url": "https://osv.dev/vulnerability/CVE-2025-38365",
"method": "structured",
"payload": {
"kind": "advisory",
"title": "btrfs: fix a race between renames and directory logging",
"summary": "In the Linux kernel, the following vulnerability has been resolved: btrfs: fix a race between renames and directory logging We have a race between a rename and directory inode logging that if it happens and we crash/power fail before the rename completes, the next time the filesystem is mounted, the log replay code will end up deleting the file that was being renamed. This is best explained following a step by step analysis of an interleaving of steps that lead into this situation. Consider the initial conditions: 1) We are at transaction N; 2) We have directories A and B created in a past transaction (< N); 3) We have inode X corresponding to a file that has 2 hardlinks, one in directory A and the other in directory B, so we'll name them as \"A/foo_link1\" and \"B/foo_link2\". Both hard links were persisted in a past transaction (< N); 4) We have inode Y corresponding to a file that as a single hard link and is located in directory A, we'll name it as \"A/bar\". This file was also persisted in a past transaction (< N). The steps leading to a file loss are the following and for all of them we are under transaction N: 1) Link \"A/foo_link1\" is removed, so inode's X last_unlink_trans field is updated to N, through btrfs_unlink() -> btrfs_record_unlink_dir(); 2) Task A starts a rename for inode Y, with the goal of renaming from \"A/bar\" to \"A/baz\", so we enter btrfs_rename(); 3) Task A inserts the new BTRFS_INODE_REF_KEY for inode Y by calling btrfs_insert_inode_ref(); 4) Because the re",
"evidence": "osv:CVE-2025-38365",
"products": [
{
"name": {
"value": "Kernel",
"evidence": "/affected/1/package/name"
},
"prerequisites": [],
"fixed_versions": [
{
"value": "6.1.143",
"evidence": "/affected/1/ranges"
},
{
"value": "6.6.96",
"evidence": "/affected/1/ranges"
},
{
"value": "6.12.36",
"evidence": "/affected/1/ranges"
},
{
"value": "6.15.5",
"evidence": "/affected/1/ranges"
}
],
"affected_versions": []
}
],
"severity": "critical",
"structured": {
"id": "CVE-2025-38365",
"aliases": [
"CVE-2025-38365"
],
"metrics": [
{
"type": "CVSS_V3",
"score": "CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:N/I:H/A:H"
}
],
"affected": [
{
"ranges": [
{
"repo": "https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git",
"type": "GIT",
"events": [
{
"introduced": "259c4b96d78dda8477a3ac21d6b3cf0eb9f75c8b"
},
{
"fixed": "51bd363c7010d033d3334daf457c824484bf9bf0"
},
{
"fixed": "aeeae8feeaae4445a86f9815273e81f902dc1f5b"
},
{
"fixed": "2088895d5903082bb9021770b919e733c57edbc1"
},
{
"fixed": "8c6874646c21bd820cf475e2874e62c133954023"
},
{
"fixed": "3ca864de852bc91007b32d2a0d48993724f4abad"
}
]
}
],
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-38365.json"
}
},
{
"ranges": [
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "5.18.0"
},
{
"fixed": "6.1.143"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "6.2.0"
},
{
"fixed": "6.6.96"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "6.7.0"
},
{
"fixed": "6.12.36"
}
]
},
{
"type": "ECOSYSTEM",
"events": [
{
"introduced": "6.13.0"
},
{
"fixed": "6.15.5"
}
]
}
],
"package": {
"name": "Kernel",
"ecosystem": "Linux"
},
"database_specific": {
"source": "https://storage.googleapis.com/cve-osv-conversion/osv-output/CVE-2025-38365.json"
}
}
],
"modified": "2026-10-28T02:30:33.031915495Z",
"provider": "osv",
"references": [
"https://git.kernel.org/stable/c/2088895d5903082bb9021770b919e733c57edbc1",
"https://git.kernel.org/stable/c/3ca864de852bc91007b32d2a0d48993724f4abad",
"https://git.kernel.org/stable/c/51bd363c7010d033d3334daf457c824484bf9bf0",
"https://git.kernel.org/stable/c/8c6874646c21bd820cf475e2874e62c133954023",
"https://git.kernel.org/stable/c/aeeae8feeaae4445a86f9815273e81f902dc1f5b",
"https://lists.debian.org/debian-lts-announce/2025/10/msg00008.html",
"https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/38xxx/CVE-2025-38365.json",
"https://nvd.nist.gov/vuln/detail/CVE-2025-38365",
"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git"
],
"provider_metadata": {
"cna_assigner": "Linux",
"osv_generated_from": "https://github.com/CVEProject/cvelistV5/tree/main/cves/2025/38xxx/CVE-2025-38365.json"
}
},
"related_cves": [
{
"value": "CVE-2025-38365",
"evidence": "/id"
}
],
"security_relevant": true,
"severity_evidence": "/severity/0/score"
},
"source_id": "core-osv",
"document_id": 499809,
"published_at": "2025-07-25T12:47:35.387+00:00"
}