packet: validate address length if non-zero
Validate packet socket address length if a length is given. Zero
length is equivalent to not setting an address.
Fixes: 99137b7888
("packet: validate address length")
Reported-by: Ido Schimmel <idosch@idosch.org>
Signed-off-by: Willem de Bruijn <willemb@google.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
a95386f039
commit
6b8d95f179
@ -2625,7 +2625,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
|
|||||||
sll_addr)))
|
sll_addr)))
|
||||||
goto out;
|
goto out;
|
||||||
proto = saddr->sll_protocol;
|
proto = saddr->sll_protocol;
|
||||||
addr = saddr->sll_addr;
|
addr = saddr->sll_halen ? saddr->sll_addr : NULL;
|
||||||
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
|
dev = dev_get_by_index(sock_net(&po->sk), saddr->sll_ifindex);
|
||||||
if (addr && dev && saddr->sll_halen < dev->addr_len)
|
if (addr && dev && saddr->sll_halen < dev->addr_len)
|
||||||
goto out;
|
goto out;
|
||||||
@ -2825,7 +2825,7 @@ static int packet_snd(struct socket *sock, struct msghdr *msg, size_t len)
|
|||||||
if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr)))
|
if (msg->msg_namelen < (saddr->sll_halen + offsetof(struct sockaddr_ll, sll_addr)))
|
||||||
goto out;
|
goto out;
|
||||||
proto = saddr->sll_protocol;
|
proto = saddr->sll_protocol;
|
||||||
addr = saddr->sll_addr;
|
addr = saddr->sll_halen ? saddr->sll_addr : NULL;
|
||||||
dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
|
dev = dev_get_by_index(sock_net(sk), saddr->sll_ifindex);
|
||||||
if (addr && dev && saddr->sll_halen < dev->addr_len)
|
if (addr && dev && saddr->sll_halen < dev->addr_len)
|
||||||
goto out;
|
goto out;
|
||||||
|
Loading…
Reference in New Issue
Block a user