Skip to content

Commit 9684407

Browse files
wkzkuba-moo
authored andcommitted
net: mvpp2: Prevent parser TCAM memory corruption
Protect the parser TCAM/SRAM memory, and the cached (shadow) SRAM information, from concurrent modifications. Both the TCAM and SRAM tables are indirectly accessed by configuring an index register that selects the row to read or write to. This means that operations must be atomic in order to, e.g., avoid spreading writes across multiple rows. Since the shadow SRAM array is used to find free rows in the hardware table, it must also be protected in order to avoid TOCTOU errors where multiple cores allocate the same row. This issue was detected in a situation where `mvpp2_set_rx_mode()` ran concurrently on two CPUs. In this particular case the MVPP2_PE_MAC_UC_PROMISCUOUS entry was corrupted, causing the classifier unit to drop all incoming unicast - indicated by the `rx_classifier_drops` counter. Fixes: 3f51850 ("ethernet: Add new driver for Marvell Armada 375 network unit") Signed-off-by: Tobias Waldekranz <[email protected]> Reviewed-by: Maxime Chevallier <[email protected]> Tested-by: Maxime Chevallier <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent d3210da commit 9684407

File tree

3 files changed

+140
-67
lines changed

3 files changed

+140
-67
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1113,6 +1113,9 @@ struct mvpp2 {
11131113

11141114
/* Spinlocks for CM3 shared memory configuration */
11151115
spinlock_t mss_spinlock;
1116+
1117+
/* Spinlock for shared PRS parser memory and shadow table */
1118+
spinlock_t prs_spinlock;
11161119
};
11171120

11181121
struct mvpp2_pcpu_stats {

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7723,8 +7723,9 @@ static int mvpp2_probe(struct platform_device *pdev)
77237723
if (mvpp2_read(priv, MVPP2_VER_ID_REG) == MVPP2_VER_PP23)
77247724
priv->hw_version = MVPP23;
77257725

7726-
/* Init mss lock */
7726+
/* Init locks for shared packet processor resources */
77277727
spin_lock_init(&priv->mss_spinlock);
7728+
spin_lock_init(&priv->prs_spinlock);
77287729

77297730
/* Initialize network controller */
77307731
err = mvpp2_init(pdev, priv);

0 commit comments

Comments
 (0)