public inbox for netdev@vger.kernel.org 
 help / color / mirror / Atom feed
From: Willem de Bruijn <willemdebruijn.kernel@gmail•com>
To: netdev@vger•kernel.org
Cc: davem@davemloft•net, idosch@idosch•org,
	Willem de Bruijn <willemb@google•com>
Subject: [PATCH net] packet: validate address length if non-zero
Date: Sat, 22 Dec 2018 16:53:45 -0500	[thread overview]
Message-ID: <20181222215345.128704-1-willemdebruijn.kernel@gmail.com> (raw)

From: Willem de Bruijn <willemb@google•com>

Validate packet socket address length if a length is given. Zero
length is equivalent to not setting an address.

Fixes: 99137b7888f4 ("packet: validate address length")
Reported-by: Ido Schimmel <idosch@idosch•org>
Signed-off-by: Willem de Bruijn <willemb@google•com>
---
 net/packet/af_packet.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c
index 5dda263b4a0a..eedacdebcd4c 100644
--- a/net/packet/af_packet.c
+++ b/net/packet/af_packet.c
@@ -2625,7 +2625,7 @@ static int tpacket_snd(struct packet_sock *po, struct msghdr *msg)
 						sll_addr)))
 			goto out;
 		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);
 		if (addr && dev && saddr->sll_halen < dev->addr_len)
 			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)))
 			goto out;
 		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);
 		if (addr && dev && saddr->sll_halen < dev->addr_len)
 			goto out;
-- 
2.20.1.415.g653613c723-goog

             reply	other threads:[~2018-12-22 21:53 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-12-22 21:53 Willem de Bruijn [this message]
2018-12-22 23:13 ` [PATCH net] packet: validate address length if non-zero David Miller
2018-12-23 16:30   ` Willem de Bruijn
2018-12-23  7:15 ` Ido Schimmel
2019-04-23 10:00 ` David Laight
2019-04-23 15:07   ` Willem de Bruijn
2019-04-23 15:53     ` David Laight
2019-04-23 17:04       ` Willem de Bruijn
2019-04-23 17:21         ` Willem de Bruijn
2019-04-23 18:21           ` Willem de Bruijn
2019-04-24 19:14             ` Willem de Bruijn
2019-04-24 19:34               ` Willem de Bruijn
2019-04-25  9:34                 ` David Laight
2019-04-25 13:56                   ` Willem de Bruijn
2019-04-25 14:35                     ` David Laight
2019-04-25 15:42                       ` Willem de Bruijn
2019-04-26 15:10                         ` Willem de Bruijn
2019-04-26 15:14                           ` David Laight
2019-04-26 19:32                             ` Willem de Bruijn

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20181222215345.128704-1-willemdebruijn.kernel@gmail.com \
    --to=willemdebruijn.kernel@gmail$(echo .)com \
    --cc=davem@davemloft$(echo .)net \
    --cc=idosch@idosch$(echo .)org \
    --cc=netdev@vger$(echo .)kernel.org \
    --cc=willemb@google$(echo .)com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox