public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Prevent crash when adding interface under a lag
@ 2025-12-20 17:32 Jerry Wu
  2025-12-20 17:57 ` Vladimir Oltean
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Jerry Wu @ 2025-12-20 17:32 UTC (permalink / raw)
  To: vladimir.oltean; +Cc: linux-kernel, Jerry Wu

Commit 15faa1f67ab4 ("lan966x: Fix crash when adding interface under a lag")
had fixed CVE-2024-26723 which is caused by NULL pointer dereference.
ocelot_set_aggr_pgids in drivers/net/ethernet/mscc/ocelot.c contains a similar logic.
This patch fix it in the same way as the aforementioned patch did.

Signed-off-by: Jerry Wu <w.7erry@foxmail.com>
---
 drivers/net/ethernet/mscc/ocelot.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/mscc/ocelot.c b/drivers/net/ethernet/mscc/ocelot.c
index 08bee56aea35..cb1c19c38c2c 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -2307,19 +2307,24 @@ static void ocelot_set_aggr_pgids(struct ocelot *ocelot)
 
 	/* Now, set PGIDs for each active LAG */
 	for (lag = 0; lag < ocelot->num_phys_ports; lag++) {
-		struct net_device *bond = ocelot->ports[lag]->bond;
+		struct ocelot_port *port = ocelot->ports[lag];
 		int num_active_ports = 0;
+		struct net_device *bond;
 		unsigned long bond_mask;
 		u8 aggr_idx[16];
 
-		if (!bond || (visited & BIT(lag)))
+		if (!port || !port->bond || (visited & BIT(lag)))
 			continue;
 
+		bond = port->bond;
 		bond_mask = ocelot_get_bond_mask(ocelot, bond);
 
 		for_each_set_bit(port, &bond_mask, ocelot->num_phys_ports) {
 			struct ocelot_port *ocelot_port = ocelot->ports[port];
 
+			if (!port)
+				continue;
+
 			// Destination mask
 			ocelot_write_rix(ocelot, bond_mask,
 					 ANA_PGID_PGID, port);
-- 
2.51.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-12-23 15:36 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-20 17:32 [PATCH] Prevent crash when adding interface under a lag Jerry Wu
2025-12-20 17:57 ` Vladimir Oltean
2025-12-20 18:01 ` Vladimir Oltean
2025-12-23  7:35 ` kernel test robot
2025-12-23 11:58 ` kernel test robot
2025-12-23 15:35 ` kernel test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox