KernelScan.io

HIGH

media HackRF Device UAF

CVE-2026-31576

CVSS 7.8 / 10.0 NVD

CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H

KernelScan AI7.8HIGH

01

In the Linux kernel, the following vulnerability has been resolved: media: hackrf: fix to not free memory after the device is registered in hackrf_probe() In hackrf driver, the following race condition occurs: ``` CPU0 CPU1 hackrf_probe() kzalloc(); // alloc hackrf_dev .... v4l2_device_register(); .... fd = sys_open("/path/to/dev"); // open hackrf fd .... v4l2_device_unregister(); .... kfree(); // free hackrf_dev .... sys_ioctl(fd, ...); v4l2_ioctl(); video_is_registered() // UAF!! .... sys_close(fd); v4l2_release() // UAF!! hackrf_video_release() kfree(); // DFB!! ``` When a V4L2 or video device is unregistered, the device node is removed so new open() calls are blocked. However, file descriptors that are already open-and any in-flight I/O-do not terminate immediately; they remain valid until the last reference is dropped and the driver's release() is invoked. Therefore, freeing device memory on the error path after hackrf_probe() has registered dev it will lead to a race to use-after-free vuln, since those already-open handles haven't been released yet. And since release() free memory too, race to use-after-free and double-free vuln occur. To prevent this, if device is registered from probe(), it should be modified to free memory only through release() rather than calling kfree() directly.

02

Engine v0.2.0

Risk summary

A race condition in the HackRF USB media driver can cause memory corruption when the device probe fails after registration. An attacker with physical access could potentially trigger this by manipulating USB device insertion/removal timing, leading to kernel crashes or potential privilege escalation through memory corruption.

Affecteddrivers/media/usb/hackrf/hackrf.c

Vulnerability analysis

Root Cause: The hackrf driver has a race condition in its probe() function where device memory is freed on error paths after the V4L2 device has been registered. When v4l2_device_register() succeeds, userspace can open file descriptors to the device. If probe() subsequently fails and calls kfree() on the device structure, those open file descriptors become dangling pointers. When userspace later performs operations on these file descriptors (ioctl, close), it triggers use-after-free and potentially double-free vulnerabilities.

Attack Surface: Local attack surface requiring physical access to plug in a HackRF USB device. The vulnerability is triggered through the USB subsystem when the device is probed and userspace applications interact with the V4L2 device nodes. Requires ability to insert USB devices and open device files.

Fix Mechanism: The fix changes the error handling path to use v4l2_device_put() instead of v4l2_device_unregister() followed by kfree(). This ensures that the device memory is only freed through the proper V4L2 reference counting mechanism in the release() callback, preventing premature deallocation while file descriptors are still open.

03

BranchFixed inPatch commit
5.105.10.25887b9685cca91
5.155.15.209131ec9046e1c
6.16.1.17567fd62e3efdc
6.126.12.8398a0a81ce780
6.186.18.2407e9e674b614
6.196.19.142145c71a8044
6.66.6.13645cbaf5c7cdc
7.07.0.1fcd1d70792a3
mainline7.1-rc13b7da2b4d0fe