Skip to content

Commit

Permalink
netlink: validate addr_len on bind
Browse files Browse the repository at this point in the history
Otherwise an out of bounds read could happen.

Signed-off-by: Hannes Frederic Sowa <hannes@stressinduktion.org>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Hannes Frederic Sowa authored and David S. Miller committed Dec 18, 2012
1 parent 9f1e0ad commit 4e4b537
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,9 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
int err;

if (addr_len < sizeof(struct sockaddr_nl))
return -EINVAL;

if (nladdr->nl_family != AF_NETLINK)
return -EINVAL;

Expand Down

0 comments on commit 4e4b537

Please sign in to comment.