diff options
author | Simon Goldschmidt | 2018-11-17 10:24:42 +0100 |
---|---|---|
committer | Joe Hershberger | 2019-01-24 11:35:27 -0600 |
commit | 7efb75b11480c46077b44df70aa30d375bf761be (patch) | |
tree | 279d634b92fed1d5fe143a2a1b6465a45bae029a /drivers/net | |
parent | ae8ac8d423675904fdbf1510ad71e37d71db0568 (diff) |
net: designware: clear padding bytes
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>
Diffstat (limited to 'drivers/net')
-rw-r--r-- | drivers/net/designware.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/drivers/net/designware.c b/drivers/net/designware.c index 01abcc21d2b..2c5d9560c58 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); |