From: sashiko-bot@kernel.org
To: "Cunhao Lu" <1579567540@qq.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
linux-can@vger.kernel.org,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH v5 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure
Date: Fri, 31 Jul 2026 10:54:02 +0000 [thread overview]
Message-ID: <20260731105402.B7A451F000E9@smtp.kernel.org> (raw)
In-Reply-To: <tencent_C82C09E7235101CC88A97E154D2534183208@qq.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Out-of-bounds read and hardware register out-of-bounds write due to CAN XL frame mishandling.
--
--- Patch [1]: [PATCH v5 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure ---
commit 8df8ef3a7e1e7414d8117605f2f14ed295ef9ad1
Author: Cunhao Lu <1579567540@qq.com>
can: rockchip_canfd: prevent TX stall on echo skb failure
This patch prevents a TX stall by installing the echo skb before loading
the hardware TX buffer. If installation fails, it drops the frame and leaves
the hardware FIFO and software TX state unchanged. It correctly relies on the
echo skb as the source for hardware frame data after it is installed.
Link: https://lore.kernel.org/linux-can/tencent_944DADCC4B42C8484EC01DA2B15F42132906@qq.com
> diff --git a/drivers/net/can/rockchip/rockchip_canfd-tx.c b/drivers/net/can/rockchip/rockchip_canfd-tx.c
> index 12200dcfd3389..86fa8f2e1c8ba 100644
> --- a/drivers/net/can/rockchip/rockchip_canfd-tx.c
> +++ b/drivers/net/can/rockchip/rockchip_canfd-tx.c
[ ... ]
> @@ -114,7 +123,6 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> cfd->len);
> }
>
> - tx_head = rkcanfd_get_tx_head(priv);
> reg_cmd = RKCANFD_REG_CMD_TX_REQ(tx_head);
>
> rkcanfd_write(priv, RKCANFD_REG_FD_TXFRAMEINFO, reg_frameinfo);
> @@ -123,10 +131,7 @@ netdev_tx_t rkcanfd_start_xmit(struct sk_buff *skb, struct net_device *ndev)
> rkcanfd_write(priv, RKCANFD_REG_FD_TXDATA0 + i,
> *(u32 *)(cfd->data + i));
>
[Severity: High]
This is a pre-existing issue, but does this code properly handle CAN XL frames?
If an ETH_P_CANXL frame is sent via AF_PACKET, can_dev_dropped_skb() currently
lacks a check to drop CAN XL frames for devices that don't support CAN XL.
When such a frame enters rkcanfd_start_xmit(), can_is_canfd_skb() returns
false, causing the driver to treat it as a Classic CAN frame.
The driver reads cfd->len from offset 4, which in a canxl_frame corresponds to
the user-controlled flags field. Because valid CAN XL frames require CANXL_XLF
(0x80) to be set, cfd->len is evaluated as at least 128.
Could a minimally sized CAN XL frame trigger a loop of 32 iterations here,
leading to an out-of-bounds read from cfd->data and an out-of-bounds write
to device memory at RKCANFD_REG_FD_TXDATA0 + i?
> - frame_len = can_skb_get_frame_len(skb);
> - err = can_put_echo_skb(skb, ndev, tx_head, frame_len);
> - if (!err)
> - netdev_sent_queue(priv->ndev, frame_len);
> + netdev_sent_queue(priv->ndev, frame_len);
>
> WRITE_ONCE(priv->tx_head, priv->tx_head + 1);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260731-master-v5-0-5b27029dee20@qq.com?part=1
next prev parent reply other threads:[~2026-07-31 10:54 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20260731-master-v5-0-5b27029dee20@qq.com>
2026-07-31 10:39 ` [PATCH v5 1/3] can: rockchip_canfd: prevent TX stall on echo skb failure Cunhao Lu
2026-07-31 10:39 ` Cunhao Lu
2026-07-31 10:54 ` sashiko-bot [this message]
2026-07-31 10:39 ` [PATCH v5 2/3] can: rockchip_canfd: retry the outstanding TX buffer Cunhao Lu
2026-07-31 10:39 ` Cunhao Lu
2026-07-31 10:39 ` [PATCH v5 3/3] can: rockchip_canfd: serialize TX state and command writes Cunhao Lu
2026-07-31 10:39 ` Cunhao Lu
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=20260731105402.B7A451F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=1579567540@qq.com \
--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.