Message ID | 20220713135204.233268-4-samuel.obuch@codasip.com |
---|---|
State | Deferred |
Delegated to: | Ramon Fried |
Headers | show |
Series | [1/3] net: emaclite: fix broken build | expand |
On Wed, Jul 13, 2022 at 5:02 PM Samuel Obuch <samuel.obuch@codasip.com> wrote: > > The maximum length is capped similarly to the emaclite_send function. > Avoid integer underflow for values of ip->ip_len < 30, the minimum > length of an IP packet is 21 bytes. > > Signed-off-by: Samuel Obuch <samuel.obuch@codasip.com> > --- > drivers/net/xilinx_emaclite.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c > index de7a2dee0b..21c450ec46 100644 > --- a/drivers/net/xilinx_emaclite.c > +++ b/drivers/net/xilinx_emaclite.c > @@ -518,6 +518,8 @@ try_again: > length = ntohs(ip->ip_len); > length += ETHER_HDR_SIZE + ETH_FCS_LEN; > debug("IP Packet %x\n", length); > + if (length > PKTSIZE) > + length = PKTSIZE; > break; > default: > debug("Other Packet\n"); > @@ -526,7 +528,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); > -- > 2.31.1 > + Michal
On 8/6/22 19:35, Ramon Fried wrote: > On Wed, Jul 13, 2022 at 5:02 PM Samuel Obuch <samuel.obuch@codasip.com> wrote: >> >> The maximum length is capped similarly to the emaclite_send function. >> Avoid integer underflow for values of ip->ip_len < 30, the minimum >> length of an IP packet is 21 bytes. >> >> Signed-off-by: Samuel Obuch <samuel.obuch@codasip.com> >> --- >> drivers/net/xilinx_emaclite.c | 4 +++- >> 1 file changed, 3 insertions(+), 1 deletion(-) >> >> diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c >> index de7a2dee0b..21c450ec46 100644 >> --- a/drivers/net/xilinx_emaclite.c >> +++ b/drivers/net/xilinx_emaclite.c >> @@ -518,6 +518,8 @@ try_again: >> length = ntohs(ip->ip_len); >> length += ETHER_HDR_SIZE + ETH_FCS_LEN; >> debug("IP Packet %x\n", length); >> + if (length > PKTSIZE) >> + length = PKTSIZE; >> break; >> default: >> debug("Other Packet\n"); >> @@ -526,7 +528,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); >> -- >> 2.31.1 >> > + Michal This looks good. Reviewed-by: Michal Simek <michal.simek@amd.com> Thanks, Michal
diff --git a/drivers/net/xilinx_emaclite.c b/drivers/net/xilinx_emaclite.c index de7a2dee0b..21c450ec46 100644 --- a/drivers/net/xilinx_emaclite.c +++ b/drivers/net/xilinx_emaclite.c @@ -518,6 +518,8 @@ try_again: length = ntohs(ip->ip_len); length += ETHER_HDR_SIZE + ETH_FCS_LEN; debug("IP Packet %x\n", length); + if (length > PKTSIZE) + length = PKTSIZE; break; default: debug("Other Packet\n"); @@ -526,7 +528,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);
The maximum length is capped similarly to the emaclite_send function. Avoid integer underflow for values of ip->ip_len < 30, the minimum length of an IP packet is 21 bytes. Signed-off-by: Samuel Obuch <samuel.obuch@codasip.com> --- drivers/net/xilinx_emaclite.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)