]> git.baikalelectronics.ru Git - kernel.git/commit
netfilter: nf_tables: fix memleak when more than 255 elements expired
authorFlorian Westphal <fw@strlen.de>
Fri, 22 Sep 2023 16:30:29 +0000 (18:30 +0200)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 6 Oct 2023 12:56:35 +0000 (14:56 +0200)
commit7e5d732e6902eb6a37b35480796838a145ae5f07
tree08e0d11a404dc670c6dc18a38ccdbe2a1cdd2a6b
parentbe4fbbbcd2f20c2cd0421f530f45c5545c3a4886
netfilter: nf_tables: fix memleak when more than 255 elements expired

commit cf5000a7787cbc10341091d37245a42c119d26c5 upstream.

When more than 255 elements expired we're supposed to switch to a new gc
container structure.

This never happens: u8 type will wrap before reaching the boundary
and nft_trans_gc_space() always returns true.

This means we recycle the initial gc container structure and
lose track of the elements that came before.

While at it, don't deref 'gc' after we've passed it to call_rcu.

Fixes: 5f68718b34a5 ("netfilter: nf_tables: GC transaction API to avoid race with control plane")
Reported-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
include/net/netfilter/nf_tables.h
net/netfilter/nf_tables_api.c