mirror of
https://github.com/torvalds/linux.git
synced 2026-11-24 23:47:06 +00:00
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 <[email protected]> Cc: [email protected] Signed-off-by: Jeremy Cline <[email protected]> Signed-off-by: David S. Miller <[email protected]>
This commit is contained in:
committed by
David S. Miller
parent
c8e8cd579b
commit
e978de7a6d
+2
-1
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user