From: <Rengarajan.S@microchip.com>
To: <aleksei.kodanev@bell-sw.com>, <netdev@vger.kernel.org>
Cc: <andrew+netdev@lunn.ch>, <Bryan.Whitehead@microchip.com>,
<davem@davemloft.net>, <Raju.Lakkaraju@microchip.com>,
<pabeni@redhat.com>, <kuba@kernel.org>, <edumazet@google.com>,
<UNGLinuxDriver@microchip.com>, <richardcochran@gmail.com>
Subject: Re: [PATCH net-next v2] net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get()
Date: Thu, 19 Jun 2025 10:39:11 +0000 [thread overview]
Message-ID: <d44ccb0adff01e9d36370b705dbc0b0a4fbc4ed3.camel@microchip.com> (raw)
In-Reply-To: <20250616113743.36284-1-aleksei.kodanev@bell-sw.com>
Hi Alexey,
On Mon, 2025-06-16 at 11:37 +0000, Alexey Kodanev wrote:
> EXTERNAL EMAIL: Do not click links or open attachments unless you
> know the content is safe
>
> Before calling lan743x_ptp_io_event_clock_get(), the 'channel' value
> is checked against the maximum value of
> PCI11X1X_PTP_IO_MAX_CHANNELS(8).
> This seems correct and aligns with the PTP interrupt status register
> (PTP_INT_STS) specifications.
>
> However, lan743x_ptp_io_event_clock_get() writes to ptp->extts[] with
> only LAN743X_PTP_N_EXTTS(4) elements, using channel as an index:
>
> lan743x_ptp_io_event_clock_get(..., u8 channel,...)
> {
> ...
> /* Update Local timestamp */
> extts = &ptp->extts[channel];
> extts->ts.tv_sec = sec;
> ...
> }
>
> To avoid an out-of-bounds write and utilize all the supported GPIO
> inputs, set LAN743X_PTP_N_EXTTS to 8.
>
> Detected using the static analysis tool - Svace.
> Fixes: 60942c397af6 ("net: lan743x: Add support for PTP-IO Event
> Input External Timestamp (extts)")
> Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
> ---
>
> v2: Increase LAN743X_PTP_N_EXTTS to 8
>
> drivers/net/ethernet/microchip/lan743x_ptp.h | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/microchip/lan743x_ptp.h
> b/drivers/net/ethernet/microchip/lan743x_ptp.h
> index e8d073bfa2ca..f33dc83c5700 100644
> --- a/drivers/net/ethernet/microchip/lan743x_ptp.h
> +++ b/drivers/net/ethernet/microchip/lan743x_ptp.h
> @@ -18,9 +18,9 @@
> */
> #define LAN743X_PTP_N_EVENT_CHAN 2
> #define LAN743X_PTP_N_PEROUT LAN743X_PTP_N_EVENT_CHAN
> -#define LAN743X_PTP_N_EXTTS 4
> -#define LAN743X_PTP_N_PPS 0
> #define PCI11X1X_PTP_IO_MAX_CHANNELS 8
> +#define LAN743X_PTP_N_EXTTS PCI11X1X_PTP_IO_MAX_CHANNELS
> +#define LAN743X_PTP_N_PPS 0
> #define PTP_CMD_CTL_TIMEOUT_CNT 50
Thanks for the update. Changing the LAN743X_PTP_N_EXTTS from 4 to 8
looks valid here.
>
> struct lan743x_adapter;
> --
> 2.25.1
>
Acked-by: Rengarajan S <rengarajan.s@microchip.com>
next prev parent reply other threads:[~2025-06-19 10:39 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-16 11:37 [PATCH net-next v2] net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get() Alexey Kodanev
2025-06-16 22:22 ` Jacob Keller
2025-06-19 10:04 ` Paolo Abeni
2025-06-19 10:26 ` Paolo Abeni
2025-06-19 10:35 ` Rengarajan.S
2025-06-19 10:39 ` Rengarajan.S [this message]
2025-06-19 13:31 ` Paolo Abeni
2025-06-19 13:50 ` patchwork-bot+netdevbpf
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=d44ccb0adff01e9d36370b705dbc0b0a4fbc4ed3.camel@microchip.com \
--to=rengarajan.s@microchip.com \
--cc=Bryan.Whitehead@microchip.com \
--cc=Raju.Lakkaraju@microchip.com \
--cc=UNGLinuxDriver@microchip.com \
--cc=aleksei.kodanev@bell-sw.com \
--cc=andrew+netdev@lunn.ch \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
--cc=richardcochran@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;
as well as URLs for NNTP newsgroup(s).