Skip to content

Commit

Permalink
netlink: make sure nladdr has correct size in netlink_connect()
Browse files Browse the repository at this point in the history
KMSAN reports use of uninitialized memory in the case when |alen| is
smaller than sizeof(struct sockaddr_nl), and therefore |nladdr| isn't
fully copied from the userspace.

Signed-off-by: Alexander Potapenko <[email protected]>
Fixes: 1da177e ("Linux-2.6.12-rc2")
Reviewed-by: Eric Dumazet <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
  • Loading branch information
ramosian-glider authored and davem330 committed Mar 26, 2018
1 parent e69647a commit 7880287
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 @@ -1085,6 +1085,9 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
if (addr->sa_family != AF_NETLINK)
return -EINVAL;

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

if ((nladdr->nl_groups || nladdr->nl_pid) &&
!netlink_allowed(sock, NL_CFG_F_NONROOT_SEND))
return -EPERM;
Expand Down

0 comments on commit 7880287

Please sign in to comment.