All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Goldschmidt <simon.k.r.goldschmidt@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/2] net: designware: clear padding bytes
Date: Sat, 17 Nov 2018 10:24:42 +0100	[thread overview]
Message-ID: <20181117092442.15638-2-simon.k.r.goldschmidt@gmail.com> (raw)
In-Reply-To: <20181117092442.15638-1-simon.k.r.goldschmidt@gmail.com>

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(-)

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);
-- 
2.17.1

  reply	other threads:[~2018-11-17  9:24 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-17  9:24 [U-Boot] [PATCH 1/2] net: designware: fix tx packet length Simon Goldschmidt
2018-11-17  9:24 ` Simon Goldschmidt [this message]
2018-11-17 16:03   ` [U-Boot] [PATCH 2/2] net: designware: clear padding bytes Joe Hershberger
2018-11-24 19:08     ` Simon Goldschmidt
2019-01-24 17:37   ` [U-Boot] " Joe Hershberger
2018-11-17 16:02 ` [U-Boot] [PATCH 1/2] net: designware: fix tx packet length Joe Hershberger
2018-12-09 20:50   ` Simon Goldschmidt
2018-12-10  4:08     ` Marek Vasut
2019-01-14 15:35       ` Simon Goldschmidt
2018-12-09 21:36 ` Philipp Tomsich
2019-01-24 17:37 ` [U-Boot] " Joe Hershberger

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=20181117092442.15638-2-simon.k.r.goldschmidt@gmail.com \
    --to=simon.k.r.goldschmidt@gmail.com \
    --cc=u-boot@lists.denx.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.