From: sashiko-bot@kernel.org
To: "Marc Kleine-Budde" <mkl@pengutronix.de>
Cc: linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>,
"Vincent Mailhol" <mailhol@kernel.org>,
"Oleksij Rempel" <o.rempel@pengutronix.de>
Subject: Re: [PATCH net-next 12/12] can: xilinx_can: set CAN FD flags on received frames
Date: Thu, 19 Nov 2026 09:32:30 +0000 [thread overview]
Message-ID: <sashiko-outbox-222854@kernel.org> (raw)
In-Reply-To: <20261118092955.1283165-13-mkl@pengutronix.de>
Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] can: xilinx_can: uninitialized data leak in xcanfd_rx() [1]
--
commit d0681f7cdc97d2a1c4872665c855ad2b34da35d9
Author: Maximilian Zimmermann <maxz@spacecubics.com>
can: xilinx_can: set CAN FD flags on received frames
This commit adds the ESI register mask and sets the CANFD_BRS and
CANFD_ESI flags in struct canfd_frame when receiving CAN FD frames.
Link: https://patch.msgid.link/20260921-fix-xilinx-canfd-flags-v1-1-a371c90b4e7c@spacecubics.com
> diff --git a/drivers/net/can/xilinx_can.c b/drivers/net/can/xilinx_can.c
> index 43d7f22820b88..52661e0882054 100644
> --- a/drivers/net/can/xilinx_can.c
> +++ b/drivers/net/can/xilinx_can.c
[ ... ]
> @@ -959,6 +960,11 @@ static int xcanfd_rx(struct net_device *ndev, int frame_base)
>
> /* Check the frame received is FD or not*/
> if (dlc & XCAN_DLCR_EDL_MASK) {
> + if (dlc & XCAN_DLCR_BRS_MASK)
> + cf->flags |= CANFD_BRS;
> + if (dlc & XCAN_DLCR_ESI_MASK)
> + cf->flags |= CANFD_ESI;
> +
> for (i = 0; i < cf->len; i += 4) {
> dw_offset = XCANFD_FRAME_DW_OFFSET(frame_base) +
> (dwindex * XCANFD_DW_BYTES);
[Severity: Critical]
This problem wasn't introduced by this patch, but can the payload copy
loops in xcanfd_rx() and xcan_rx() leak residual hardware register bytes to
userspace [1]?
alloc_can_skb() and alloc_canfd_skb() zero-initialize cf->data, but both
receive paths write full 32-bit words into cf->data:
drivers/net/can/xilinx_can.c:xcanfd_rx() {
...
for (i = 0; i < cf->len; i += 4) {
dw_offset = XCANFD_FRAME_DW_OFFSET(frame_base) +
(dwindex * XCANFD_DW_BYTES);
data[0] = priv->read_reg(priv, dw_offset);
*(__be32 *)(cf->data + i) = cpu_to_be32(data[0]);
dwindex++;
}
...
}
When cf->len is not a multiple of 4 bytes, the final 32-bit store
overwrites the zeroed trailing padding with leftover bytes from the
hardware register, which are then copied to userspace on raw CAN socket
reads.
[1] https://sashiko.dev/#/bug/linux-32f289b3-a2b0-4d94-a883-7cfaa1d3ff70
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261118092955.1283165-1-mkl@pengutronix.de?part=12
prev parent reply other threads:[~2026-11-19 9:32 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-18 9:11 [PATCH net-next 0/12] pull-request: can-next 2026-11-18 Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 01/12] MAINTAINERS: add entry for PEAK-System CAN drivers Marc Kleine-Budde
2026-11-18 9:38 ` netdev-bot+sinfo
2026-11-18 9:45 ` Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 02/12] can: raw: remove redundant NULL check before netdev_hold() Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 03/12] can: dev: remove unused safe_candev_priv() Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 04/12] can: convert to DEFINE_SIMPLE_DEV_PM_OPS() Marc Kleine-Budde
2026-11-19 9:54 ` netdev-bot+sashiko
2026-11-18 9:11 ` [PATCH net-next 05/12] can: cc770: don't discard the IRQ lookup error in probe Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 06/12] can: sun4i_can: " Marc Kleine-Budde
2026-11-19 9:32 ` sashiko-bot
2026-11-19 9:37 ` Marc Kleine-Budde
2026-11-19 9:54 ` netdev-bot+sashiko
2026-11-18 9:11 ` [PATCH net-next 07/12] can: at91_can: " Marc Kleine-Budde
2026-11-19 9:54 ` netdev-bot+sashiko
2026-11-18 9:11 ` [PATCH net-next 08/12] can: janz-ican3: " Marc Kleine-Budde
2026-11-19 9:54 ` netdev-bot+sashiko
2026-11-18 9:11 ` [PATCH net-next 09/12] can: ifi_canfd: " Marc Kleine-Budde
2026-11-19 9:54 ` netdev-bot+sashiko
2026-11-18 9:11 ` [PATCH net-next 10/12] can: remove Softing CANcard driver Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 11/12] can: ucan: fix repeated word 'is' in comment Marc Kleine-Budde
2026-11-18 9:11 ` [PATCH net-next 12/12] can: xilinx_can: set CAN FD flags on received frames Marc Kleine-Budde
2026-11-19 9:32 ` 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=sashiko-outbox-222854@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 \
/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