]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.9.108/packet-fix-reserve-calculation.patch
Fix up backported ptrace patch
[thirdparty/kernel/stable-queue.git] / releases / 4.9.108 / packet-fix-reserve-calculation.patch
CommitLineData
e6d488dc
GKH
1From foo@baz Tue Jun 12 11:38:32 CEST 2018
2From: Willem de Bruijn <willemb@google.com>
3Date: Thu, 24 May 2018 18:10:30 -0400
4Subject: packet: fix reserve calculation
5
6From: Willem de Bruijn <willemb@google.com>
7
8[ Upstream commit 9aad13b087ab0a588cd68259de618f100053360e ]
9
10Commit b84bbaf7a6c8 ("packet: in packet_snd start writing at link
11layer allocation") ensures that packet_snd always starts writing
12the link layer header in reserved headroom allocated for this
13purpose.
14
15This is needed because packets may be shorter than hard_header_len,
16in which case the space up to hard_header_len may be zeroed. But
17that necessary padding is not accounted for in skb->len.
18
19The fix, however, is buggy. It calls skb_push, which grows skb->len
20when moving skb->data back. But in this case packet length should not
21change.
22
23Instead, call skb_reserve, which moves both skb->data and skb->tail
24back, without changing length.
25
26Fixes: b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")
27Reported-by: Tariq Toukan <tariqt@mellanox.com>
28Signed-off-by: Willem de Bruijn <willemb@google.com>
29Acked-by: Soheil Hassas Yeganeh <soheil@google.com>
30Signed-off-by: David S. Miller <davem@davemloft.net>
31Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
32---
33 net/packet/af_packet.c | 2 +-
34 1 file changed, 1 insertion(+), 1 deletion(-)
35
36--- a/net/packet/af_packet.c
37+++ b/net/packet/af_packet.c
38@@ -2918,7 +2918,7 @@ static int packet_snd(struct socket *soc
39 if (unlikely(offset < 0))
40 goto out_free;
41 } else if (reserve) {
42- skb_push(skb, reserve);
43+ skb_reserve(skb, -reserve);
44 }
45
46 /* Returns -EFAULT on error */