Skip to contentSkip to conversation

net: cortina_ni: buffer overrun

PATCH New Heinrich Schuchardt 3 participants 3 messages Feb 20, 2021 – Feb 25, 2021 Network drivers

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: cortina_ni: buffer overrun

When copying to a u32 field we should use sizeof(u32) and not sizeof(*u32) in memcpy.

On 64bit systems like cortina_presidio-asic-emmc_defconfig using sizeof(*u32) leads to a buffer overrun.

Fixes febe13b438b3 ("net: cortina_ni: Add eth support for Cortina Access CAxxxx SoCs")
---
 drivers/net/cortina_ni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cortina_ni.c +1 -1
index ee424d95bc..ef6ecd88b0 100644
@@ -713,7 +713,7 @@ static int cortina_eth_recv(struct udevice *dev, int flags, uchar **packetp)
 							 priv->rx_xram_end_adr);
 
 			memcpy(&packet_status, rx_xram_ptr,
-			       sizeof(rx_xram_ptr));
+			       sizeof(*rx_xram_ptr));
 			if (packet_status.valid == 0) {
 				debug("%s: Invalid Packet !!, ", __func__);
 				debug("next_link=%d\n", next_link);

--
2.30.0

#1 lore raw

PATCH 1/1 net: cortina_ni: buffer overrun

Quoted 27 lines · Heinrich Schuchardt

When copying to a u32 field we should use sizeof(u32) and not sizeof(*u32) in memcpy.

On 64bit systems like cortina_presidio-asic-emmc_defconfig using sizeof(*u32) leads to a buffer overrun.

Fixes febe13b438b3 ("net: cortina_ni: Add eth support for Cortina Access CAxxxx SoCs")
---
 drivers/net/cortina_ni.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/cortina_ni.c +1 -2
index ee424d95bc..ef6ecd88b0 100644
@@ -713,7 +713,7 @@ static int cortina_eth_recv(struct udevice *dev, int flags, uchar **packetp)
                                                         priv->rx_xram_end_adr);
 
                        memcpy(&packet_status, rx_xram_ptr,
-                              sizeof(rx_xram_ptr));
+                              sizeof(*rx_xram_ptr));
                        if (packet_status.valid == 0) {
                                debug("%s: Invalid Packet !!, ", __func__);
                                debug("next_link=%d\n", next_link);
--
Quoted 2 lines

2.30.0

#2 lore raw

PATCH 1/1 net: cortina_ni: buffer overrun

In reply to Heinrich Schuchardt
Quoted 9 lines · Heinrich Schuchardt

When copying to a u32 field we should use sizeof(u32) and not sizeof(*u32) in memcpy.

On 64bit systems like cortina_presidio-asic-emmc_defconfig using sizeof(*u32) leads to a buffer overrun.

Fixes febe13b438b3 ("net: cortina_ni: Add eth support for Cortina Access CAxxxx SoCs")

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 659 bytes
Desc: not available
URL: <https://lists.denx.de/pipermail/u-boot/attachments/20210225/6ef899f9/attachment.sig>