netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH net 1/2] net: dsa: realtek: fix out-of-bounds access
@ 2023-03-15 13:09 Ahmad Fatoum
  2023-03-15 13:09 ` [PATCH net 2/2] net: dsa: realtek: fix missing new lines in error messages Ahmad Fatoum
                   ` (6 more replies)
  0 siblings, 7 replies; 18+ messages in thread
From: Ahmad Fatoum @ 2023-03-15 13:09 UTC (permalink / raw)
  To: Linus Walleij, Alvin Šipraga, Andrew Lunn, Florian Fainelli,
	Vladimir Oltean, Luiz Angelo Daros de Luca, David S. Miller
  Cc: kernel, Ahmad Fatoum, Eric Dumazet, Jakub Kicinski, Paolo Abeni,
	netdev, linux-kernel

The probe function sets priv->chip_data to (void *)priv + sizeof(*priv)
with the expectation that priv has enough trailing space.

However, only realtek-smi actually allocated this chip_data space.
Do likewise in realtek-mdio to fix out-of-bounds accesses.

Fixes: aac94001067d ("net: dsa: realtek: add new mdio interface for drivers")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 drivers/net/dsa/realtek/realtek-mdio.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/dsa/realtek/realtek-mdio.c b/drivers/net/dsa/realtek/realtek-mdio.c
index 3e54fac5f902..3b22d3f7ad99 100644
--- a/drivers/net/dsa/realtek/realtek-mdio.c
+++ b/drivers/net/dsa/realtek/realtek-mdio.c
@@ -152,7 +152,7 @@ static int realtek_mdio_probe(struct mdio_device *mdiodev)
 	if (!var)
 		return -EINVAL;
 
-	priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv), GFP_KERNEL);
+	priv = devm_kzalloc(&mdiodev->dev, sizeof(*priv) + var->chip_data_sz, GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-- 
2.30.2


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

end of thread, other threads:[~2023-03-22 18:22 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-03-15 13:09 [PATCH net 1/2] net: dsa: realtek: fix out-of-bounds access Ahmad Fatoum
2023-03-15 13:09 ` [PATCH net 2/2] net: dsa: realtek: fix missing new lines in error messages Ahmad Fatoum
2023-03-15 13:16   ` Linus Walleij
2023-03-15 13:21   ` Alvin Šipraga
2023-03-15 20:22   ` Florian Fainelli
2023-03-17  4:05   ` Jakub Kicinski
2023-03-22 15:47     ` Ahmad Fatoum
2023-03-15 13:15 ` [PATCH net 1/2] net: dsa: realtek: fix out-of-bounds access Linus Walleij
2023-03-15 15:34   ` Ahmad Fatoum
2023-03-15 13:21 ` Alvin Šipraga
2023-03-15 13:30 ` Andrew Lunn
2023-03-15 13:35   ` Ahmad Fatoum
2023-03-15 13:45     ` Andrew Lunn
2023-03-15 20:22 ` Florian Fainelli
2023-03-16 17:41 ` Luiz Angelo Daros de Luca
2023-03-17  4:07 ` Jakub Kicinski
2023-03-22 15:51   ` Ahmad Fatoum
2023-03-22 18:21     ` Jakub Kicinski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).