aboutsummaryrefslogtreecommitdiffstats
path: root/net
diff options
context:
space:
mode:
Diffstat (limited to 'net')
-rw-r--r--net/core/sock_diag.c2
-rw-r--r--net/socket.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/net/core/sock_diag.c b/net/core/sock_diag.c
index c37b5be7c5e4..3312a5849a97 100644
--- a/net/core/sock_diag.c
+++ b/net/core/sock_diag.c
@@ -10,6 +10,7 @@
10#include <linux/kernel.h> 10#include <linux/kernel.h>
11#include <linux/tcp.h> 11#include <linux/tcp.h>
12#include <linux/workqueue.h> 12#include <linux/workqueue.h>
13#include <linux/nospec.h>
13 14
14#include <linux/inet_diag.h> 15#include <linux/inet_diag.h>
15#include <linux/sock_diag.h> 16#include <linux/sock_diag.h>
@@ -218,6 +219,7 @@ static int __sock_diag_cmd(struct sk_buff *skb, struct nlmsghdr *nlh)
218 219
219 if (req->sdiag_family >= AF_MAX) 220 if (req->sdiag_family >= AF_MAX)
220 return -EINVAL; 221 return -EINVAL;
222 req->sdiag_family = array_index_nospec(req->sdiag_family, AF_MAX);
221 223
222 if (sock_diag_handlers[req->sdiag_family] == NULL) 224 if (sock_diag_handlers[req->sdiag_family] == NULL)
223 sock_load_diag_module(req->sdiag_family, 0); 225 sock_load_diag_module(req->sdiag_family, 0);
diff --git a/net/socket.c b/net/socket.c
index b91949168a87..270f28264cb1 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -2697,8 +2697,7 @@ EXPORT_SYMBOL(sock_unregister);
2697 2697
2698bool sock_is_registered(int family) 2698bool sock_is_registered(int family)
2699{ 2699{
2700 return family < NPROTO && 2700 return family < NPROTO && rcu_access_pointer(net_families[family]);
2701 rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]);
2702} 2701}
2703 2702
2704static int __init sock_init(void) 2703static int __init sock_init(void)