KernelScan.io

HIGH

gpib Descriptor UAF

CVE-2026-31769

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: gpib: fix use-after-free in IO ioctl handlers The IBRD, IBWRT, IBCMD, and IBWAIT ioctl handlers use a gpib_descriptor pointer after board->big_gpib_mutex has been released. A concurrent IBCLOSEDEV ioctl can free the descriptor via close_dev_ioctl() during this window, causing a use-after-free. The IO handlers (read_ioctl, write_ioctl, command_ioctl) explicitly release big_gpib_mutex before calling their handler. wait_ioctl() is called with big_gpib_mutex held, but ibwait() releases it internally when wait_mask is non-zero. In all four cases, the descriptor pointer obtained from handle_to_descriptor() becomes unprotected. Fix this by introducing a kernel-only descriptor_busy reference count in struct gpib_descriptor. Each handler atomically increments descriptor_busy under file_priv->descriptors_mutex before releasing the lock, and decrements it when done. close_dev_ioctl() checks descriptor_busy under the same lock and rejects the close with -EBUSY if the count is non-zero. A reference count rather than a simple flag is necessary because multiple handlers can operate on the same descriptor concurrently (e.g. IBRD and IBWAIT on the same handle from different threads). A separate counter is needed because io_in_progress can be cleared from unprivileged userspace via the IBWAIT ioctl (through general_ibstatus() with set_mask containing CMPL), which would allow an attacker to bypass a check based solely on io_in_progress. The new descriptor_busy counter is only modified by the kernel IO paths. The lock ordering is consistent (big_gpib_mutex -> descriptors_mutex) and the handlers only hold descriptors_mutex briefly during the lookup, so there is no deadlock risk and no impact on IO throughput.

02

Engine v0.2.0

Risk summary

A local attacker with access to GPIB devices can trigger a use-after-free vulnerability by racing IO operations against device close operations. This could lead to kernel memory corruption, system crashes, or potentially privilege escalation. The vulnerability affects systems using GPIB (General Purpose Interface Bus) hardware for instrument control.

Affecteddrivers/gpib/common/gpib_os.c

Vulnerability analysis

Root Cause: The GPIB ioctl handlers (IBRD, IBWRT, IBCMD, IBWAIT) obtain a gpib_descriptor pointer via handle_to_descriptor() while holding board->big_gpib_mutex, but then release this mutex before performing IO operations. During this window, a concurrent IBCLOSEDEV ioctl can free the descriptor via close_dev_ioctl(), creating a use-after-free condition when the IO handlers subsequently access the freed descriptor pointer.

Attack Surface: This vulnerability requires local access with the ability to open GPIB device files and issue ioctl commands. An attacker would need to create multiple threads to race GPIB IO operations against device close operations. The attack requires specific timing to exploit the window between mutex release and descriptor usage in the IO handlers.

Fix Mechanism: The fix introduces a kernel-only atomic reference counter (descriptor_busy) in struct gpib_descriptor. IO handlers atomically increment this counter under file_priv->descriptors_mutex before releasing the big_gpib_mutex, and decrement it when done. The close_dev_ioctl() function checks this counter and returns -EBUSY if non-zero, preventing descriptor deallocation while IO operations are in progress. This provides proper lifetime management for descriptors across concurrent operations.

03

BranchFixed inPatch commit
6.186.18.22cae26eff1b56
6.196.19.1228c75dd143ea
mainline7.0d1857f8296dc