net: dsa: mv88e6xxx: Fix out-of-bound access
authorJoseph Huang <Joseph.Huang@garmin.com>
Mon, 19 Aug 2024 23:52:50 +0000 (19:52 -0400)
committerJakub Kicinski <kuba@kernel.org>
Tue, 20 Aug 2024 23:53:21 +0000 (16:53 -0700)
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>
drivers/net/dsa/mv88e6xxx/global1_atu.c

index ce3b3690c3c057235d78b1c701d97aad26f24b00..c47f068f56b32afe71c6da4fe6700e1881b583d9 100644 (file)
@@ -457,7 +457,8 @@ static irqreturn_t mv88e6xxx_g1_atu_prob_irq_thread_fn(int irq, void *dev_id)
                trace_mv88e6xxx_atu_full_violation(chip->dev, spid,
                                                   entry.portvec, entry.mac,
                                                   fid);
-               chip->ports[spid].atu_full_violation++;
+               if (spid < ARRAY_SIZE(chip->ports))
+                       chip->ports[spid].atu_full_violation++;
        }
 
        return IRQ_HANDLED;