From: Johannes Berg Date: Wed, 18 Jul 2007 09:07:51 +0000 (-0700) Subject: [NETLINK]: negative groups in netlink_setsockopt X-Git-Tag: v2.6.23-rc1~496^2~7 X-Git-Url: https://asedeno.scripts.mit.edu/gitweb/?a=commitdiff_plain;h=eb4965344965530411359891214cd6fcab483649;p=linux.git [NETLINK]: negative groups in netlink_setsockopt 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 Signed-off-by: David S. Miller --- diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c index a3c8e692f493..641cfbc278d8 100644 --- a/net/netlink/af_netlink.c +++ b/net/netlink/af_netlink.c @@ -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) {