[PATCH v2 0/5] can: peak_usb: fixes, cleanup and input validation hardening
From: Stéphane Grosjean
Date: Fri Oct 09 2026 - 03:31:37 EST
This series contains a mix of bug fixes, cleanups, and hardening
improvements for the PEAK-System USB CAN drivers.
The first patch fixes a bug in CAN error frame generation where
CAN_ERR_CNT accidentally overwrites previously recorded CAN error
flags. As a result, information about previously detected error
conditions may be lost when error counters are reported.
The second and third patches are cleanup changes. One makes a public
header self-contained by including all required dependencies, while
the other reorders CAN_CTRLMODE_* flags in ctrlmode_supported for
improved readability without changing driver behavior.
The remaining patches strengthen validation of data received from USB
devices. They verify device-provided CAN channel numbers before they
are used as array indexes and introduce additional bounds checking
when parsing received message buffers.
Malformed messages are now rejected consistently, preventing possible
out-of-bounds memory accesses caused by corrupted or otherwise
untrusted device input.
---
Changes in v2:
- Kill all pending RX URBs before unregistering sibling netdevs.
- Reject records targeting unavailable channels during device
initialization in rare corner cases involving malformed device
input.
- Link to v1: https://patch.msgid.link/20261008-canfd_check_channel_idx-v1-0-0a3bb82f4e09@xxxxxxxxxxxxxx
To: Marc Kleine-Budde <mkl@xxxxxxxxxxxxxx>
To: Vincent Mailhol <mailhol@xxxxxxxxxx>
To: Dan Carpenter <error27@xxxxxxxxx>
To: Wolfgang Grandegger <wg@xxxxxxxxxxxxxx>
Cc: Stéphane Grosjean <s.grosjean@xxxxxxxxxxxxxx>
Cc: linux-can@xxxxxxxxxxxxxxx
Cc: linux-kernel@xxxxxxxxxxxxxxx
---
Marc Kleine-Budde (1):
can: peak_usb: add missing includes
Stefan Günther (1):
can: peak_usb: fix missing CAN_ERR_FLAG when reporting error counters
Stéphane Grosjean (3):
can: peak_usb: sort ctrlmode_supported flags
can: peak_usb: validate channel numbers in PCAN-USB FD
can: peak_usb: harden PCAN-USB message validation
drivers/net/can/usb/peak_usb/pcan_usb.c | 29 ++++++----
drivers/net/can/usb/peak_usb/pcan_usb_core.c | 12 +++-
drivers/net/can/usb/peak_usb/pcan_usb_core.h | 6 ++
drivers/net/can/usb/peak_usb/pcan_usb_fd.c | 84 ++++++++++++++++++++++------
drivers/net/can/usb/peak_usb/pcan_usb_pro.c | 3 +-
5 files changed, 104 insertions(+), 30 deletions(-)
---
base-commit: a7bfaba4823e3c165bb2004c74eff7c096672bc7
change-id: 20261007-canfd_check_channel_idx-a4d7a1a1ee7d
Best regards,
--
Stéphane Grosjean <s.grosjean@xxxxxxxxxxxxxx>