Skip to content

Commit

Permalink
net: Fix permission check in netlink_connect()
Browse files Browse the repository at this point in the history
netlink_sendmsg() was changed to prevent non-root processes from sending
messages with dst_pid != 0.
netlink_connect() however still only checks if nladdr->nl_groups is set.
This patch modifies netlink_connect() to check for the same condition.

Signed-off-by: Mike Pecovnik <mike.pecovnik@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Mike Pecovnik authored and David S. Miller committed Feb 25, 2014
1 parent 687d705 commit 46833a8
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,8 +1489,8 @@ static int netlink_connect(struct socket *sock, struct sockaddr *addr,
if (addr->sa_family != AF_NETLINK)
return -EINVAL;

/* Only superuser is allowed to send multicasts */
if (nladdr->nl_groups && !netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
if ((nladdr->nl_groups || nladdr->nl_pid) &&
!netlink_capable(sock, NL_CFG_F_NONROOT_SEND))
return -EPERM;

if (!nlk->portid)
Expand Down

0 comments on commit 46833a8

Please sign in to comment.