net: dsa: mv88e6xxx: Fix out-of-bound access

commit 528876d867a23b5198022baf2e388052ca67c952 upstream.

If an ATU violation was caused by a CPU Load operation, the SPID could
be larger than DSA_MAX_PORTS (the size of mv88e6xxx_chip.ports[] array).

Fixes: 75c05a74e745 ("net: dsa: mv88e6xxx: Fix counting of ATU violations")
Signed-off-by: Joseph Huang <Joseph.Huang@garmin.com>
Reviewed-by: Andrew Lunn <andrew@lunn.ch>
Link: https://patch.msgid.link/20240819235251.1331763-1-Joseph.Huang@garmin.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Bruno VERNAY <bruno.vernay@se.com>
Signed-off-by: Hugo SIMELIERE <hsimeliere.opensource@witekio.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
Joseph Huang
2024-08-19 19:52:50 -04:00
committed by Greg Kroah-Hartman
parent 11a772d537
commit 4a88fca95c

View File

@@ -363,6 +363,7 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
dev_err_ratelimited(chip->dev, dev_err_ratelimited(chip->dev,
"ATU full violation for %pM portvec %x spid %d\n", "ATU full violation for %pM portvec %x spid %d\n",
entry.mac, entry.portvec, spid); entry.mac, entry.portvec, spid);
if (spid < ARRAY_SIZE(chip->ports))
chip->ports[spid].atu_full_violation++; chip->ports[spid].atu_full_violation++;
} }
mutex_unlock(&chip->reg_lock); mutex_unlock(&chip->reg_lock);