All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Ciprian Costea" <ciprianmarian.costea@oss.nxp.com>
Cc: linux-can@vger.kernel.org, imx@lists.linux.dev,
	"Oliver Hartkopp" <socketcan@hartkopp.net>,
	"Vincent Mailhol" <mailhol@kernel.org>,
	"Oleksij Rempel" <o.rempel@pengutronix.de>,
	Frank.Li@kernel.org, "Marc Kleine-Budde" <mkl@pengutronix.de>
Subject: Re: [PATCH v3 1/2] can: rx-offload: make skb_irq_queue per-CPU
Date: Tue, 01 Sep 2026 10:57:20 +0000	[thread overview]
Message-ID: <20260901105721.18EBD1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260901104103.458619-2-ciprianmarian.costea@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [High] Ignoring the return value of can_rx_offload_add_manual() leads to a kernel panic in gs_usb if per-CPU allocation fails.
--

commit d8e59325c82aef9b3489bcce81a1a5ee64835783
Author: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>

can: rx-offload: make skb_irq_queue per-CPU

This patch converts skb_irq_queue to a per-CPU allocation to fix concurrent
list enqueueing issues on platforms with multiple mailboxes affined to
different CPUs.

> diff --git a/drivers/net/can/dev/rx-offload.c b/drivers/net/can/dev/rx-offload.c
> index 46e7b6db4a1ef..649bfda08b654 100644
> --- a/drivers/net/can/dev/rx-offload.c
> +++ b/drivers/net/can/dev/rx-offload.c
[ ... ]
> @@ -353,13 +391,21 @@ static int can_rx_offload_init_queue(struct net_device *dev,
>  				     struct can_rx_offload *offload,
>  				     unsigned int weight)
>  {
[ ... ]
> -	__skb_queue_head_init(&offload->skb_irq_queue);
> +
> +	offload->skb_irq_queue = alloc_percpu(struct sk_buff_head);
> +	if (!offload->skb_irq_queue)
> +		return -ENOMEM;
> +

[Severity: High]
Does this new error path cause a kernel panic in drivers that ignore the
return value of can_rx_offload_add_manual()?

Looking at gs_make_candev() in drivers/net/can/usb/gs_usb.c, it does not
check the return value of can_rx_offload_add_manual(). If alloc_percpu()
fails here, the gs_usb driver proceeds with registration.

When a frame is later received, can_rx_offload_queue_tail() uses
get_cpu_ptr(offload->skb_irq_queue). Passing a NULL pointer to get_cpu_ptr()
results in an invalid pointer (0 + per-CPU offset), leading to a crash when
it is unconditionally dereferenced by __skb_queue_tail().

I note an identical issue in at91_can.c was addressed in a subsequent patch
("can: at91_can: fix rx-offload cleanup on unbind and probe errors"), but it
appears gs_usb.c was missed.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260901104103.458619-1-ciprianmarian.costea@oss.nxp.com?part=1

  reply	other threads:[~2026-09-01 10:57 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-01 10:41 [PATCH v3 0/2] can: rx-offload: make skb_irq_queue per-CPU Ciprian Costea
2026-09-01 10:41 ` [PATCH v3 1/2] " Ciprian Costea
2026-09-01 10:57   ` sashiko-bot [this message]
2026-09-01 11:30     ` Ciprian Marian Costea
2026-09-01 10:41 ` [PATCH v3 2/2] can: at91_can: fix rx-offload cleanup on unbind and probe errors Ciprian Costea

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=20260901105721.18EBD1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=ciprianmarian.costea@oss.nxp.com \
    --cc=imx@lists.linux.dev \
    --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 \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.