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.
CVE-2026-31576 is a use-after-free vulnerability in the Linux kernel's HackRF media driver that occurs due to improper memory management during device registration. The vulnerability allows local attackers with file descriptor access to trigger UAF and double-free conditions through race conditions between probe error handling and device release operations. With a CVSS score of 7.8, this poses a significant risk for systems running affected kernel versions with HackRF hardware or drivers loaded.
Immediate Actions:
1. Identify systems running Linux kernel versions with HackRF driver support
2. Check if HackRF hardware or drivers are actively loaded: lsmod | grep hackrf
3. Restrict local access to HackRF devices using file permissions and SELinux policies
Patching Guidance:
1. Apply the latest Linux kernel patch that resolves the memory management issue in hackrf_probe()
2. Ensure the fix modifies memory deallocation to occur only through release() rather than kfree() on error paths
3. Test patches in non-production environments before deployment
4. Prioritize patching for systems with HackRF hardware attached
Compensating Controls (if immediate patching unavailable):
1. Disable HackRF driver module: modprobe -r hackrf
2. Remove HackRF hardware from systems if not actively required
3. Implement strict access controls to /dev/video* devices
4. Use AppArmor or SELinux to restrict ioctl operations on video devices
5. Monitor for suspicious ioctl calls: auditctl -w /dev/video* -p x -k hackrf_monitor
Detection Rules:
1. Monitor for UAF-related kernel panics in dmesg logs
2. Alert on multiple rapid open/close cycles on /dev/video* devices
3. Track failed ioctl operations on video devices from unprivileged users
4. Monitor kernel memory corruption indicators and KASAN warnings
الإجراءات الفورية:
1. تحديد الأنظمة التي تقوم بتشغيل إصدارات نواة Linux مع دعم مشغل HackRF
2. التحقق مما إذا كان جهاز HackRF أو المشغلات محملة بنشاط: lsmod | grep hackrf
3. تقييد الوصول المحلي إلى أجهزة HackRF باستخدام أذونات الملفات وسياسات SELinux
إرشادات التصحيح:
1. تطبيق أحدث تصحيح نواة Linux الذي يحل مشكلة إدارة الذاكرة في hackrf_probe()
2. التأكد من أن الإصلاح يعدل إلغاء تخصيص الذاكرة ليحدث فقط من خلال release() وليس kfree() في مسارات الخطأ
3. اختبار التصحيحات في بيئات غير الإنتاج قبل النشر
4. إعطاء الأولوية لتصحيح الأنظمة التي تحتوي على أجهزة HackRF المرفقة
الضوابط البديلة (إذا لم يكن التصحيح الفوري متاحاً):
1. تعطيل وحدة مشغل HackRF: modprobe -r hackrf
2. إزالة أجهزة HackRF من الأنظمة إذا لم تكن مطلوبة بنشاط
3. تنفيذ ضوابط وصول صارمة على أجهزة /dev/video*
4. استخدام AppArmor أو SELinux لتقييد عمليات ioctl على أجهزة الفيديو
5. مراقبة استدعاءات ioctl المريبة: auditctl -w /dev/video* -p x -k hackrf_monitor
قواعد الكشف:
1. مراقبة حالات الذعر في النواة المتعلقة بـ UAF في سجلات dmesg
2. التنبيه على دورات فتح/إغلاق سريعة متعددة على أجهزة /dev/video*
3. تتبع عمليات ioctl الفاشلة على أجهزة الفيديو من المستخدمين غير المميزين
4. مراقبة مؤشرات تلف ذاكرة النواة وتحذيرات KASAN