From: Xiang Mei <xmei5@asu.edu>
To: mkl@pengutronix.de, mailhol@kernel.org, linux-can@vger.kernel.org
Cc: s.grosjean@peak-system.fr, co+5e2bcf11e7027510@bugs.sh,
Xiang Mei <xmei5@asu.edu>
Subject: [PATCH net] can: peak_usb: fix slab-out-of-bounds read in pcan_usb_handle_bus_evt()
Date: Sun, 6 Sep 2026 15:21:31 -0700 [thread overview]
Message-ID: <20260906222132.3850994-1-xmei5@asu.edu> (raw)
pcan_usb_handle_bus_evt() reads mc->ptr[1] and mc->ptr[2] without checking
them against mc->end. On entry mc->ptr may already equal mc->end, and the
rx buffer is an exact kmalloc(64), so a device sending a full 64-byte
transfer reads past the slab object.
The two bytes end up in pdev->bec, which user space can read back via
IFLA_CAN_BERR_COUNTER.
Bail out unless both bytes are within the buffer.
BUG: KASAN: slab-out-of-bounds in pcan_usb_decode_buf (drivers/net/can/usb/peak_usb/pcan_usb.c:563)
Read of size 1 at addr ffff8880100921c1 by task swapper/1/0
Call Trace:
<IRQ>
kasan_report (mm/kasan/report.c:595)
pcan_usb_decode_buf (drivers/net/can/usb/peak_usb/pcan_usb.c:563)
peak_usb_read_bulk_callback (drivers/net/can/usb/peak_usb/pcan_usb_core.c:267)
__usb_hcd_giveback_urb (drivers/usb/core/hcd.c:1657)
dummy_timer (drivers/usb/gadget/udc/dummy_hcd.c:2019)
__hrtimer_run_queues (kernel/time/hrtimer.c:2067)
handle_softirqs (kernel/softirq.c:645)
</IRQ>
The buggy address is located 1 bytes to the right of
allocated 64-byte region [ffff888010092180, ffff8880100921c0)
Fixes: ea8b33bde76c ("can: pcan_usb: add support of rxerr/txerr counters")
Reported-by: co+5e2bcf11e7027510@bugs.sh
Closes: https://lore.kernel.org/linux-can/upsCxxaJjg2FJWhfCx6KjFXLlh8o4IhaHKJi@bugs.sh/
Assisted-by: Claude:claude-opus-4-8
Signed-off-by: Xiang Mei <xmei5@asu.edu>
---
drivers/net/can/usb/peak_usb/pcan_usb.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/can/usb/peak_usb/pcan_usb.c b/drivers/net/can/usb/peak_usb/pcan_usb.c
index 8fd058c32856..e87ed7657cc1 100644
--- a/drivers/net/can/usb/peak_usb/pcan_usb.c
+++ b/drivers/net/can/usb/peak_usb/pcan_usb.c
@@ -558,6 +558,8 @@ static int pcan_usb_handle_bus_evt(struct pcan_usb_msg_context *mc, u8 ir)
switch (ir) {
case PCAN_USB_ERR_CNT_DEC:
case PCAN_USB_ERR_CNT_INC:
+ if ((mc->ptr + 3) > mc->end)
+ return -EINVAL;
/* save rx/tx error counters from in the device context */
pdev->bec.rxerr = mc->ptr[1];
--
2.43.0
next reply other threads:[~2026-09-06 22:21 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-06 22:21 Xiang Mei [this message]
2026-09-06 22:36 ` [PATCH net] can: peak_usb: fix slab-out-of-bounds read in pcan_usb_handle_bus_evt() sashiko-bot
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260906222132.3850994-1-xmei5@asu.edu \
--to=xmei5@asu.edu \
--cc=co+5e2bcf11e7027510@bugs.sh \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=s.grosjean@peak-system.fr \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox