From: sashiko-bot@kernel.org
To: "Ciprian Regus" <ciprian.regus@analog.com>
Cc: conor+dt@kernel.org, devicetree@vger.kernel.org, robh@kernel.org
Subject: Re: [PATCH net-next v5 02/13] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode
Date: Wed, 08 Jul 2026 22:34:52 +0000 [thread overview]
Message-ID: <20260708223453.375611F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260708-adin1140-driver-v5-2-4aca7b51a58b@analog.com>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [High] Integer truncation in `oa_tc6_check_ctrl_write_reply()` causes out-of-bounds read and kernel panic
--
--- Patch [2]: [PATCH net-next v5 02/13] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode ---
commit f765aab54c97488541b3e9e738aa5de9bff2269a
Author: Ciprian Regus <ciprian.regus@analog.com>
net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode
This patch implements the OA TC6 standard defined protected mode for control
(register access) transactions. In addition to the current register access
formats the oa_tc6 driver handles, 1's complement values of the data field
are included in the SPI transfer frames as an integrity check.
> diff --git a/drivers/net/ethernet/oa_tc6.c b/drivers/net/ethernet/oa_tc6.c
> index 0727d53345a33..8b96558834960 100644
> --- a/drivers/net/ethernet/oa_tc6.c
> +++ b/drivers/net/ethernet/oa_tc6.c
[ ... ]
> @@ -284,10 +321,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);
>
> - size = oa_tc6_calculate_ctrl_buf_size(length);
> + /* Prepare control command and copy to SPI control buffer */
> + oa_tc6_prepare_ctrl_spi_buf(tc6, address, value, length, reg_op, size);
>
> /* Perform SPI transfer */
> ret = oa_tc6_spi_transfer(tc6, OA_TC6_CTRL_HEADER, size);
[ ... ]
> @@ -302,7 +339,7 @@ static int oa_tc6_perform_ctrl(struct oa_tc6 *tc6, u32 address, u32 value[],
> return oa_tc6_check_ctrl_write_reply(tc6, size);
>
> /* Check echoed/received control read command reply for errors */
> - ret = oa_tc6_check_ctrl_read_reply(tc6, size);
> + ret = oa_tc6_check_ctrl_read_reply(tc6, length);
[Severity: High]
This is a pre-existing issue, but does oa_tc6_check_ctrl_write_reply() safely
handle the u16 size being passed to it?
The size variable is declared as a u16 in oa_tc6_perform_ctrl(), but
oa_tc6_check_ctrl_write_reply() takes size as a 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))
return -EPROTO;
...
}
If size is exactly 256 bytes (which can happen when writing 62 registers in
unprotected mode, or 31 in protected mode), the size parameter truncates to 0.
The subtraction size - OA_TC6_CTRL_IGNORED_SIZE then becomes 0 - 4 = -4.
When cast to size_t for memcmp(), this becomes a massive out-of-bounds read
that can cause a page fault and kernel panic.
Additionally, if the truncated size is greater than 0 but less than the actual
size, memcmp() will only compare a few bytes, silently bypassing the full
integrity check.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260708-adin1140-driver-v5-0-4aca7b51a58b@analog.com?part=2
next prev parent reply other threads:[~2026-07-08 22:34 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-07 22:33 [PATCH net-next v5 00/13] net: Add ADIN1140 support Ciprian Regus via B4 Relay
2026-07-07 22:33 ` [PATCH net-next v5 01/13] dt-bindings: net: Add ADIN1140 Ciprian Regus via B4 Relay
2026-07-07 22:33 ` [PATCH net-next v5 02/13] net: ethernet: oa_tc6: Handle the OA TC6 SPI protected mode Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot [this message]
2026-07-07 22:33 ` [PATCH net-next v5 03/13] net: ethernet: oa_tc6: add OA_TC6_BROKEN_PHY quirk flag Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 04/13] net: ethernet: oa_tc6: Export the C45 access functions Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 05/13] net: ethernet: oa_tc6: Export standard defined registers Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 06/13] net: ethernet: oa_tc6: Add the OA_TC6_ prefix to standard registers Ciprian Regus via B4 Relay
2026-07-07 22:33 ` [PATCH net-next v5 07/13] net: ethernet: oa_tc6: Add read_mms/write_mms register access functions Ciprian Regus via B4 Relay
2026-07-08 17:23 ` Selvamani Rajagopal
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 08/13] net: ethernet: oa_tc6: Use the read_mms/write_mms functions for C45 Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 09/13] net: ethernet: oa_tc6: Add new register address defines Ciprian Regus via B4 Relay
2026-07-07 22:33 ` [PATCH net-next v5 10/13] net: phy: add generic helpers for direct C45 MMD access Ciprian Regus via B4 Relay
2026-07-09 2:29 ` Selvamani Rajagopal
2026-07-07 22:33 ` [PATCH net-next v5 11/13] net: phy: microchip-t1s: use generic C45 MMD access helpers Ciprian Regus via B4 Relay
2026-07-07 22:33 ` [PATCH net-next v5 12/13] net: phy: Add support for the ADIN1140 PHY Ciprian Regus via B4 Relay
2026-07-08 22:34 ` sashiko-bot
2026-07-07 22:33 ` [PATCH net-next v5 13/13] net: ethernet: adi: Add a driver for the ADIN1140 MACPHY Ciprian Regus via B4 Relay
2026-07-08 22:34 ` 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=20260708223453.375611F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=ciprian.regus@analog.com \
--cc=conor+dt@kernel.org \
--cc=devicetree@vger.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