net: netlink: Check address length before reading groups field
KMSAN will complain if valid address length passed to bind() is shorter than sizeof(struct sockaddr_nl) bytes. Signed-off-by: Tetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
175f7c1f01
commit
d852be8477
|
@ -988,7 +988,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
|
|||
struct netlink_sock *nlk = nlk_sk(sk);
|
||||
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
|
||||
int err = 0;
|
||||
unsigned long groups = nladdr->nl_groups;
|
||||
unsigned long groups;
|
||||
bool bound;
|
||||
|
||||
if (addr_len < sizeof(struct sockaddr_nl))
|
||||
|
@ -996,6 +996,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
|
|||
|
||||
if (nladdr->nl_family != AF_NETLINK)
|
||||
return -EINVAL;
|
||||
groups = nladdr->nl_groups;
|
||||
|
||||
/* Only superuser is allowed to listen multicasts */
|
||||
if (groups) {
|
||||
|
|
Loading…
Reference in New Issue