From: sashiko-bot@kernel.org
To: "Ciprian Regus via B4 Relay"
<devnull+ciprian.regus.analog.com@kernel.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH net-next v4 02/13] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode
Date: Wed, 10 Jun 2026 15:28:20 +0000 [thread overview]
Message-ID: <20260610152821.16D7C1F0089A@smtp.kernel.org> (raw)
In-Reply-To: <20260609-adin1140-driver-v4-2-0753e28ee004@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] The `size` parameter in `oa_tc6_check_ctrl_write_reply` is typed as `u8`, but it receives a calculated `u16` SPI transaction size from `oa_tc6_perform_ctrl`. This size can be up to 1032 bytes in protected mode or 520 bytes in unprotected mode. The truncation to `u8` causes integer underflow in the `memcmp` length calculation `size - OA_TC6_CTRL_IGNORED_SIZE` (where ignored size is 4). For example, a size of 256 (which occurs when writing exactly 31 registers in protected mode or 62 in unprotected mode) is truncated to 0, causing `0 - 4 = -4`. This negative value is cast to a massive `size_t` value, resulting in a severe out-of-bounds memory read.
--
commit f635b76e9df199f1fc90b685521cd415a107c2a3
Author: Ciprian Regus <ciprian.regus@analog.com>
net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode
This commit implements the OA TC6 standard protected mode for control
transactions. It adds support for including 1's complement values of the
data field in SPI transfer frames, which acts as an integrity check.
> diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6.c
> --- a/drivers/net/ethernet/oa_tc6.c
> +++ b/drivers/net/ethernet/oa_tc6.c
[ ... ]
> @@ -283,10 +320,10 @@ static int oa_tc6_perform_ctrl(struct oa_tc6 *tc6, u32 address, u32 value[],
> u16 size;
> int ret;
>
> - /* Prepare control command and copy to SPI control buffer */
> - oa_tc6_prepare_ctrl_spi_buf(tc6, address, value, length, reg_op);
> + size = oa_tc6_calculate_ctrl_buf_size(length, tc6->prot_ctrl);
[ ... ]
> /* Check echoed/received control write command reply for errors */
> if (reg_op == OA_TC6_CTRL_REG_WRITE)
> return oa_tc6_check_ctrl_write_reply(tc6, size);
[Severity: High]
This isn't a bug introduced by this patch, but could this lead to an out of
bounds memory access when the size gets truncated?
Looking at oa_tc6_check_ctrl_write_reply(), the size parameter is typed
as u8:
static int oa_tc6_check_ctrl_write_reply(struct oa_tc6 *tc6, u8 size)
{
...
if (memcmp(tx_buf, rx_buf, size - OA_TC6_CTRL_IGNORED_SIZE))
...
}
Since oa_tc6_perform_ctrl() calculates a u16 size (which can be up to 1032
bytes in protected mode or 520 bytes in unprotected mode), passing it to a
function expecting a u8 will truncate the value.
If the truncated size is less than OA_TC6_CTRL_IGNORED_SIZE (which is 4),
for example if the original size is exactly 256, wouldn't the subtraction
underflow?
This would pass a massive size_t value to memcmp() and cause an out of
bounds read on the spi_ctrl_tx_buf and spi_ctrl_rx_buf buffers.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260609-adin1140-driver-v4-0-0753e28ee004@analog.com?part=2
next prev parent reply other threads:[~2026-06-10 15:28 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-09 15:27 [PATCH net-next v4 00/13] net: Add ADIN1140 support Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 01/13] dt-bindings: net: Add ADIN1140 Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 02/13] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot [this message]
2026-06-09 15:28 ` [PATCH net-next v4 03/13] net: ethernet: oa_tc6: add OA_TC6_BROKEN_PHY quirk flag Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
2026-06-09 15:28 ` [PATCH net-next v4 04/13] net: ethernet: oa_tc6: Export the C45 access functions Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
2026-06-09 15:28 ` [PATCH net-next v4 05/13] net: ethernet: oa_tc6: Export standard defined registers Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
2026-06-09 15:28 ` [PATCH net-next v4 06/13] net: ethernet: oa_tc6: Add the OA_TC6_ prefix to standard registers Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
2026-06-09 15:28 ` [PATCH net-next v4 07/13] net: ethernet: oa_tc6: Add read_mms/write_mms register access functions Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 08/13] net: ethernet: oa_tc6: Use the read_mms/write_mms functions for C45 Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
2026-06-09 15:28 ` [PATCH net-next v4 09/13] net: ethernet: oa_tc6: Add new register address defines Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 10/13] net: phy: add generic helpers for direct C45 MMD access Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 11/13] net: phy: microchip-t1s: use generic C45 MMD access helpers Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 12/13] net: phy: Add support for the ADIN1140 PHY Ciprian Regus via B4 Relay
2026-06-09 15:28 ` [PATCH net-next v4 13/13] net: ethernet: adi: Add a driver for the ADIN1140 MACPHY Ciprian Regus via B4 Relay
2026-06-10 15:28 ` sashiko-bot
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=20260610152821.16D7C1F0089A@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.kernel.org \
--cc=devnull+ciprian.regus.analog.com@kernel.org \
--cc=robh@kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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