Skip to content

Commit 9aad13b

Browse files
wdebruijdavem330
authored andcommitted
packet: fix reserve calculation
Commit b84bbaf ("packet: in packet_snd start writing at link layer allocation") ensures that packet_snd always starts writing the link layer header in reserved headroom allocated for this purpose. This is needed because packets may be shorter than hard_header_len, in which case the space up to hard_header_len may be zeroed. But that necessary padding is not accounted for in skb->len. The fix, however, is buggy. It calls skb_push, which grows skb->len when moving skb->data back. But in this case packet length should not change. Instead, call skb_reserve, which moves both skb->data and skb->tail back, without changing length. Fixes: b84bbaf ("packet: in packet_snd start writing at link layer allocation") Reported-by: Tariq Toukan <tariqt@mellanox.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Acked-by: Soheil Hassas Yeganeh <soheil@google.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent d546b67 commit 9aad13b

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

net/packet/af_packet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2911,7 +2911,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
29112911
if (unlikely(offset < 0))
29122912
goto out_free;
29132913
} else if (reserve) {
2914-
skb_push(skb, reserve);
2914+
skb_reserve(skb, -reserve);
29152915
}
29162916

29172917
/* Returns -EFAULT on error */

0 commit comments

Comments
 (0)