CVE Vulnerabilities

CVE-2025-38365

Concurrent Execution using Shared Resource with Improper Synchronization ('Race Condition')

Published: Jul 25, 2025 | Modified: Dec 16, 2025
CVSS 3.x
4.7
MEDIUM
Source:
NVD
CVSS:3.1/AV:L/AC:H/PR:L/UI:N/S:U/C:N/I:N/A:H
CVSS 2.x
RedHat/V2
RedHat/V3
Ubuntu
MEDIUM
root.io logo minimus.io logo echo.ai logo

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 well 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, well 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 inodes 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 rename happens in the same directory, we dont set the last_unlink_trans field of directoty As inode to the current transaction id, that is, we dont cal btrfs_record_unlink_dir();

  5. Task A then removes the entries from directory A (BTRFS_DIR_ITEM_KEY and BTRFS_DIR_INDEX_KEY items) when calling __btrfs_unlink_inode() (actually the dir index item is added as a delayed item, but the effect is the same);

  6. Now before task A adds the new entry A/baz to directory A by calling btrfs_add_link(), another task, task B is logging inode X;

  7. Task B starts a fsync of inode X and after logging inode X, at btrfs_log_inode_parent() it calls btrfs_log_all_parents(), since inode X has a last_unlink_trans value of N, set at in step 1;

  8. At btrfs_log_all_parents() we search for all parent directories of inode X using the commit root, so we find directories A and B and log them. Bu when logging direct A, we dont have a dir index item for inode Y anymore, neither the old name A/bar nor for the new name A/baz since the rename has deleted the old name but has not yet inserted the new name - task A hasnt called yet btrfs_add_link() to do that.

    Note that logging directory A doesnt fallback to a transaction commit because its last_unlink_trans has a lower value than the current transactions id (see step 4);

  9. Task B finishes logging directories A and B and gets back to btrfs_sync_file() where it calls btrfs_sync_log() to persist the log tree;

  10. Task B successfully persisted the log tree, btrfs_sync_log() completed with success, and a power failure happened.

    We have a log tree without any directory entry for inode Y, so the log replay code deletes the entry for inode Y, name A/bar, from the subvolume tree since it doesnt exist in the log tree and the log tree is authorative for its index (we logged a BTRFS_DIR_LOG_INDEX_KEY item that covers the index range for the dentry that corresponds to A/bar).

    Since theres no other hard link for inode Y and the log replay code deletes the name A/bar, the file is lost.

The issue wouldnt happen if task B synced the log only after task A called btrfs_log_new_name(), which would update the log with the new name for inode Y (A/bar).

Fix this by pinning the log root during renames before removing the old directory entry, and unpinning af —truncated—

Weakness

The product contains a concurrent code sequence that requires temporary, exclusive access to a shared resource, but a timing window exists in which the shared resource can be modified by another code sequence operating concurrently.

Affected Software

NameVendorStart VersionEnd Version
Linux_kernelLinux5.18 (including)6.1.143 (excluding)
Linux_kernelLinux6.2 (including)6.6.96 (excluding)
Linux_kernelLinux6.7 (including)6.12.36 (excluding)
Linux_kernelLinux6.13 (including)6.15.5 (excluding)
Linux_kernelLinux6.16-rc1 (including)6.16-rc1 (including)
Linux_kernelLinux6.16-rc2 (including)6.16-rc2 (including)
Linux_kernelLinux6.16-rc3 (including)6.16-rc3 (including)
LinuxUbuntunoble*
LinuxUbuntuplucky*
LinuxUbuntuupstream*
Linux-allwinner-5.19Ubuntujammy*
Linux-allwinner-5.19Ubuntuupstream*
Linux-awsUbuntunoble*
Linux-awsUbuntuplucky*
Linux-awsUbuntuupstream*
Linux-aws-5.0Ubuntubionic*
Linux-aws-5.0Ubuntuesm-infra/bionic*
Linux-aws-5.0Ubuntuupstream*
Linux-aws-5.11Ubuntuesm-infra/focal*
Linux-aws-5.11Ubuntufocal*
Linux-aws-5.11Ubuntuupstream*
Linux-aws-5.13Ubuntuesm-infra/focal*
Linux-aws-5.13Ubuntufocal*
Linux-aws-5.13Ubuntuupstream*
Linux-aws-5.15Ubuntuupstream*
Linux-aws-5.19Ubuntujammy*
Linux-aws-5.19Ubuntuupstream*
Linux-aws-5.3Ubuntubionic*
Linux-aws-5.3Ubuntuesm-infra/bionic*
Linux-aws-5.3Ubuntuupstream*
Linux-aws-5.4Ubuntuupstream*
Linux-aws-5.8Ubuntuesm-infra/focal*
Linux-aws-5.8Ubuntufocal*
Linux-aws-5.8Ubuntuupstream*
Linux-aws-6.14Ubuntunoble*
Linux-aws-6.14Ubuntuupstream*
Linux-aws-6.2Ubuntujammy*
Linux-aws-6.2Ubuntuupstream*
Linux-aws-6.5Ubuntujammy*
Linux-aws-6.5Ubuntuupstream*
Linux-aws-6.8Ubuntujammy*
Linux-aws-6.8Ubuntuupstream*
Linux-aws-fipsUbuntufips-updates/noble*
Linux-aws-fipsUbuntutrusty*
Linux-aws-fipsUbuntuupstream*
Linux-aws-fipsUbuntuxenial*
Linux-aws-hweUbuntuupstream*
Linux-azureUbuntubionic*
Linux-azureUbuntuesm-infra/bionic*
Linux-azureUbuntunoble*
Linux-azureUbuntuplucky*
Linux-azureUbuntuupstream*
Linux-azure-4.15Ubuntuupstream*
Linux-azure-5.11Ubuntuesm-infra/focal*
Linux-azure-5.11Ubuntufocal*
Linux-azure-5.11Ubuntuupstream*
Linux-azure-5.13Ubuntuesm-infra/focal*
Linux-azure-5.13Ubuntufocal*
Linux-azure-5.13Ubuntuupstream*
Linux-azure-5.15Ubuntuupstream*
Linux-azure-5.19Ubuntujammy*
Linux-azure-5.19Ubuntuupstream*
Linux-azure-5.3Ubuntubionic*
Linux-azure-5.3Ubuntuesm-infra/bionic*
Linux-azure-5.3Ubuntuupstream*
Linux-azure-5.4Ubuntuupstream*
Linux-azure-5.8Ubuntuesm-infra/focal*
Linux-azure-5.8Ubuntufocal*
Linux-azure-5.8Ubuntuupstream*
Linux-azure-6.11Ubuntunoble*
Linux-azure-6.11Ubuntuupstream*
Linux-azure-6.14Ubuntunoble*
Linux-azure-6.14Ubuntuupstream*
Linux-azure-6.2Ubuntujammy*
Linux-azure-6.2Ubuntuupstream*
Linux-azure-6.5Ubuntujammy*
Linux-azure-6.5Ubuntuupstream*
Linux-azure-6.8Ubuntujammy*
Linux-azure-6.8Ubuntuupstream*
Linux-azure-edgeUbuntubionic*
Linux-azure-edgeUbuntuesm-infra/bionic*
Linux-azure-edgeUbuntuupstream*
Linux-azure-fdeUbuntuesm-infra/focal*
Linux-azure-fdeUbuntufocal*
Linux-azure-fdeUbuntunoble*
Linux-azure-fdeUbuntuupstream*
Linux-azure-fde-5.15Ubuntuupstream*
Linux-azure-fde-5.19Ubuntujammy*
Linux-azure-fde-5.19Ubuntuupstream*
Linux-azure-fde-6.14Ubuntuupstream*
Linux-azure-fde-6.2Ubuntujammy*
Linux-azure-fde-6.2Ubuntuupstream*
Linux-azure-fde-6.8Ubuntujammy*
Linux-azure-fde-6.8Ubuntuupstream*
Linux-azure-fipsUbuntufips-updates/noble*
Linux-azure-fipsUbuntutrusty*
Linux-azure-fipsUbuntuupstream*
Linux-azure-fipsUbuntuxenial*
Linux-azure-nvidiaUbuntunoble*
Linux-azure-nvidiaUbuntuupstream*
Linux-azure-nvidia-6.14Ubuntunoble*
Linux-azure-nvidia-6.14Ubuntuupstream*
Linux-bluefieldUbuntuupstream*
Linux-fipsUbuntufips-updates/noble*
Linux-fipsUbuntuupstream*
Linux-gcpUbuntubionic*
Linux-gcpUbuntuesm-infra/bionic*
Linux-gcpUbuntunoble*
Linux-gcpUbuntuplucky*
Linux-gcpUbuntuupstream*
Linux-gcp-4.15Ubuntuupstream*
Linux-gcp-5.11Ubuntuesm-infra/focal*
Linux-gcp-5.11Ubuntufocal*
Linux-gcp-5.11Ubuntuupstream*
Linux-gcp-5.13Ubuntuesm-infra/focal*
Linux-gcp-5.13Ubuntufocal*
Linux-gcp-5.13Ubuntuupstream*
Linux-gcp-5.15Ubuntuupstream*
Linux-gcp-5.19Ubuntujammy*
Linux-gcp-5.19Ubuntuupstream*
Linux-gcp-5.3Ubuntubionic*
Linux-gcp-5.3Ubuntuesm-infra/bionic*
Linux-gcp-5.3Ubuntuupstream*
Linux-gcp-5.4Ubuntuupstream*
Linux-gcp-5.8Ubuntuesm-infra/focal*
Linux-gcp-5.8Ubuntufocal*
Linux-gcp-5.8Ubuntuupstream*
Linux-gcp-6.11Ubuntunoble*
Linux-gcp-6.11Ubuntuupstream*
Linux-gcp-6.14Ubuntunoble*
Linux-gcp-6.14Ubuntuupstream*
Linux-gcp-6.2Ubuntujammy*
Linux-gcp-6.2Ubuntuupstream*
Linux-gcp-6.5Ubuntujammy*
Linux-gcp-6.5Ubuntuupstream*
Linux-gcp-6.8Ubuntujammy*
Linux-gcp-6.8Ubuntuupstream*
Linux-gcp-fipsUbuntufips-updates/noble*
Linux-gcp-fipsUbuntutrusty*
Linux-gcp-fipsUbuntuupstream*
Linux-gcp-fipsUbuntuxenial*
Linux-gkeUbuntuesm-infra/focal*
Linux-gkeUbuntufocal*
Linux-gkeUbuntunoble*
Linux-gkeUbuntuupstream*
Linux-gkeUbuntuxenial*
Linux-gke-4.15Ubuntubionic*
Linux-gke-4.15Ubuntuesm-infra/bionic*
Linux-gke-4.15Ubuntuupstream*
Linux-gke-5.15Ubuntuesm-infra/focal*
Linux-gke-5.15Ubuntufocal*
Linux-gke-5.15Ubuntuupstream*
Linux-gke-5.4Ubuntubionic*
Linux-gke-5.4Ubuntuesm-infra/bionic*
Linux-gke-5.4Ubuntuupstream*
Linux-gkeopUbuntuesm-infra/focal*
Linux-gkeopUbuntufocal*
Linux-gkeopUbuntunoble*
Linux-gkeopUbuntuupstream*
Linux-gkeop-5.15Ubuntuesm-infra/focal*
Linux-gkeop-5.15Ubuntufocal*
Linux-gkeop-5.15Ubuntuupstream*
Linux-gkeop-5.4Ubuntubionic*
Linux-gkeop-5.4Ubuntuesm-infra/bionic*
Linux-gkeop-5.4Ubuntuupstream*
Linux-hweUbuntubionic*
Linux-hweUbuntuesm-infra/bionic*
Linux-hweUbuntuupstream*
Linux-hwe-5.11Ubuntuesm-infra/focal*
Linux-hwe-5.11Ubuntufocal*
Linux-hwe-5.11Ubuntuupstream*
Linux-hwe-5.13Ubuntuesm-infra/focal*
Linux-hwe-5.13Ubuntufocal*
Linux-hwe-5.13Ubuntuupstream*
Linux-hwe-5.15Ubuntuupstream*
Linux-hwe-5.19Ubuntujammy*
Linux-hwe-5.19Ubuntuupstream*
Linux-hwe-5.4Ubuntuupstream*
Linux-hwe-5.8Ubuntuesm-infra/focal*
Linux-hwe-5.8Ubuntufocal*
Linux-hwe-5.8Ubuntuupstream*
Linux-hwe-6.11Ubuntunoble*
Linux-hwe-6.11Ubuntuupstream*
Linux-hwe-6.14Ubuntuupstream*
Linux-hwe-6.2Ubuntujammy*
Linux-hwe-6.2Ubuntuupstream*
Linux-hwe-6.5Ubuntujammy*
Linux-hwe-6.5Ubuntuupstream*
Linux-hwe-6.8Ubuntujammy*
Linux-hwe-6.8Ubuntuupstream*
Linux-hwe-edgeUbuntubionic*
Linux-hwe-edgeUbuntuesm-infra/bionic*
Linux-hwe-edgeUbuntuesm-infra/xenial*
Linux-hwe-edgeUbuntuupstream*
Linux-hwe-edgeUbuntuxenial*
Linux-ibmUbuntunoble*
Linux-ibmUbuntuupstream*
Linux-ibm-5.15Ubuntuupstream*
Linux-ibm-5.4Ubuntuupstream*
Linux-ibm-6.8Ubuntujammy*
Linux-ibm-6.8Ubuntuupstream*
Linux-intelUbuntunoble*
Linux-intelUbuntuupstream*
Linux-intel-5.13Ubuntuesm-infra/focal*
Linux-intel-5.13Ubuntufocal*
Linux-intel-5.13Ubuntuupstream*
Linux-intel-iot-realtimeUbuntujammy*
Linux-intel-iot-realtimeUbuntuupstream*
Linux-intel-iotgUbuntuupstream*
Linux-intel-iotg-5.15Ubuntuupstream*
Linux-iotUbuntuupstream*
Linux-kvmUbuntuupstream*
Linux-lowlatencyUbuntunoble*
Linux-lowlatencyUbuntuupstream*
Linux-lowlatency-hwe-5.15Ubuntuupstream*
Linux-lowlatency-hwe-5.19Ubuntujammy*
Linux-lowlatency-hwe-5.19Ubuntuupstream*
Linux-lowlatency-hwe-6.11Ubuntunoble*
Linux-lowlatency-hwe-6.11Ubuntuupstream*
Linux-lowlatency-hwe-6.2Ubuntujammy*
Linux-lowlatency-hwe-6.2Ubuntuupstream*
Linux-lowlatency-hwe-6.5Ubuntujammy*
Linux-lowlatency-hwe-6.5Ubuntuupstream*
Linux-lowlatency-hwe-6.8Ubuntujammy*
Linux-lowlatency-hwe-6.8Ubuntuupstream*
Linux-lts-xenialUbuntuupstream*
Linux-nvidiaUbuntunoble*
Linux-nvidiaUbuntuupstream*
Linux-nvidia-6.11Ubuntunoble*
Linux-nvidia-6.11Ubuntuupstream*
Linux-nvidia-6.2Ubuntujammy*
Linux-nvidia-6.2Ubuntuupstream*
Linux-nvidia-6.5Ubuntujammy*
Linux-nvidia-6.5Ubuntuupstream*
Linux-nvidia-6.8Ubuntujammy*
Linux-nvidia-6.8Ubuntuupstream*
Linux-nvidia-lowlatencyUbuntunoble*
Linux-nvidia-lowlatencyUbuntuupstream*
Linux-nvidia-tegraUbuntunoble*
Linux-nvidia-tegraUbuntuupstream*
Linux-nvidia-tegra-5.15Ubuntuupstream*
Linux-nvidia-tegra-igxUbuntuupstream*
Linux-oemUbuntubionic*
Linux-oemUbuntuesm-infra/bionic*
Linux-oemUbuntuupstream*
Linux-oemUbuntuxenial*
Linux-oem-5.10Ubuntuesm-infra/focal*
Linux-oem-5.10Ubuntufocal*
Linux-oem-5.10Ubuntuupstream*
Linux-oem-5.13Ubuntuesm-infra/focal*
Linux-oem-5.13Ubuntufocal*
Linux-oem-5.13Ubuntuupstream*
Linux-oem-5.14Ubuntuesm-infra/focal*
Linux-oem-5.14Ubuntufocal*
Linux-oem-5.14Ubuntuupstream*
Linux-oem-5.17Ubuntujammy*
Linux-oem-5.17Ubuntuupstream*
Linux-oem-5.6Ubuntuesm-infra/focal*
Linux-oem-5.6Ubuntufocal*
Linux-oem-5.6Ubuntuupstream*
Linux-oem-6.0Ubuntujammy*
Linux-oem-6.0Ubuntuupstream*
Linux-oem-6.1Ubuntujammy*
Linux-oem-6.1Ubuntuupstream*
Linux-oem-6.11Ubuntunoble*
Linux-oem-6.11Ubuntuupstream*
Linux-oem-6.14Ubuntunoble*
Linux-oem-6.14Ubuntuupstream*
Linux-oem-6.17Ubuntuupstream*
Linux-oem-6.5Ubuntujammy*
Linux-oem-6.5Ubuntuupstream*
Linux-oem-6.8Ubuntunoble*
Linux-oem-6.8Ubuntuupstream*
Linux-oracleUbuntunoble*
Linux-oracleUbuntuplucky*
Linux-oracleUbuntuupstream*
Linux-oracle-5.0Ubuntubionic*
Linux-oracle-5.0Ubuntuesm-infra/bionic*
Linux-oracle-5.0Ubuntuupstream*
Linux-oracle-5.11Ubuntuesm-infra/focal*
Linux-oracle-5.11Ubuntufocal*
Linux-oracle-5.11Ubuntuupstream*
Linux-oracle-5.13Ubuntuesm-infra/focal*
Linux-oracle-5.13Ubuntufocal*
Linux-oracle-5.13Ubuntuupstream*
Linux-oracle-5.15Ubuntuupstream*
Linux-oracle-5.3Ubuntubionic*
Linux-oracle-5.3Ubuntuesm-infra/bionic*
Linux-oracle-5.3Ubuntuupstream*
Linux-oracle-5.4Ubuntuupstream*
Linux-oracle-5.8Ubuntuesm-infra/focal*
Linux-oracle-5.8Ubuntufocal*
Linux-oracle-5.8Ubuntuupstream*
Linux-oracle-6.14Ubuntunoble*
Linux-oracle-6.14Ubuntuupstream*
Linux-oracle-6.5Ubuntujammy*
Linux-oracle-6.5Ubuntuupstream*
Linux-oracle-6.8Ubuntujammy*
Linux-oracle-6.8Ubuntuupstream*
Linux-raspiUbuntunoble*
Linux-raspiUbuntuplucky*
Linux-raspiUbuntuupstream*
Linux-raspi-5.4Ubuntuupstream*
Linux-raspi-realtimeUbuntunoble*
Linux-raspi-realtimeUbunturealtime/noble*
Linux-raspi-realtimeUbuntuupstream*
Linux-raspi2Ubuntubionic*
Linux-raspi2Ubuntuesm-infra/focal*
Linux-raspi2Ubuntufocal*
Linux-raspi2Ubuntuupstream*
Linux-raspi2Ubuntuxenial*
Linux-realtimeUbuntujammy*
Linux-realtimeUbuntunoble*
Linux-realtimeUbuntuplucky*
Linux-realtimeUbunturealtime/noble*
Linux-realtimeUbuntuupstream*
Linux-realtime-6.14Ubunturealtime/noble*
Linux-realtime-6.14Ubuntuupstream*
Linux-realtime-6.8Ubunturealtime/jammy*
Linux-realtime-6.8Ubuntuupstream*
Linux-riscvUbuntuesm-infra/focal*
Linux-riscvUbuntufocal*
Linux-riscvUbuntujammy*
Linux-riscvUbuntunoble*
Linux-riscvUbuntuplucky*
Linux-riscvUbuntuupstream*
Linux-riscv-5.11Ubuntuesm-infra/focal*
Linux-riscv-5.11Ubuntufocal*
Linux-riscv-5.11Ubuntuupstream*
Linux-riscv-5.15Ubuntuupstream*
Linux-riscv-5.19Ubuntujammy*
Linux-riscv-5.19Ubuntuupstream*
Linux-riscv-5.8Ubuntuesm-infra/focal*
Linux-riscv-5.8Ubuntufocal*
Linux-riscv-5.8Ubuntuupstream*
Linux-riscv-6.14Ubuntunoble*
Linux-riscv-6.14Ubuntuupstream*
Linux-riscv-6.5Ubuntujammy*
Linux-riscv-6.5Ubuntuupstream*
Linux-riscv-6.8Ubuntujammy*
Linux-riscv-6.8Ubuntuupstream*
Linux-starfive-5.19Ubuntujammy*
Linux-starfive-5.19Ubuntuupstream*
Linux-starfive-6.2Ubuntujammy*
Linux-starfive-6.2Ubuntuupstream*
Linux-starfive-6.5Ubuntujammy*
Linux-starfive-6.5Ubuntuupstream*
Linux-xilinxUbuntunoble*
Linux-xilinxUbuntuupstream*
Linux-xilinx-zynqmpUbuntuupstream*

Extended Description

A race condition occurs within concurrent environments, and it is effectively a property of a code sequence. Depending on the context, a code sequence may be in the form of a function call, a small number of instructions, a series of program invocations, etc. A race condition violates these properties, which are closely related:

A race condition exists when an “interfering code sequence” can still access the shared resource, violating exclusivity. The interfering code sequence could be “trusted” or “untrusted.” A trusted interfering code sequence occurs within the product; it cannot be modified by the attacker, and it can only be invoked indirectly. An untrusted interfering code sequence can be authored directly by the attacker, and typically it is external to the vulnerable product.

Potential Mitigations

  • Minimize the usage of shared resources in order to remove as much complexity as possible from the control flow and to reduce the likelihood of unexpected conditions occurring.
  • Additionally, this will minimize the amount of synchronization necessary and may even help to reduce the likelihood of a denial of service where an attacker may be able to repeatedly trigger a critical section (CWE-400).

References