Commit 8ee7e2b8 authored by Jeremy Cline's avatar Jeremy Cline Committed by Kleber Sacilotto de Souza

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: default avatarJeremy Cline <jcline@redhat.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>

CVE-2017-5753

(backported from commit e978de7a)
[juergh: Adjusted for missing sock_is_registered().]
Signed-off-by: default avatarJuerg Haefliger <juergh@canonical.com>
Acked-by: default avatarStefan Bader <stefan.bader@canonical.com>
Acked-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
Signed-off-by: default avatarKleber Sacilotto de Souza <kleber.souza@canonical.com>
parent c0b09846
......@@ -2428,11 +2428,14 @@ int sock_register(const struct net_proto_family *ops)
}
spin_lock(&net_family_lock);
if (rcu_dereference_protected(net_families[ops->family],
lockdep_is_held(&net_family_lock)))
if (rcu_dereference_protected(
net_families[array_index_nospec(ops->family, NPROTO)],
lockdep_is_held(&net_family_lock)))
err = -EEXIST;
else {
rcu_assign_pointer(net_families[ops->family], ops);
rcu_assign_pointer(
net_families[array_index_nospec(ops->family, NPROTO)],
ops);
err = 0;
}
spin_unlock(&net_family_lock);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment