{"id":"CVE-2026-31769","state":"PUBLISHED","title":"gpib: fix use-after-free in IO ioctl handlers","description":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpib: fix use-after-free in IO ioctl handlers\n\nThe IBRD, IBWRT, IBCMD, and IBWAIT ioctl handlers use a gpib_descriptor\npointer after board->big_gpib_mutex has been released.  A concurrent\nIBCLOSEDEV ioctl can free the descriptor via close_dev_ioctl() during\nthis window, causing a use-after-free.\n\nThe IO handlers (read_ioctl, write_ioctl, command_ioctl) explicitly\nrelease big_gpib_mutex before calling their handler.  wait_ioctl() is\ncalled with big_gpib_mutex held, but ibwait() releases it internally\nwhen wait_mask is non-zero.  In all four cases, the descriptor pointer\nobtained from handle_to_descriptor() becomes unprotected.\n\nFix this by introducing a kernel-only descriptor_busy reference count\nin struct gpib_descriptor.  Each handler atomically increments\ndescriptor_busy under file_priv->descriptors_mutex before releasing the\nlock, and decrements it when done.  close_dev_ioctl() checks\ndescriptor_busy under the same lock and rejects the close with -EBUSY\nif the count is non-zero.\n\nA reference count rather than a simple flag is necessary because\nmultiple handlers can operate on the same descriptor concurrently\n(e.g. IBRD and IBWAIT on the same handle from different threads).\n\nA separate counter is needed because io_in_progress can be cleared from\nunprivileged userspace via the IBWAIT ioctl (through general_ibstatus()\nwith set_mask containing CMPL), which would allow an attacker to bypass\na check based solely on io_in_progress.  The new descriptor_busy\ncounter is only modified by the kernel IO paths.\n\nThe lock ordering is consistent (big_gpib_mutex -> descriptors_mutex)\nand the handlers only hold descriptors_mutex briefly during the lookup,\nso there is no deadlock risk and no impact on IO throughput.","publishedAt":"2026-05-01T14:14:58.617Z","updatedAt":"2026-08-05T12:25:02.500Z","severity":{"score":7.8,"label":"High","version":"3.1","vector":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","source":"Linux"},"assigner":"Linux","products":["Linux Linux"],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"cae26eff1b56d78bed7873cf3e60a2b1bdd4da6c","versionType":"git"},{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"28c75dd143ead62e0dfac564c79d251e21d5d74b","versionType":"git"},{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"d1857f8296dceb75d00ab857fc3c61bc00c7f5c6","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpib/common/gpib_os.c","drivers/gpib/include/gpib_types.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.13","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.13","versionType":"semver"},{"version":"6.18.22","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.12","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpib/common/gpib_os.c","drivers/gpib/include/gpib_types.h"]}],"references":["https://git.kernel.org/stable/c/cae26eff1b56d78bed7873cf3e60a2b1bdd4da6c","https://git.kernel.org/stable/c/28c75dd143ead62e0dfac564c79d251e21d5d74b","https://git.kernel.org/stable/c/d1857f8296dceb75d00ab857fc3c61bc00c7f5c6"],"weaknesses":[],"ingestedAt":"2026-10-29T20:11:40.391Z","source":{"repository":"CVEProject/cvelistV5","path":"cves/2026/31xxx/CVE-2026-31769.json","commit":"556c9d3a8cd17e218bb8e452ba7cd619a384ff47"},"raw":{"dataType":"CVE_RECORD","dataVersion":"5.2","cveMetadata":{"cveId":"CVE-2026-31769","state":"PUBLISHED","datePublished":"2026-05-01T14:14:58.617Z","dateUpdated":"2026-08-05T12:25:02.500Z","assignerShortName":"Linux","assignerOrgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateReserved":"2026-03-09T15:48:24.140Z"},"containers":{"cna":{"title":"gpib: fix use-after-free in IO ioctl handlers","descriptions":[{"lang":"en","value":"In the Linux kernel, the following vulnerability has been resolved:\n\ngpib: fix use-after-free in IO ioctl handlers\n\nThe IBRD, IBWRT, IBCMD, and IBWAIT ioctl handlers use a gpib_descriptor\npointer after board->big_gpib_mutex has been released.  A concurrent\nIBCLOSEDEV ioctl can free the descriptor via close_dev_ioctl() during\nthis window, causing a use-after-free.\n\nThe IO handlers (read_ioctl, write_ioctl, command_ioctl) explicitly\nrelease big_gpib_mutex before calling their handler.  wait_ioctl() is\ncalled with big_gpib_mutex held, but ibwait() releases it internally\nwhen wait_mask is non-zero.  In all four cases, the descriptor pointer\nobtained from handle_to_descriptor() becomes unprotected.\n\nFix this by introducing a kernel-only descriptor_busy reference count\nin struct gpib_descriptor.  Each handler atomically increments\ndescriptor_busy under file_priv->descriptors_mutex before releasing the\nlock, and decrements it when done.  close_dev_ioctl() checks\ndescriptor_busy under the same lock and rejects the close with -EBUSY\nif the count is non-zero.\n\nA reference count rather than a simple flag is necessary because\nmultiple handlers can operate on the same descriptor concurrently\n(e.g. IBRD and IBWAIT on the same handle from different threads).\n\nA separate counter is needed because io_in_progress can be cleared from\nunprivileged userspace via the IBWAIT ioctl (through general_ibstatus()\nwith set_mask containing CMPL), which would allow an attacker to bypass\na check based solely on io_in_progress.  The new descriptor_busy\ncounter is only modified by the kernel IO paths.\n\nThe lock ordering is consistent (big_gpib_mutex -> descriptors_mutex)\nand the handlers only hold descriptors_mutex briefly during the lookup,\nso there is no deadlock risk and no impact on IO throughput."}],"affected":[{"vendor":"Linux","product":"Linux","defaultStatus":"unaffected","versions":[{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"cae26eff1b56d78bed7873cf3e60a2b1bdd4da6c","versionType":"git"},{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"28c75dd143ead62e0dfac564c79d251e21d5d74b","versionType":"git"},{"version":"9dde4559e93955ccc47d588f7fd051684d55c4e7","status":"affected","lessThan":"d1857f8296dceb75d00ab857fc3c61bc00c7f5c6","versionType":"git"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpib/common/gpib_os.c","drivers/gpib/include/gpib_types.h"]},{"vendor":"Linux","product":"Linux","defaultStatus":"affected","versions":[{"version":"6.13","status":"affected"},{"version":"0","status":"unaffected","lessThan":"6.13","versionType":"semver"},{"version":"6.18.22","status":"unaffected","lessThanOrEqual":"6.18.*","versionType":"semver"},{"version":"6.19.12","status":"unaffected","lessThanOrEqual":"6.19.*","versionType":"semver"},{"version":"7.0","status":"unaffected","lessThanOrEqual":"*","versionType":"original_commit_for_fix"}],"repo":"https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git","programFiles":["drivers/gpib/common/gpib_os.c","drivers/gpib/include/gpib_types.h"]}],"references":[{"url":"https://git.kernel.org/stable/c/cae26eff1b56d78bed7873cf3e60a2b1bdd4da6c"},{"url":"https://git.kernel.org/stable/c/28c75dd143ead62e0dfac564c79d251e21d5d74b"},{"url":"https://git.kernel.org/stable/c/d1857f8296dceb75d00ab857fc3c61bc00c7f5c6"}],"metrics":[{"cvssV3_1":{"version":"3.1","vectorString":"CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:H","baseScore":7.8,"baseSeverity":"HIGH"},"scenarios":[{"lang":"en","value":"AV:L - The vulnerable code is reached through local `/dev/gpibN` character-device ioctls such as `IBRD`, `IBWRT`, `IBCMD`, `IBWAIT`, and `IBCLOSEDEV`. There is no network, adjacent, or physical packet-processing entry point for this bug.\nAC:L - The attacker controls both sides of the race by issuing concurrent ioctls on the same GPIB file descriptor and handle. Use-after-free triggering does not depend on conditions outside attacker control once the board is online and accessible.\nPR:L - The vulnerable ioctls do not perform capability checks; a local user with access to the GPIB device node can open a descriptor, run IO or wait operations, and concurrently close it. Administrative privileges are needed for board configuration, but not for the vulnerable open/close/IO path in a configured deployment.\nUI:N - No victim action is required after the attacker has local access to the device. Exploitation is performed entirely by attacker-controlled ioctl calls.\nS:U - The bug is a kernel use-after-free reachable from a local kernel device interface and impacts the same kernel security authority. It does not cross a virtualization, IOMMU, or separate security-scope boundary.\nC:H - This is a kernel heap use-after-free of `struct gpib_descriptor`, and freed object reuse can expose or help derive kernel memory contents. Following the required kernel guidance, use-after-free bugs are scored as high confidentiality impact.\nI:H - The stale descriptor pointer is dereferenced after free and can be overlapped through heap reuse, giving a plausible path to corrupt kernel data or build write/control-flow primitives. Following the required kernel guidance, use-after-free bugs are scored as high integrity impact.\nA:H - The stale pointer can be dereferenced after `kfree()` during IO or wait completion, making kernel oops, panic, or hang plausible. Use-after-free bugs are therefore high availability impact."}]}],"providerMetadata":{"shortName":"Linux","orgId":"416baaa9-dc9f-4396-8d5f-8c081fb06d67","dateUpdated":"2026-08-05T12:25:02.500Z"},"cpeApplicability":[{"nodes":[{"operator":"OR","negate":false,"cpeMatch":[{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.13","versionEndExcluding":"6.18.22"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.13","versionEndExcluding":"6.19.12"},{"vulnerable":true,"criteria":"cpe:2.3:o:linux:linux_kernel:*:*:*:*:*:*:*:*","versionStartIncluding":"6.13","versionEndExcluding":"7.0"}]}]}],"x_generator":{"engine":"bippy-1.2.0"}}}}}