net: lan743x: fix potential out-of-bounds write in lan743x_ptp_io_event_clock_get()
[ Upstream commit e353b0854d3a1a31cb061df8d022fbfea53a0f24 ]
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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7382b6f7d1
commit
66bba1fd5b
@@ -18,9 +18,9 @@
|
|||||||
*/
|
*/
|
||||||
#define LAN743X_PTP_N_EVENT_CHAN 2
|
#define LAN743X_PTP_N_EVENT_CHAN 2
|
||||||
#define LAN743X_PTP_N_PEROUT LAN743X_PTP_N_EVENT_CHAN
|
#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 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
|
#define PTP_CMD_CTL_TIMEOUT_CNT 50
|
||||||
|
|
||||||
struct lan743x_adapter;
|
struct lan743x_adapter;
|
||||||
|
Reference in New Issue
Block a user