net/sched: act_ct: fix ref leak when switching zones
authorMarcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Thu, 24 Mar 2022 19:22:10 +0000 (16:22 -0300)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 8 Apr 2022 12:23:53 +0000 (14:23 +0200)
commitbcbf4e5c3b5b373cd61528392dd1ec8e9c0fd33d
tree8351d2d4e9ea8de38f780d2bd3ee9d0e5420d124
parent72dd9e61fa319bc44020c2d365275fc8f6799bff
net/sched: act_ct: fix ref leak when switching zones

[ Upstream commit bcb74e132a76ce0502bb33d5b65533a4ed72d159 ]

When switching zones or network namespaces without doing a ct clear in
between, it is now leaking a reference to the old ct entry. That's
because tcf_ct_skb_nfct_cached() returns false and
tcf_ct_flow_table_lookup() may simply overwrite it.

The fix is to, as the ct entry is not reusable, free it already at
tcf_ct_skb_nfct_cached().

Reported-by: Florian Westphal <fw@strlen.de>
Fixes: 2f131de361f6 ("net/sched: act_ct: Fix flow table lookup after ct clear or switching zones")
Signed-off-by: Marcelo Ricardo Leitner <marcelo.leitner@gmail.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Signed-off-by: Sasha Levin <sashal@kernel.org>
net/sched/act_ct.c