提交 e978de7a 编写于 作者: J Jeremy Cline 提交者: David S. Miller

net: socket: Fix potential spectre v1 gadget in sock_is_registered

'family' can be a user-controlled value, so sanitize it after the bounds
check to avoid speculative out-of-bounds access.

Cc: Josh Poimboeuf <jpoimboe@redhat.com>
Cc: stable@vger.kernel.org
Signed-off-by: NJeremy Cline <jcline@redhat.com>
Signed-off-by: NDavid S. Miller <davem@davemloft.net>
上级 c8e8cd57
...@@ -2690,7 +2690,8 @@ EXPORT_SYMBOL(sock_unregister); ...@@ -2690,7 +2690,8 @@ EXPORT_SYMBOL(sock_unregister);
bool sock_is_registered(int family) bool sock_is_registered(int family)
{ {
return family < NPROTO && rcu_access_pointer(net_families[family]); return family < NPROTO &&
rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]);
} }
static int __init sock_init(void) static int __init sock_init(void)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册