| d1857f82 | 17-Mar-2026 |
Adam Crosser <adam.crosser@praetorian.com> |
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
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.
Signed-off-by: Adam Crosser <adam.crosser@praetorian.com> Cc: stable <stable@kernel.org> Reviewed-by: Dave Penkler <dpenkler@gmail.com> Tested-by: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 5cefb52c | 10-Mar-2026 |
Johan Hovold <johan@kernel.org> |
gpib: lpvo_usb: fix memory leak on disconnect
The driver iterates over the registered USB interfaces during GPIB attach and takes a reference to their USB devices until a match is found. These refer
gpib: lpvo_usb: fix memory leak on disconnect
The driver iterates over the registered USB interfaces during GPIB attach and takes a reference to their USB devices until a match is found. These references are never released which leads to a memory leak when devices are disconnected.
Fix the leak by dropping the unnecessary references.
Fixes: fce79512a96a ("staging: gpib: Add LPVO DIY USB GPIB driver") Cc: stable <stable@kernel.org> # 6.13 Cc: Dave Penkler <dpenkler@gmail.com> Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260310105127.17538-1-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 678f946b | 05-Mar-2026 |
Johan Hovold <johan@kernel.org> |
gpib: ni_usb: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take addit
gpib: ni_usb: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260305102745.12032-3-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| d35da40e | 05-Mar-2026 |
Johan Hovold <johan@kernel.org> |
gpib: agilent_82357a: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to ta
gpib: agilent_82357a: drop redundant device reference
Driver core holds a reference to the USB interface and its parent USB device while the interface is bound to a driver and there is no need to take additional references unless the structures are needed after disconnect.
Drop the redundant device reference to reduce cargo culting, make it easier to spot drivers where an extra reference is needed, and reduce the risk of memory leaks when drivers fail to release it.
Signed-off-by: Johan Hovold <johan@kernel.org> Link: https://patch.msgid.link/20260305102745.12032-2-johan@kernel.org Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 04576813 | 03-Mar-2026 |
Jori Koolstra <jkoolstra@xs4all.nl> |
gpib: common: change gpib_class to a const struct
The class_create() call has been deprecated in favor of class_register() as the driver core now allows for a struct class to be in read-only memory.
gpib: common: change gpib_class to a const struct
The class_create() call has been deprecated in favor of class_register() as the driver core now allows for a struct class to be in read-only memory. Change gpib_class to be a const struct class and drop the class_create() call.
Link: https://lore.kernel.org/all/2023040244-duffel-pushpin-f738@gregkh/
Suggested-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> Signed-off-by: Jori Koolstra <jkoolstra@xs4all.nl> Link: https://patch.msgid.link/20260303192124.3855792-1-jkoolstra@xs4all.nl Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 42df3a51 | 31-Jan-2026 |
Ethan Nelson-Moore <enelsonmoore@gmail.com> |
gpib: remove unnecessary module_init/exit functions
Two GPIB drivers have unnecessary empty module_init and module_exit functions. Remove them. Note that if a module_init function exists, a module_e
gpib: remove unnecessary module_init/exit functions
Two GPIB drivers have unnecessary empty module_init and module_exit functions. Remove them. Note that if a module_init function exists, a module_exit function must also exist; otherwise, the module cannot be unloaded.
Signed-off-by: Ethan Nelson-Moore <enelsonmoore@gmail.com> Link: https://patch.msgid.link/20260131014152.35875-1-enelsonmoore@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 3df1fd31 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: tnt4882: Unify *allocate_private usage
Use the return value of tnt4882_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <domini
gpib: tnt4882: Unify *allocate_private usage
Use the return value of tnt4882_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-28-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 9effb865 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: tnt4882: Unify *allocate_private return value
Return -ENOMEM instead of -1 in tnt4882_allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.k
gpib: tnt4882: Unify *allocate_private return value
Return -ENOMEM instead of -1 in tnt4882_allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-27-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| a16ad9b6 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: tnt4882: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in tnt4882_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piat
gpib: tnt4882: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in tnt4882_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-26-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| c2a9f77c | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: pc2: Unify *allocate_private usage
Use the return value of allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piat
gpib: pc2: Unify *allocate_private usage
Use the return value of allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-25-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 68de22e9 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: pc2: Unify *allocate_private return value
Return -ENOMEM instead of -1 in allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkow
gpib: pc2: Unify *allocate_private return value
Return -ENOMEM instead of -1 in allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-24-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 6e6dc3f7 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: pc2: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@proto
gpib: pc2: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-23-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 78047416 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: ni_usb: Fix the *allocate_private retval check
Change
if (retval < 0) return retval;
into
if (retval) return retval;
as it is more fitting in this case.
Signed-off-by: Dom
gpib: ni_usb: Fix the *allocate_private retval check
Change
if (retval < 0) return retval;
into
if (retval) return retval;
as it is more fitting in this case.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-22-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 64900aa8 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: ni_usb: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in ni_usb_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatko
gpib: ni_usb: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in ni_usb_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-21-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 11f1b169 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: ines: Unify *allocate_private usage
Use the return value of ines_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karo
gpib: ines: Unify *allocate_private usage
Use the return value of ines_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-20-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 24d4d06a | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: ines: Unify *allocate_private return value
Return -ENOMEM instead of -1 in ines_allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.p
gpib: ines: Unify *allocate_private return value
Return -ENOMEM instead of -1 in ines_allocate_private in case of memory allocation failure.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-19-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| b3d3ab10 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: ines: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in ines_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski
gpib: ines: Replace kmalloc/memset to kzalloc in *allocate_private
Replace kmalloc/memset pair to kzalloc in ines_allocate_private.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-18-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|
| 3f5d8316 | 16-Jan-2026 |
Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> |
gpib: hp_82341: Unify *allocate_private usage
Use the return value of hp_82341_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <domi
gpib: hp_82341: Unify *allocate_private usage
Use the return value of hp_82341_allocate_private in calling code as early return value in case of error.
Signed-off-by: Dominik Karol Piątkowski <dominik.karol.piatkowski@protonmail.com> Link: https://patch.msgid.link/20260116174647.317256-17-dominik.karol.piatkowski@protonmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
show more ...
|