Skip to content

Commit

Permalink
[NETLINK]: negative groups in netlink_setsockopt
Browse files Browse the repository at this point in the history
Reading netlink_setsockopt it's not immediately clear why there isn't a
bug when you pass in negative numbers, the reason being that the >=
comparison is really unsigned although 'val' is signed because
nlk->ngroups is unsigned. Make 'val' unsigned too.

[ Update the get_user() cast to match.  --DaveM ]

Signed-off-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Johannes Berg authored and David S. Miller committed Jul 18, 2007
1 parent f77ae93 commit eb49653
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions net/netlink/af_netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -1012,13 +1012,14 @@ static int netlink_setsockopt(struct socket *sock, int level, int optname,
{
struct sock *sk = sock->sk;
struct netlink_sock *nlk = nlk_sk(sk);
int val = 0, err;
unsigned int val = 0;
int err;

if (level != SOL_NETLINK)
return -ENOPROTOOPT;

if (optlen >= sizeof(int) &&
get_user(val, (int __user *)optval))
get_user(val, (unsigned int __user *)optval))
return -EFAULT;

switch (optname) {
Expand Down

0 comments on commit eb49653

Please sign in to comment.