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.
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
| Ecosystem | Package | Fixed in | Advisory |
|---|---|---|---|
| Debian:12 | linux | 6.1.176-1 | DEBIAN-CVE-2025-21739 |
| Debian:13 | linux | 6.12.15-1 | DEBIAN-CVE-2025-21739 |
| Debian:14 | linux | 6.12.15-1 | DEBIAN-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux | 5.15.0-186.196 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux | 5.15.0-186.196 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux | 6.8.0-64.67 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-allwinner-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws | 5.15.0-1112.119 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws | 5.15.0-1112.119 | USN-8575-2 |
| Ubuntu:24.04:LTS | linux-aws | 6.8.0-1032.34 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-aws-6.8 | 6.8.0-1032.34~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure | 5.15.0-1117.126 | USN-8575-3 |
| Ubuntu:22.04:LTS | linux-azure | 5.15.0-1117.126 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-azure | 6.8.0-1034.39 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-azure-6.11 | 6.11.0-1015.15~24.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-6.8 | 6.8.0-1034.39~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-fde | 5.15.0-1117.126 | USN-8610-1 |
| Ubuntu:22.04:LTS | linux-azure-fde | 5.15.0-1117.126 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-fde-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-azure-fde-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-azure-nvidia | 6.8.0-1022.23 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gcp | 5.15.0-1112.122 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux-gcp | 5.15.0-1112.122 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-gcp | 6.8.0-1033.35 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gcp-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-gcp-6.11 | 6.11.0-1015.15~24.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gcp-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gcp-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gcp-6.8 | 6.8.0-1033.35~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gke | 5.15.0-1108.114 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux-gke | 5.15.0-1108.114 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-gke | 6.8.0-1028.32 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-gkeop | 5.15.0-1095.103 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux-gkeop | 5.15.0-1095.103 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-gkeop | 6.8.0-1015.17 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-hwe-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-hwe-6.11 | 6.11.0-26.26~24.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-hwe-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-hwe-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-hwe-6.8 | 6.8.0-64.67~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-ibm | 5.15.0-1106.110 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-ibm | 5.15.0-1106.110 | USN-8575-2 |
| Ubuntu:24.04:LTS | linux-ibm | 6.8.0-1029.29 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-ibm-6.8 | 6.8.0-1029.29~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-intel-iot-realtime | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-intel-iotg | 5.15.0-1107.113 | USN-8620-4 |
| Ubuntu:22.04:LTS | linux-intel-iotg | 5.15.0-1107.113 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-kvm | 5.15.0-1104.109 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux-kvm | 5.15.0-1104.109 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency | 5.15.0-184.194 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency | 5.15.0-184.194 | USN-8575-1 |
| Ubuntu:24.04:LTS | linux-lowlatency | 6.8.0-64.67.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-lowlatency-hwe-6.11 | 6.11.0-1014.15~24.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-lowlatency-hwe-6.8 | 6.8.0-64.67.1~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia | 5.15.0-1107.108 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia | 5.15.0-1107.108 | USN-8575-2 |
| Ubuntu:24.04:LTS | linux-nvidia | 6.8.0-1031.34 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-nvidia-6.11 | 6.11.0-1010.10 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-6.8 | 6.8.0-1031.34~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-nvidia-lowlatency | 6.8.0-1031.34.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra | 5.15.0-1064.66 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra | 5.15.0-1064.66 | USN-8576-2 |
| Ubuntu:24.04:LTS | linux-nvidia-tegra | 6.8.0-1008.8 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra-igx | 5.15.0-1053.53 | USN-8576-2 |
| Ubuntu:22.04:LTS | linux-nvidia-tegra-igx | 5.15.0-1053.53 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oem-5.17 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oem-6.0 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oem-6.1 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-oem-6.11 | 6.11.0-1022.22 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oem-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-oem-6.8 | 6.8.0-1031.31 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oracle | 5.15.0-1109.115 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oracle | 5.15.0-1109.115 | USN-8575-3 |
| Ubuntu:24.04:LTS | linux-oracle | 6.8.0-1029.30 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oracle-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-oracle-6.8 | 6.8.0-1029.30~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-raspi | 5.15.0-1106.109 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-raspi | 5.15.0-1106.109 | USN-8668-2 |
| Ubuntu:24.04:LTS | linux-raspi | 6.8.0-1031.35 | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-raspi-realtime | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-realtime | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-riscv | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-riscv-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-riscv-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-riscv-6.8 | 6.8.0-64.67~22.04.1 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-starfive-5.19 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-starfive-6.2 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-starfive-6.5 | no fix listed | UBUNTU-CVE-2025-21739 |
| Ubuntu:24.04:LTS | linux-xilinx | 6.8.0-1017.18 | UBUNTU-CVE-2025-21739 |
| Ubuntu:22.04:LTS | linux-xilinx-zynqmp | 5.15.0-1075.79 | USN-8575-1 |
| Ubuntu:22.04:LTS | linux-xilinx-zynqmp | 5.15.0-1075.79 | UBUNTU-CVE-2025-21739 |
Affected products (as reported)
| Vendor | Product | Versions |
|---|---|---|
| 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
- https://git.kernel.org/stable/c/0a6895c03b1f439236e2d22b1a69ebfc1eb9d5ea
- https://git.kernel.org/stable/c/d06eb2620d3bf16056b8b7ea3744dbb5e30512f4
- https://git.kernel.org/stable/c/0dc539b888fb5f56b6eeddd95433eab557d4b0c1
- https://git.kernel.org/stable/c/0c77c0d754fe83cb154715fcfec6c3faef94f207
- https://git.kernel.org/stable/c/9c185beae09a3eb85f54777edafa227f7e03075d
- https://git.kernel.org/stable/c/f8fb2403ddebb5eea0033d90d9daae4c88749ada