CVE-2025-38161 in Linuxinfo

Summary

by MITRE • 07/03/2025

In the Linux kernel, the following vulnerability has been resolved:

RDMA/mlx5: Fix error flow upon firmware failure for RQ destruction

Upon RQ destruction if the firmware command fails which is the last resource to be destroyed some SW resources were already cleaned regardless of the failure.

Now properly rollback the object to its original state upon such failure.

In order to avoid a use-after free in case someone tries to destroy the object again, which results in the following kernel trace: refcount_t: underflow; use-after-free. WARNING: CPU: 0 PID: 37589 at lib/refcount.c:28 refcount_warn_saturate+0xf4/0x148 Modules linked in: rdma_ucm(OE) rdma_cm(OE) iw_cm(OE) ib_ipoib(OE) ib_cm(OE) ib_umad(OE) mlx5_ib(OE) rfkill mlx5_core(OE) mlxdevm(OE) ib_uverbs(OE) ib_core(OE) psample mlxfw(OE) mlx_compat(OE) macsec tls pci_hyperv_intf sunrpc vfat fat virtio_net net_failover failover fuse loop nfnetlink vsock_loopback vmw_vsock_virtio_transport_common vmw_vsock_vmci_transport vmw_vmci vsock xfs crct10dif_ce ghash_ce sha2_ce sha256_arm64 sha1_ce virtio_console virtio_gpu virtio_blk virtio_dma_buf virtio_mmio dm_mirror dm_region_hash dm_log dm_mod xpmem(OE) CPU: 0 UID: 0 PID: 37589 Comm: python3 Kdump: loaded Tainted: G OE ------- --- 6.12.0-54.el10.aarch64 #1 Tainted: [O]=OOT_MODULE, [E]=UNSIGNED_MODULE
Hardware name: QEMU KVM Virtual Machine, BIOS 0.0.0 02/06/2015 pstate: 60400005 (nZCv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) pc : refcount_warn_saturate+0xf4/0x148 lr : refcount_warn_saturate+0xf4/0x148 sp : ffff80008b81b7e0 x29: ffff80008b81b7e0 x28: ffff000133d51600 x27: 0000000000000001 x26: 0000000000000000 x25: 00000000ffffffea x24: ffff00010ae80f00 x23: ffff00010ae80f80 x22: ffff0000c66e5d08 x21: 0000000000000000 x20: ffff0000c66e0000 x19: ffff00010ae80340 x18: 0000000000000006 x17: 0000000000000000 x16: 0000000000000020 x15: ffff80008b81b37f x14: 0000000000000000 x13: 2e656572662d7265 x12: ffff80008283ef78 x11: ffff80008257efd0 x10: ffff80008283efd0 x9 : ffff80008021ed90 x8 : 0000000000000001 x7 : 00000000000bffe8 x6 : c0000000ffff7fff x5 : ffff0001fb8e3408 x4 : 0000000000000000 x3 : ffff800179993000 x2 : 0000000000000000 x1 : 0000000000000000 x0 : ffff000133d51600 Call trace: refcount_warn_saturate+0xf4/0x148 mlx5_core_put_rsc+0x88/0xa0 [mlx5_ib]
mlx5_core_destroy_rq_tracked+0x64/0x98 [mlx5_ib]
mlx5_ib_destroy_wq+0x34/0x80 [mlx5_ib]
ib_destroy_wq_user+0x30/0xc0 [ib_core]
uverbs_free_wq+0x28/0x58 [ib_uverbs]
destroy_hw_idr_uobject+0x34/0x78 [ib_uverbs]
uverbs_destroy_uobject+0x48/0x240 [ib_uverbs]
__uverbs_cleanup_ufile+0xd4/0x1a8 [ib_uverbs]
uverbs_destroy_ufile_hw+0x48/0x120 [ib_uverbs]
ib_uverbs_close+0x2c/0x100 [ib_uverbs]
__fput+0xd8/0x2f0 __fput_sync+0x50/0x70 __arm64_sys_close+0x40/0x90 invoke_syscall.constprop.0+0x74/0xd0 do_el0_svc+0x48/0xe8 el0_svc+0x44/0x1d0 el0t_64_sync_handler+0x120/0x130 el0t_64_sync+0x1a4/0x1a8

Statistical analysis made it clear that VulDB provides the best quality for vulnerability data.

Analysis

by VulDB Data Team • 07/31/2026

The vulnerability described in CVE-2025-38161 affects the Linux kernel's RDMA/mlx5 driver, specifically within the mlx5_ib module responsible for managing InfiniBand and RoCE (RDMA over Converged Ethernet) hardware resources. This issue arises during the destruction of Receive Queues (RQs) when a firmware command fails, leading to improper state management and potential use-after-free conditions. The flaw manifests when the driver attempts to clean up software resources even after a firmware operation has failed, causing inconsistent object states that can lead to kernel crashes and system instability. The vulnerability is classified under CWE-415: Double Free and CWE-416: Use After Free, both of which are critical memory safety issues that can be exploited to cause denial of service or potentially arbitrary code execution in kernel space.

The technical root cause involves the improper rollback mechanism during resource destruction operations in the mlx5 driver's RDMA implementation. When destroying an RQ, the system performs multiple steps including firmware commands and software cleanup. If the firmware command fails during the final phase of destruction, the driver incorrectly proceeds to clean up software resources without properly reverting the object to its original state. This leads to a scenario where subsequent destruction attempts can result in accessing freed memory, triggering the kernel's refcount subsystem to detect an underflow condition. The kernel trace shows a call stack that begins with a Python process attempting to destroy RDMA work queues, which eventually leads to the refcount_t underflow in lib/refcount.c, indicating that the reference counting mechanism has been corrupted due to the improper resource cleanup sequence.

The operational impact of this vulnerability extends beyond simple system crashes, as it can affect high-performance computing environments, data centers, and any infrastructure relying on RDMA for low-latency network communication. The use-after-free condition can lead to unpredictable behavior including kernel oops, system panics, or even potential privilege escalation if exploited through carefully crafted malicious RDMA operations. The vulnerability affects systems using Mellanox ConnectX series adapters and other RDMA hardware that relies on the mlx5 driver, particularly in enterprise environments where RDMA is used for high-speed interconnects in distributed computing clusters, storage networks, and supercomputing applications. The issue is particularly concerning because RDMA operations are often critical for performance-sensitive applications where system stability is paramount.

Mitigation strategies for CVE-2025-38161 should focus on applying the latest kernel patches that implement proper rollback mechanisms for resource destruction operations. System administrators should prioritize updating their kernel versions to include the fix that ensures software resources are properly rolled back when firmware commands fail, preventing the inconsistent state that leads to use-after-free conditions. Additionally, monitoring for kernel oops messages and refcount warnings should be implemented to detect potential exploitation attempts. Organizations using RDMA workloads should also consider implementing runtime protections such as kernel lockdown modes and restricting RDMA operations to trusted processes only. The fix aligns with ATT&CK technique T1068: Exploitation for Privilege Escalation by ensuring proper resource management prevents potential exploitation paths that could lead to kernel-level privilege escalation. Regular security audits of RDMA configurations and kernel modules should be conducted to identify and remediate similar resource management issues across the infrastructure.

Responsible

Linux

Reservation

04/16/2025

Disclosure

07/03/2025

Moderation

accepted

CPE

ready

EPSS

0.00153

KEV

no

Activities

very low

Sources

Do you want to use VulDB in your project?

Use the official API to access entries easily!