mirror of
git://git.kernel.org/pub/scm/linux/kernel/git/xiang/erofs.git
synced 2026-11-01 23:04:54 +01: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:
1 parent
c8e8cd579b
commit
e978de7a6d
1 file changed
+2
-1
+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