Skip to content

Commit cbd7ec0

Browse files
Sean Andersonkuba-moo
authored andcommitted
net: dpaa: Pad packets to ETH_ZLEN
When sending packets under 60 bytes, up to three bytes of the buffer following the data may be leaked. Avoid this by extending all packets to ETH_ZLEN, ensuring nothing is leaked in the padding. This bug can be reproduced by running $ ping -s 11 destination Fixes: 9ad1a37 ("dpaa_eth: add support for DPAA Ethernet") Suggested-by: Eric Dumazet <[email protected]> Signed-off-by: Sean Anderson <[email protected]> Reviewed-by: Eric Dumazet <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent b4cd80b commit cbd7ec0

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

drivers/net/ethernet/freescale/dpaa/dpaa_eth.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2272,12 +2272,12 @@ static netdev_tx_t
22722272
dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
22732273
{
22742274
const int queue_mapping = skb_get_queue_mapping(skb);
2275-
bool nonlinear = skb_is_nonlinear(skb);
22762275
struct rtnl_link_stats64 *percpu_stats;
22772276
struct dpaa_percpu_priv *percpu_priv;
22782277
struct netdev_queue *txq;
22792278
struct dpaa_priv *priv;
22802279
struct qm_fd fd;
2280+
bool nonlinear;
22812281
int offset = 0;
22822282
int err = 0;
22832283

@@ -2287,6 +2287,13 @@ dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
22872287

22882288
qm_fd_clear_fd(&fd);
22892289

2290+
/* Packet data is always read as 32-bit words, so zero out any part of
2291+
* the skb which might be sent if we have to pad the packet
2292+
*/
2293+
if (__skb_put_padto(skb, ETH_ZLEN, false))
2294+
goto enomem;
2295+
2296+
nonlinear = skb_is_nonlinear(skb);
22902297
if (!nonlinear) {
22912298
/* We're going to store the skb backpointer at the beginning
22922299
* of the data buffer, so we need a privately owned skb

0 commit comments

Comments
 (0)