]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: socket: icmp6: fix use-after-scope
authorBenjamin Hesmans <benjamin.hesmans@tessares.net>
Fri, 3 Sep 2021 13:23:35 +0000 (15:23 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Sep 2021 10:26:45 +0000 (12:26 +0200)
commit5760dbfff6e05079b838dd68445401e76b08fada
tree707b9c718b5cd4dbc4f0299f7f2da3400fd50fd7
parent691984b0d3834b76faeac5ab25e865a9f4e28e3a
netfilter: socket: icmp6: fix use-after-scope

[ Upstream commit 730affed24bffcd1eebd5903171960f5ff9f1f22 ]

Bug reported by KASAN:

BUG: KASAN: use-after-scope in inet6_ehashfn (net/ipv6/inet6_hashtables.c:40)
Call Trace:
(...)
inet6_ehashfn (net/ipv6/inet6_hashtables.c:40)
(...)
nf_sk_lookup_slow_v6 (net/ipv6/netfilter/nf_socket_ipv6.c:91
net/ipv6/netfilter/nf_socket_ipv6.c:146)

It seems that this bug has already been fixed by Eric Dumazet in the
past in:
commit 67e9afea028f ("netfilter: xt_socket: fix a stack corruption bug")

But a variant of the same issue has been introduced in
commit 0af2a326dc15 ("netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match")

`daddr` and `saddr` potentially hold a reference to ipv6_var that is no
longer in scope when the call to `nf_socket_get_sock_v6` is made.

Fixes: 0af2a326dc15 ("netfilter: x_tables: don't extract flow keys on early demuxed sks in socket match")
Acked-by: Matthieu Baerts <matthieu.baerts@tessares.net>
Signed-off-by: Benjamin Hesmans <benjamin.hesmans@tessares.net>
Reviewed-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/ipv6/netfilter/nf_socket_ipv6.c