Commit d852be84 authored by Tetsuo Handa's avatar Tetsuo Handa Committed by David S. Miller

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: default avatarTetsuo Handa <penguin-kernel@I-love.SAKURA.ne.jp>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 175f7c1f
...@@ -988,7 +988,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, ...@@ -988,7 +988,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
struct netlink_sock *nlk = nlk_sk(sk); struct netlink_sock *nlk = nlk_sk(sk);
struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr; struct sockaddr_nl *nladdr = (struct sockaddr_nl *)addr;
int err = 0; int err = 0;
unsigned long groups = nladdr->nl_groups; unsigned long groups;
bool bound; bool bound;
if (addr_len < sizeof(struct sockaddr_nl)) if (addr_len < sizeof(struct sockaddr_nl))
...@@ -996,6 +996,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr, ...@@ -996,6 +996,7 @@ static int netlink_bind(struct socket *sock, struct sockaddr *addr,
if (nladdr->nl_family != AF_NETLINK) if (nladdr->nl_family != AF_NETLINK)
return -EINVAL; return -EINVAL;
groups = nladdr->nl_groups;
/* Only superuser is allowed to listen multicasts */ /* Only superuser is allowed to listen multicasts */
if (groups) { if (groups) {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment