]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blobdiff - net/netlink/af_netlink.c
netlink: Don't shift with UB on nlk->ngroups
[mirror_ubuntu-bionic-kernel.git] / net / netlink / af_netlink.c
index 21af79486690fee964adff1e2521a23ab27890f0..b3353aa506514643e92c9a4f4540fc6e682cc211 100644 (file)
@@ -975,7 +975,11 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
                if (err)
                        return err;
        }
-       groups &= (1UL << nlk->ngroups) - 1;
+
+       if (nlk->ngroups == 0)
+               groups = 0;
+       else
+               groups &= (1ULL << nlk->ngroups) - 1;
 
        bound = nlk->bound;
        if (bound) {