]> git.baikalelectronics.ru Git - kernel.git/commit
netlink: prevent potential spectre v1 gadgets
authorEric Dumazet <edumazet@google.com>
Thu, 19 Jan 2023 11:01:50 +0000 (11:01 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 6 Feb 2023 06:52:45 +0000 (07:52 +0100)
commitc12d5ada5fcb928d774422faefec0621db080003
treed9c0d55f9e7812ea889cba1363c850d2392b7472
parent7d246a8a093a6d9cd2f84cdd6820f666c3de1daf
netlink: prevent potential spectre v1 gadgets

[ Upstream commit f0950402e8c76e7dcb08563f1b4e8000fbc62455 ]

Most netlink attributes are parsed and validated from
__nla_validate_parse() or validate_nla()

    u16 type = nla_type(nla);

    if (type == 0 || type > maxtype) {
        /* error or continue */
    }

@type is then used as an array index and can be used
as a Spectre v1 gadget.

array_index_nospec() can be used to prevent leaking
content of kernel memory to malicious users.

This should take care of vast majority of netlink uses,
but an audit is needed to take care of others where
validation is not yet centralized in core netlink functions.

Fixes: 4932ff39b3e6 ("[NETLINK]: Type-safe netlink messages/attributes interface")
Signed-off-by: Eric Dumazet <edumazet@google.com>
Link: https://lore.kernel.org/r/20230119110150.2678537-1-edumazet@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
lib/nlattr.c