Skip to content

Commit 82d0d07

Browse files
jeremyclinegregkh
authored andcommitted
net: socket: Fix potential spectre v1 gadget in sock_is_registered
commit e978de7 upstream. '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]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent baaa0eb commit 82d0d07

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

net/socket.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2694,7 +2694,8 @@ EXPORT_SYMBOL(sock_unregister);
26942694

26952695
bool sock_is_registered(int family)
26962696
{
2697-
return family < NPROTO && rcu_access_pointer(net_families[family]);
2697+
return family < NPROTO &&
2698+
rcu_access_pointer(net_families[array_index_nospec(family, NPROTO)]);
26982699
}
26992700

27002701
static int __init sock_init(void)

0 commit comments

Comments
 (0)