From: sashiko-bot@kernel.org
To: "Avi Weiss" <thnkslprpt@gmail.com>
Cc: "Oleksij Rempel" <o.rempel@pengutronix.de>,
"Marc Kleine-Budde" <mkl@pengutronix.de>,
"Vincent Mailhol" <mailhol@kernel.org>,
linux-can@vger.kernel.org,
"Oliver Hartkopp" <socketcan@hartkopp.net>
Subject: Re: [PATCH net] can: ctucanfd: use self-test mode for PRESUME_ACK
Date: Thu, 23 Jul 2026 19:27:40 +0000 [thread overview]
Message-ID: <20260723192740.D8A301F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260722192726.230729-1-thnkslprpt@gmail.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Critical] Missing bounds check on `RWCNT` when calculating RX frame length can lead to kernel heap overflow.
--
--- Patch [1]: [PATCH net] can: ctucanfd: use self-test mode for PRESUME_ACK ---
commit 84cf60cfa3d4dbe2be47f85be01d189d34ce05a7
Author: Avi Weiss <thnkslprpt@gmail.com>
can: ctucanfd: use self-test mode for PRESUME_ACK
This commit uses self-test mode for CAN_CTRLMODE_PRESUME_ACK so transmitted
frames can complete without receiving an ACK. It fixes an issue where the ACK
forbidden mode prevented the controller from acknowledging received frames.
> diff --git a/drivers/net/can/ctucanfd/ctucanfd_base.c b/drivers/net/can/ctucanfd/ctucanfd_base.c
> index 0ea1ff28dfce8..8e0a606f2c84e 100644
> --- a/drivers/net/can/ctucanfd/ctucanfd_base.c
> +++ b/drivers/net/can/ctucanfd/ctucanfd_base.c
> @@ -340,8 +340,8 @@ static void ctucan_set_mode(struct ctucan_priv *priv, const struct can_ctrlmode
> (mode_reg & ~REG_MODE_FDE);
>
> mode_reg = (mode->flags & CAN_CTRLMODE_PRESUME_ACK) ?
> - (mode_reg | REG_MODE_ACF) :
> - (mode_reg & ~REG_MODE_ACF);
> + (mode_reg | REG_MODE_STM) :
> + (mode_reg & ~REG_MODE_STM);
>
> mode_reg = (mode->flags & CAN_CTRLMODE_FD_NON_ISO) ?
> (mode_reg | REG_MODE_NISOFD) :
[Severity: Critical]
This is a pre-existing issue, but can this code in ctucan_read_rx_frame()
cause a heap buffer overflow?
drivers/net/can/ctucanfd/ctucanfd_base.c:ctucan_read_rx_frame() {
...
wc = FIELD_GET(REG_FRAME_FORMAT_W_RWCNT, ffw) - 3;
/* DLC */
if (FIELD_GET(REG_FRAME_FORMAT_W_DLC, ffw) <= 8) {
len = FIELD_GET(REG_FRAME_FORMAT_W_DLC, ffw);
} else {
if (FIELD_GET(REG_FRAME_FORMAT_W_FDF, ffw))
len = wc << 2;
else
len = 8;
}
cf->len = len;
if (unlikely(len > wc * 4))
len = wc * 4;
...
}
If the hardware returns RWCNT < 3, doesn't wc underflow to a very large
unsigned integer?
This appears to allow len to become large enough to cause the subsequent loop
to write out-of-bounds. Furthermore, if RWCNT is between 20 and 31, wc could
be up to 28, making len up to 112.
Since cf->data only has space for 64 bytes (CANFD_MAX_DLEN), could this copy
more bytes than allocated and overflow the heap backing the SKB?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260722192726.230729-1-thnkslprpt@gmail.com?part=1
prev parent reply other threads:[~2026-07-23 19:27 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 19:27 [PATCH net] can: ctucanfd: use self-test mode for PRESUME_ACK Avi Weiss
2026-07-22 20:56 ` Pavel Pisa
2026-07-23 19:27 ` 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=20260723192740.D8A301F000E9@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=thnkslprpt@gmail.com \
/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