Linux CAN drivers development
 help / color / mirror / Atom feed
From: Ciprian Marian Costea <ciprianmarian.costea@oss.nxp.com>
To: sashiko-reviews@lists.linux.dev
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>,
	s32@nxp.com, imx@lists.linux.dev
Subject: Re: [PATCH v3 1/2] can: rx-offload: make skb_irq_queue per-CPU
Date: Tue, 1 Sep 2026 14:30:05 +0300	[thread overview]
Message-ID: <801df0c8-472f-43ef-8a24-0b3c64bfea20@oss.nxp.com> (raw)
In-Reply-To: <20260901105721.18EBD1F000E9@smtp.kernel.org>

On 9/1/2026 1:57 PM, sashiko-bot@kernel.org wrote:
> 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.
> 

Seems to be the same class issue as 'at91_can' one. Nice finding. I will
address it in V4.

Ciprian

  reply	other threads:[~2026-09-01 11:30 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
2026-09-01 11:30     ` Ciprian Marian Costea [this message]
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=801df0c8-472f-43ef-8a24-0b3c64bfea20@oss.nxp.com \
    --to=ciprianmarian.costea@oss.nxp.com \
    --cc=Frank.Li@kernel.org \
    --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=s32@nxp.com \
    --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