Vulnerability · Published Feb 27, 2025 · Assigned by Linux

CVE-2025-21739scsi: ufs: core: Fix use-after free in init error and remove paths

High 7.8

In plain English

A high-severity use-after-free in Linux from Linux. There are no confirmed reports of exploitation so far. The chance it is exploited in the next 30 days is estimated at 0.2% (higher than 13% of all known vulnerabilities). Fixed versions are available - upgrade the affected package.

Severity (CVSS 3.1)7.8High
Exploit odds (30 days)0.2%top 87.0% of all CVEs
Exploited in the wildNo reportsCISA SSVC: none
Attack toolingNoneno public tooling known

Official description

In the Linux kernel, the following vulnerability has been resolved: scsi: ufs: core: Fix use-after free in init error and remove paths devm_blk_crypto_profile_init() registers a cleanup handler to run when the associated (platform-) device is being released. For UFS, the crypto private data and pointers are stored as part of the ufs_hba's data structure 'struct ufs_hba::crypto_profile'. This structure is allocated as part of the underlying ufshcd and therefore Scsi_host allocation. During driver release or during error handling in ufshcd_pltfrm_init(), this structure is released as part of ufshcd_dealloc_host() before the (platform-) device associated with the crypto call above is released. Once this device is released, the crypto cleanup code will run, using the just-released 'struct ufs_hba::crypto_profile'. This causes a use-after-free situation: Call trace: kfree+0x60/0x2d8 (P) kvfree+0x44/0x60 blk_crypto_profile_destroy_callback+0x28/0x70 devm_action_release+0x1c/0x30 release_nodes+0x6c/0x108 devres_release_all+0x98/0x100 device_unbind_cleanup+0x20/0x70 really_probe+0x218/0x2d0 In other words, the initialisation code flow is: platform-device probe ufshcd_pltfrm_init() ufshcd_alloc_host() scsi_host_alloc() allocation of struct ufs_hba creation of scsi-host devices devm_blk_crypto_profile_init() devm registration of cleanup handler using platform-device and during error handling of ufshcd_pltfrm_init() or during driver removal: ufshcd_dealloc_host() scsi_host_put() put_device(scsi-host) release of struct ufs_hba put_device(platform-device) crypto cleanup handler To fix this use-after free, change ufshcd_alloc_host() to register a devres action to automatically cleanup the underlying SCSI device on ufshcd destruction, without requiring explicit calls to ufshcd_dealloc_host(). This way: * the crypto profile and all other ufs_hba-owned resources are destroyed before SCSI (as they've been registered after) * a memleak is plugged in tc-dwc-g210-pci.c remove() as a side-effect * EXPORT_SYMBOL_GPL(ufshcd_dealloc_host) can be removed fully as it's not needed anymore * no future drivers using ufshcd_alloc_host() could ever forget adding the cleanup

Affected packages & fixed versions

EcosystemPackageFixed inAdvisory
Debian:12linux6.1.176-1DEBIAN-CVE-2025-21739
Debian:13linux6.12.15-1DEBIAN-CVE-2025-21739
Debian:14linux6.12.15-1DEBIAN-CVE-2025-21739
Ubuntu:22.04:LTSlinux5.15.0-186.196USN-8575-1
Ubuntu:22.04:LTSlinux5.15.0-186.196UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux6.8.0-64.67UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-allwinner-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws5.15.0-1112.119UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws5.15.0-1112.119USN-8575-2
Ubuntu:24.04:LTSlinux-aws6.8.0-1032.34UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-aws-6.86.8.0-1032.34~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure5.15.0-1117.126USN-8575-3
Ubuntu:22.04:LTSlinux-azure5.15.0-1117.126UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-azure6.8.0-1034.39UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-azure-6.116.11.0-1015.15~24.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-6.86.8.0-1034.39~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1117.126USN-8610-1
Ubuntu:22.04:LTSlinux-azure-fde5.15.0-1117.126UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-fde-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-azure-fde-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-azure-nvidia6.8.0-1022.23UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gcp5.15.0-1112.122USN-8575-1
Ubuntu:22.04:LTSlinux-gcp5.15.0-1112.122UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-gcp6.8.0-1033.35UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gcp-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-gcp-6.116.11.0-1015.15~24.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gcp-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gcp-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gcp-6.86.8.0-1033.35~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gke5.15.0-1108.114USN-8575-1
Ubuntu:22.04:LTSlinux-gke5.15.0-1108.114UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-gke6.8.0-1028.32UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1095.103USN-8575-1
Ubuntu:22.04:LTSlinux-gkeop5.15.0-1095.103UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-gkeop6.8.0-1015.17UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-hwe-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-hwe-6.116.11.0-26.26~24.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-hwe-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-hwe-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-hwe-6.86.8.0-64.67~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-ibm5.15.0-1106.110UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-ibm5.15.0-1106.110USN-8575-2
Ubuntu:24.04:LTSlinux-ibm6.8.0-1029.29UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-ibm-6.86.8.0-1029.29~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-intel-iot-realtimeno fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1107.113USN-8620-4
Ubuntu:22.04:LTSlinux-intel-iotg5.15.0-1107.113UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-kvm5.15.0-1104.109USN-8575-1
Ubuntu:22.04:LTSlinux-kvm5.15.0-1104.109UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-184.194UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency5.15.0-184.194USN-8575-1
Ubuntu:24.04:LTSlinux-lowlatency6.8.0-64.67.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency-hwe-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-lowlatency-hwe-6.116.11.0-1014.15~24.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-lowlatency-hwe-6.86.8.0-64.67.1~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1107.108UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia5.15.0-1107.108USN-8575-2
Ubuntu:24.04:LTSlinux-nvidia6.8.0-1031.34UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-nvidia-6.116.11.0-1010.10UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-6.86.8.0-1031.34~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-nvidia-lowlatency6.8.0-1031.34.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-tegra5.15.0-1064.66UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-tegra5.15.0-1064.66USN-8576-2
Ubuntu:24.04:LTSlinux-nvidia-tegra6.8.0-1008.8UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-nvidia-tegra-igx5.15.0-1053.53USN-8576-2
Ubuntu:22.04:LTSlinux-nvidia-tegra-igx5.15.0-1053.53UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oem-5.17no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oem-6.0no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oem-6.1no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-oem-6.116.11.0-1022.22UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oem-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-oem-6.86.8.0-1031.31UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oracle5.15.0-1109.115UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oracle5.15.0-1109.115USN-8575-3
Ubuntu:24.04:LTSlinux-oracle6.8.0-1029.30UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oracle-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-oracle-6.86.8.0-1029.30~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-raspi5.15.0-1106.109UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-raspi5.15.0-1106.109USN-8668-2
Ubuntu:24.04:LTSlinux-raspi6.8.0-1031.35UBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-raspi-realtimeno fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-realtimeno fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-riscvno fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-riscv-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-riscv-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-riscv-6.86.8.0-64.67~22.04.1UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-starfive-5.19no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-starfive-6.2no fix listedUBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-starfive-6.5no fix listedUBUNTU-CVE-2025-21739
Ubuntu:24.04:LTSlinux-xilinx6.8.0-1017.18UBUNTU-CVE-2025-21739
Ubuntu:22.04:LTSlinux-xilinx-zynqmp5.15.0-1075.79USN-8575-1
Ubuntu:22.04:LTSlinux-xilinx-zynqmp5.15.0-1075.79UBUNTU-CVE-2025-21739

Affected products (as reported)

VendorProductVersions
Linux Linux d76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before 0a6895c03b1f439236e2d22b1a69ebfc1eb9d5ead76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before d06eb2620d3bf16056b8b7ea3744dbb5e30512f4d76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before 0dc539b888fb5f56b6eeddd95433eab557d4b0c1d76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before 0c77c0d754fe83cb154715fcfec6c3faef94f207d76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before 9c185beae09a3eb85f54777edafa227f7e03075dd76d9d7d1009968dd3a0fc30e5f5ee9fbffc1350 – before f8fb2403ddebb5eea0033d90d9daae4c88749ada
Linux Linux 5.12

Weakness: CWE-416 · Vector: CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

References