Skip to contentSkip to conversation

net: emaclite: Avoid reading negative bytes

PATCH In review Liao Junxuan 3 participants 3 messages Jul 19, 2022 – Aug 8, 2022

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 net: emaclite: Avoid reading negative bytes

As far as I know, an IP packet isn't necessarily shorter than an ARP packet, and if length < first_read, xemaclite_alignedread() goes into an infinite loop.

---
 drivers/net/xilinx_emaclite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xilinx_emaclite.c +1 -1
index 43fc36dc..134973a5 100644
@@ -526,7 +526,7 @@ try_again:
 	}
 
 	/* Read the rest of the packet which is longer then first read */
-	if (length != first_read)
+	if (length > first_read)
 		xemaclite_alignedread(addr + first_read,
 				      etherrxbuff + first_read,
 				      length - first_read);
Signature · 1 line
2.37.1
#1 lore raw
Quoted 22 lines · Liao Junxuan

As far as I know, an IP packet isn't necessarily shorter than an ARP packet, and if length < first_read, xemaclite_alignedread() goes into an infinite loop.

---
 drivers/net/xilinx_emaclite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xilinx_emaclite.c +1 -2
index 43fc36dc..134973a5 100644
@@ -526,7 +526,7 @@ try_again:
        }
 
        /* Read the rest of the packet which is longer then first read */
-       if (length != first_read)
+       if (length > first_read)
                xemaclite_alignedread(addr + first_read,
                                      etherrxbuff + first_read,
                                      length - first_read);
--
Quoted 2 lines

2.37.1

There's a similar patch here.
https://lists.denx.de/pipermail/u-boot/2022-July/488770.html
I let michal review it.

maintainer
#2 lore raw
Quoted 19 lines · Ramon Fried

CAUTION: This message has originated from an External Source. Please use proper judgment and caution when opening attachments, clicking links, or responding to this email.

Quoted 15 lines · Liao Junxuan

As far as I know, an IP packet isn't necessarily shorter than an ARP packet, and if length < first_read, xemaclite_alignedread() goes into an infinite loop.

---
  drivers/net/xilinx_emaclite.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/xilinx_emaclite.c +0 -0
index 43fc36dc..134973a5 100644
@@ -526,7 +526,7 @@ try_again:
         }
 
Quoted 12 lines
Quoted 9 lines
drivers/net/xilinx_emaclite.c +1 -2
         /* Read the rest of the packet which is longer then first read */
-       if (length != first_read)
+       if (length > first_read)
                 xemaclite_alignedread(addr + first_read,
                                       etherrxbuff + first_read,
                                       length - first_read);
--

2.37.1

There's a similar patch here.
https://lists.denx.de/pipermail/u-boot/2022-July/488770.html
I let michal review it.

You need to CC me on these patches to see them. The patch from Samuel is better and already reviewed it.

Thanks,
Michal