From: sashiko-bot@kernel.org
To: "Pengpeng Hou" <pengpeng@iscas.ac.cn>
Cc: "Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Oleksij Rempel" <o.rempel@pengutronix.de>,
linux-can@vger.kernel.org
Subject: Re: [PATCH] can: peak_usb: validate response and receive record extents
Date: Sun, 30 Aug 2026 14:12:54 +0000 [thread overview]
Message-ID: <20260830141255.5B82D1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260830135942.19449-1-pengpeng@iscas.ac.cn>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] OOB Read/Write due to unvalidated DLC in CAN frame parsing.
--
commit 3a2ad6057d438a3e936d788c2a9ec4229e3c427c
Author: Pengpeng Hou <pengpeng@iscas.ac.cn>
can: peak_usb: validate response and receive record extents
This commit adds validation to ensure that both record headers and complete
declared records are present in the response and receive paths before
processing them. This prevents out-of-bounds access when parsing USB message
buffers.
> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
> index b6be8c19e537f..aaa5f4f7db191 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_pro.c
[ ... ]
> @@ -727,7 +740,14 @@ static int pcan_usb_pro_decode_buf(struct peak_usb_device *dev, struct urb *urb)
> msg_end = urb->transfer_buffer + urb->actual_length;
> rec_cnt = le16_to_cpu(*usb_msg.u.rec_cnt_rd);
> for (; rec_cnt > 0; rec_cnt--) {
> - union pcan_usb_pro_rec *pr = (union pcan_usb_pro_rec *)rec_ptr;
> + union pcan_usb_pro_rec *pr;
> +
> + if (rec_ptr >= msg_end) {
> + err = -EBADMSG;
> + break;
> + }
> +
> + pr = (union pcan_usb_pro_rec *)rec_ptr;
[Severity: High]
This is a pre-existing issue, but there appears to be an out-of-bounds read
and write in how these records are processed later in
pcan_usb_pro_handle_canmsg().
When handling a CAN message record from an untrusted USB device:
drivers/net/can/usb/peak_usb/pcan_usb_pro.c:pcan_usb_pro_handle_canmsg() {
...
can_frame->len = rx->len & 0x0f;
...
} else {
memcpy(can_frame->data, rx->data, can_frame->len);
...
}
If the device sends a message where rx->len & 0x0f is greater than 8, can
this result in an out-of-bounds write since can_frame->data is exactly 8
bytes long?
Could this also pass a malformed frame to userspace with a length greater
than 8, violating the classic CAN API contract?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260830135942.19449-1-pengpeng@iscas.ac.cn?part=1
prev parent reply other threads:[~2026-08-30 14:12 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-30 13:59 [PATCH] can: peak_usb: validate response and receive record extents Pengpeng Hou
2026-08-30 14:12 ` sashiko-bot [this message]
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=20260830141255.5B82D1F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=linux-can@vger.kernel.org \
--cc=mailhol@kernel.org \
--cc=mkl@pengutronix.de \
--cc=o.rempel@pengutronix.de \
--cc=pengpeng@iscas.ac.cn \
--cc=sashiko-reviews@lists.linux.dev \
--cc=socketcan@hartkopp.net \
/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