diff mbox series

[U-Boot,2/2] net: designware: clear padding bytes

Message ID 20181117092442.15638-2-simon.k.r.goldschmidt@gmail.com
State Accepted
Commit 7efb75b11480c46077b44df70aa30d375bf761be
Delegated to: Joe Hershberger
Headers show
Series [U-Boot,1/2] net: designware: fix tx packet length | expand

Commit Message

Simon Goldschmidt Nov. 17, 2018, 9:24 a.m. UTC
Short frames are padded to the minimum allowed size of 60 bytes.
However, the designware driver sends old data in these padding bytes.
It is common practice to zero out these padding bytes ro prevent
leaking memory contents to other hosts.

Fix the padding code to zero out the padded bytes at the end.

Tested on socfpga gen5.

Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
---

 drivers/net/designware.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Joe Hershberger Nov. 17, 2018, 4:03 p.m. UTC | #1
On Sat, Nov 17, 2018 at 3:26 AM Simon Goldschmidt
<simon.k.r.goldschmidt@gmail.com> wrote:
>
> Short frames are padded to the minimum allowed size of 60 bytes.
> However, the designware driver sends old data in these padding bytes.
> It is common practice to zero out these padding bytes ro prevent
> leaking memory contents to other hosts.
>
> Fix the padding code to zero out the padded bytes at the end.
>
> Tested on socfpga gen5.
>
> Signed-off-by: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
Joe Hershberger Jan. 24, 2019, 5:37 p.m. UTC | #2
Hi Simon,

https://patchwork.ozlabs.org/patch/999268/ was applied to http://git.denx.de/?p=u-boot/u-boot-net.git

Thanks!
-Joe
diff mbox series

Patch

diff --git a/drivers/net/designware.c b/drivers/net/designware.c
index 688cf9fef2..33463de0f8 100644
--- a/drivers/net/designware.c
+++ b/drivers/net/designware.c
@@ -380,9 +380,11 @@  static int _dw_eth_send(struct dw_eth_dev *priv, void *packet, int length)
 		return -EPERM;
 	}
 
-	length = max(length, ETH_ZLEN);
-
 	memcpy((void *)data_start, packet, length);
+	if (length < ETH_ZLEN) {
+		memset(&((char *)data_start)[length], 0, ETH_ZLEN - length);
+		length = ETH_ZLEN;
+	}
 
 	/* Flush data to be sent */
 	flush_dcache_range(data_start, data_end);