]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
packet: reset network header if packet shorter than ll reserved space
authorWillem de Bruijn <willemb@google.com>
Wed, 11 Jul 2018 16:00:45 +0000 (12:00 -0400)
committerJuerg Haefliger <juergh@canonical.com>
Wed, 24 Jul 2019 01:43:40 +0000 (19:43 -0600)
BugLink: https://bugs.launchpad.net/bugs/1835845
[ Upstream commit 993675a3100b16a4c80dfd70cbcde8ea7127b31d ]

If variable length link layer headers result in a packet shorter
than dev->hard_header_len, reset the network header offset. Else
skb->mac_len may exceed skb->len after skb_mac_reset_len.

packet_sendmsg_spkt already has similar logic.

Fixes: b84bbaf7a6c8 ("packet: in packet_snd start writing at link layer allocation")
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Khalid Elmously <khalid.elmously@canonical.com>
net/packet/af_packet.c

index 11499de17c69086a7b0fb3dae4c6b58cc80f19f6..59be60d923fd707945e50611d43702afcb83c785 100644 (file)
@@ -2909,6 +2909,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
                        goto out_free;
        } else if (reserve) {
                skb_reserve(skb, -reserve);
+               if (len < reserve)
+                       skb_reset_network_header(skb);
        }
 
        /* Returns -EFAULT on error */