ipv4: prevent potential spectre v1 gadget in fib_metrics_match()
authorEric Dumazet <edumazet@google.com>
Fri, 20 Jan 2023 13:31:40 +0000 (13:31 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 1 Feb 2023 07:27:27 +0000 (08:27 +0100)
commitca3cf947760de050d558293002ad3e7f4b8745d2
tree0fbcf6c4213ad682bc7bdb76733937db7af920fe
parentd50e7348b44f1e046121ff5be01b7fb6978a1149
ipv4: prevent potential spectre v1 gadget in fib_metrics_match()

[ Upstream commit 5e9398a26a92fc402d82ce1f97cc67d832527da0 ]

if (!type)
        continue;
    if (type > RTAX_MAX)
        return false;
    ...
    fi_val = fi->fib_metrics->metrics[type - 1];

@type being used as an array index, we need to prevent
cpu speculation or risk leaking kernel memory content.

Fixes: 5f9ae3d9e7e4 ("ipv4: do metrics match when looking up and deleting a route")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20230120133140.3624204-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv4/fib_semantics.c