Linux CAN drivers development
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Stéphane Grosjean" <stephane.grosjean@free.fr>
Cc: linux-can@vger.kernel.org, "Vincent Mailhol" <mailhol@kernel.org>,
	"Oliver Hartkopp" <socketcan@hartkopp.net>,
	"Marc Kleine-Budde" <mkl@pengutronix.de>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH] can: peak_usb: Add bus error reporting for the PCAN-USB FD family
Date: Tue, 29 Sep 2026 14:15:02 +0000	[thread overview]
Message-ID: <20260929141503.645871F000FF@smtp.kernel.org> (raw)
In-Reply-To: <20260929-peak_usb-canfd-berr-v1-1-7abd585f877f@peak-system.fr>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] can: peak_usb: NULL pointer dereference in pcan_usb_fd_decode_error()
--

commit 19614d59ec182f3f690df8a2b9505f478b56815e
Author: Stéphane Grosjean <s.grosjean@peak-system.fr>

can: peak_usb: Add bus error reporting for the PCAN-USB FD family

This commit adds CAN bus error reporting for PEAK-System USB-to-CAN FD
devices by enabling firmware bus error notifications per channel.

> diff --git a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> index 0d46f4ce5dca7..fdd38908b4c37 100644
> --- a/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> +++ b/drivers/net/can/usb/peak_usb/pcan_usb_fd.c
> @@ -661,6 +661,9 @@ static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if,
>  	struct pucan_error_msg *er = (struct pucan_error_msg *)rx_msg;
>  	struct pcan_usb_fd_device *pdev;
>  	struct peak_usb_device *dev;
> +	struct can_frame *cf;
> +	struct sk_buff *skb;
> +	u8 can_err_tx = 0;
>  
>  	if (pucan_ermsg_get_channel(er) >= ARRAY_SIZE(usb_if->dev))
>  		return -EINVAL;

[Severity: High]
Does this bounds check adequately protect against accessing an uninitialized
channel? Since ARRAY_SIZE(usb_if->dev) is statically 2, if an untrusted
single-channel adapter sends a PUCAN_MSG_ERROR message with channel index 1,
the bounds check passes but the fetched usb_if->dev[1] pointer could be NULL.

> @@ -672,6 +675,53 @@ static int pcan_usb_fd_decode_error(struct pcan_usb_fd_if *usb_if,
>  	pdev->bec.txerr = er->tx_err_cnt;
>  	pdev->bec.rxerr = er->rx_err_cnt;
>  
> +	/* ignore non-CAN error notifications */
> +	if (PUCAN_ERMSG_TYPE(er) > PUCAN_ERMSG_OTHER_ERROR)
> +		return 0;
> +
> +	/* update other errors counters */
> +	dev->can.can_stats.bus_error++;

[Severity: High]
If the fetched dev pointer is NULL as described above, will this addition
cause a kernel panic when dereferencing dev? Could a maliciously crafted USB
peripheral exploit this to cause a denial of service?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260929-peak_usb-canfd-berr-v1-1-7abd585f877f@peak-system.fr?part=1

      reply	other threads:[~2026-09-29 14:15 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-29 14:01 [PATCH] can: peak_usb: Add bus error reporting for the PCAN-USB FD family Stéphane Grosjean
2026-09-29 14:15 ` 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=20260929141503.645871F000FF@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=sashiko-reviews@lists.linux.dev \
    --cc=socketcan@hartkopp.net \
    --cc=stephane.grosjean@free.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