forked from luck/tmp_suning_uos_patched
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: Jeremy Cline <jcline@redhat.com> Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
parent
c8e8cd579b
commit
e978de7a6d
|
@ -2690,7 +2690,8 @@ EXPORT_SYMBOL(sock_unregister);
|
|||
|
||||
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)
|
||||
|
|
Loading…
Reference in New Issue
Block a user