diff options
author | Willem de Bruijn <willemb@google.com> | 2018-12-21 12:06:59 -0500 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2018-12-21 12:11:25 -0500 |
commit | 99137b7888f4058087895d035d81c6b2d31015c5 (patch) | |
tree | 1ceba39b8276cb77f2ce7ec7369bd96c6a31d21f | |
parent | d134e486e831defd26130770181f01dfc6195f7d (diff) |
packet: validate address length
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>
-rw-r--r-- | net/packet/af_packet.c | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index 6655793765b2..5dda263b4a0a 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) | |||
2627 | proto = saddr->sll_protocol; | 2627 | proto = saddr->sll_protocol; |
2628 | addr = saddr->sll_addr; | 2628 | addr = saddr->sll_addr; |
2629 | dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex); | 2629 | dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex); |
2630 | if (addr && dev && saddr->sll_halen < dev->addr_len) | ||
2631 | goto out; | ||
2630 | } | 2632 | } |
2631 | 2633 | ||
2632 | err = -ENXIO; | 2634 | err = -ENXIO; |
@@ -2825,6 +2827,8 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len) | |||
2825 | proto = saddr->sll_protocol; | 2827 | proto = saddr->sll_protocol; |
2826 | addr = saddr->sll_addr; | 2828 | addr = saddr->sll_addr; |
2827 | dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); | 2829 | dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex); |
2830 | if (addr && dev && saddr->sll_halen < dev->addr_len) | ||
2831 | goto out; | ||
2828 | } | 2832 | } |
2829 | 2833 | ||
2830 | err = -ENXIO; | 2834 | err = -ENXIO; |