Skip to content

Commit 34fcac2

Browse files
Sean Andersongregkh
authored andcommitted
net: dpaa: Pad packets to ETH_ZLEN
[ Upstream commit cbd7ec0 ] 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 <edumazet@google.com> Signed-off-by: Sean Anderson <sean.anderson@linux.dev> Reviewed-by: Eric Dumazet <edumazet@google.com> Link: https://patch.msgid.link/20240910143144.1439910-1-sean.anderson@linux.dev Signed-off-by: Jakub Kicinski <kuba@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent fc8c0ce commit 34fcac2

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
@@ -2285,12 +2285,12 @@ static netdev_tx_t
22852285
dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
22862286
{
22872287
const int queue_mapping = skb_get_queue_mapping(skb);
2288-
bool nonlinear = skb_is_nonlinear(skb);
22892288
struct rtnl_link_stats64 *percpu_stats;
22902289
struct dpaa_percpu_priv *percpu_priv;
22912290
struct netdev_queue *txq;
22922291
struct dpaa_priv *priv;
22932292
struct qm_fd fd;
2293+
bool nonlinear;
22942294
int offset = 0;
22952295
int err = 0;
22962296

@@ -2300,6 +2300,13 @@ dpaa_start_xmit(struct sk_buff *skb, struct net_device *net_dev)
23002300

23012301
qm_fd_clear_fd(&fd);
23022302

2303+
/* Packet data is always read as 32-bit words, so zero out any part of
2304+
* the skb which might be sent if we have to pad the packet
2305+
*/
2306+
if (__skb_put_padto(skb, ETH_ZLEN, false))
2307+
goto enomem;
2308+
2309+
nonlinear = skb_is_nonlinear(skb);
23032310
if (!nonlinear) {
23042311
/* We're going to store the skb backpointer at the beginning
23052312
* of the data buffer, so we need a privately owned skb

0 commit comments

Comments
 (0)