mirror-linux/drivers/net/ethernet/microchip
Alexey Kodanev e353b0854d net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get()
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: 60942c397a ("net: lan743x: Add support for PTP-IO Event Input External Timestamp (extts)")
Signed-off-by: Alexey Kodanev <aleksei.kodanev@bell-sw.com>
Reviewed-by: Jacob Keller <jacob.e.keller@intel.com>
Acked-by: Rengarajan S <rengarajan.s@microchip.com>
Link: https://patch.msgid.link/20250616113743.36284-1-aleksei.kodanev@bell-sw.com
Signed-off-by: Paolo Abeni <pabeni@redhat.com>
2025-06-19 15:32:14 +02:00
..
fdma net: microchip: Make FDMA config symbol invisible 2024-10-01 11:31:43 +02:00
lan865x microchip: lan865x: add driver support for Microchip's LAN865X MAC-PHY 2024-09-11 20:53:46 -07:00
lan966x net: lan966x: Make sure to insert the vlan tags also in host mode 2025-05-29 15:48:37 +02:00
sparx5 Networking changes for 6.15. 2025-03-26 21:48:21 -07:00
vcap net: microchip: vcap: Add typegroup table terminators in kunit tests 2024-11-24 16:52:13 -08:00
Kconfig net: lan969x: fix cyclic dependency reported by depmod 2024-12-09 13:30:16 +00:00
Makefile net: lan969x: fix cyclic dependency reported by depmod 2024-12-09 13:30:16 +00:00
enc28j60.c net: enc28j60: Use threaded interrupt instead of workqueue 2023-05-11 18:00:37 -07:00
enc28j60_hw.h
encx24j600-regmap.c net: encx24j600: constify struct regmap_bus/regmap_config 2024-07-05 17:02:20 -07:00
encx24j600.c net: encx24j600: Correct spelling in comments 2024-04-25 19:13:26 -07:00
encx24j600_hw.h net: encx24j600: Correct spelling in comments 2024-04-25 19:13:26 -07:00
lan743x_ethtool.c net: lan743x: Modify the EEPROM and OTP size for PCI1xxxx devices 2025-05-27 18:18:50 -07:00
lan743x_ethtool.h
lan743x_main.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2025-05-28 10:11:15 +02:00
lan743x_main.h net: lan743x: implement ndo_hwtstamp_get() 2025-05-15 17:56:38 -07:00
lan743x_ptp.c net: lan743x: implement ndo_hwtstamp_get() 2025-05-15 17:56:38 -07:00
lan743x_ptp.h net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get() 2025-06-19 15:32:14 +02:00