mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH master 2/5] net: dsa: realtek: mdio: fix out-of-bounds memory write
Date: Tue,  7 Mar 2023 11:14:43 +0100	[thread overview]
Message-ID: <20230307101446.2077676-2-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20230307101446.2077676-1-a.fatoum@pengutronix.de>

The SMI Realtek driver takes care of chip_data_sz as expected, but the
MDIO driver doesn't, leading to memory corruption. Fix this.

This issue is also present in the original Linux driver and will be fixed
there as well.

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

diff --git a/drivers/net/realtek-dsa/realtek-mdio.c b/drivers/net/realtek-dsa/realtek-mdio.c
index 7c26841d2fac..8b32c3cf539e 100644
--- a/drivers/net/realtek-dsa/realtek-mdio.c
+++ b/drivers/net/realtek-dsa/realtek-mdio.c
@@ -119,7 +119,7 @@ static int realtek_mdio_probe(struct phy_device *mdiodev)
 	if (!var)
 		return -EINVAL;
 
-	priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+	priv = kzalloc(sizeof(*priv) + var->chip_data_sz, GFP_KERNEL);
 	if (!priv)
 		return -ENOMEM;
 
-- 
2.30.2




  reply	other threads:[~2023-03-07 10:16 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-07 10:14 [PATCH master 1/5] net: dsa: realtek: rtl8365mb: add missing new line to log print Ahmad Fatoum
2023-03-07 10:14 ` Ahmad Fatoum [this message]
2023-03-07 10:14 ` [PATCH master 3/5] crypto: caam - pbl-init: fix null pointer check Ahmad Fatoum
2023-03-07 10:14 ` [PATCH master 4/5] ARM: i.MX8M: silence warning accessing bootrom log in zero page Ahmad Fatoum
2023-03-07 10:14 ` [PATCH master 5/5] ARM: i.MX8M: fix outdated comment about imx-atf Ahmad Fatoum
2023-03-09 10:50 ` [PATCH master 1/5] net: dsa: realtek: rtl8365mb: add missing new line to log print Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230307101446.2077676-2-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox