Skip to content

Commit

Permalink
af_packet: move strict addr_len check right before dev_[mc/unicast]_[…
Browse files Browse the repository at this point in the history
…add/del]

My previous patch 914c8ad incorrectly changed
the length check in packet_mc_add to be more strict. The problem is that
userspace is not filling this field (and it stays zeroed) in case of setting
PACKET_MR_PROMISC or PACKET_MR_ALLMULTI. So move the strict check to the point
in path where the addr_len must be set correctly.

Signed-off-by: Jiri Pirko <jpirko@redhat.com>
Reported-by: Pavel Roskin <proski@gnu.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Jiri Pirko authored and David S. Miller committed Mar 3, 2010
1 parent 9fe9693 commit 1162563
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion net/packet/af_packet.c
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,8 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
{
switch (i->type) {
case PACKET_MR_MULTICAST:
if (i->alen != dev->addr_len)
return -EINVAL;
if (what > 0)
return dev_mc_add(dev, i->addr, i->alen, 0);
else
Expand All @@ -1700,6 +1702,8 @@ static int packet_dev_mc(struct net_device *dev, struct packet_mclist *i,
return dev_set_allmulti(dev, what);
break;
case PACKET_MR_UNICAST:
if (i->alen != dev->addr_len)
return -EINVAL;
if (what > 0)
return dev_unicast_add(dev, i->addr);
else
Expand Down Expand Up @@ -1734,7 +1738,7 @@ static int packet_mc_add(struct sock *sk, struct packet_mreq_max *mreq)
goto done;

err = -EINVAL;
if (mreq->mr_alen != dev->addr_len)
if (mreq->mr_alen > dev->addr_len)
goto done;

err = -ENOBUFS;
Expand Down

0 comments on commit 1162563

Please sign in to comment.