summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorWillem de Bruijn <willemb@google.com>2018-12-21 12:06:59 -0500
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-01-09 17:38:33 +0100
commita35c9c1712df97ec3cae9be876ac27814f47b0b6 (patch)
tree05b7dd9817cca8904e1f3e2a2a9976aad41b0c6a /net
parent781e26adfdea4e580e04247718010fcedfb9c715 (diff)
downloadlinux-rpi3-a35c9c1712df97ec3cae9be876ac27814f47b0b6.tar.gz
linux-rpi3-a35c9c1712df97ec3cae9be876ac27814f47b0b6.tar.bz2
linux-rpi3-a35c9c1712df97ec3cae9be876ac27814f47b0b6.zip
packet: validate address length
[ Upstream commit 99137b7888f4058087895d035d81c6b2d31015c5 ] Packet sockets with SOCK_DGRAM may pass an address for use in dev_hard_header. Ensure that it is of sufficient length. Reported-by: syzbot <syzkaller@googlegroups.com> Signed-off-by: Willem de Bruijn <willemb@google.com> Signed-off-by: David S. Miller <davem@davemloft.net> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/packet/af_packet.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 6477b131e809..425169cc5b26 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2627,6 +2627,8 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
proto = saddr->sll_protocol;
addr = saddr->sll_addr;
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
+ if (addr && dev && saddr->sll_halen < dev->addr_len)
+ goto out;
}
err = -ENXIO;
@@ -2825,6 +2827,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
proto = saddr->sll_protocol;
addr = saddr->sll_addr;
dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
+ if (addr && dev && saddr->sll_halen < dev->addr_len)
+ goto out;
}
err = -ENXIO;