1
0
Fork 0

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>
hifive-unleashed-5.1
Tetsuo Handa 2019-04-12 19:53:38 +09:00 committed by David S. Miller
parent 175f7c1f01
commit d852be8477
1 changed files with 2 additions and 1 deletions

View File

@ -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) {