]> git.proxmox.com Git - mirror_ubuntu-jammy-kernel.git/commit
netfilter: nft_ct: protect nft_ct_pcpu_template_refcnt with mutex
authorPavel Skripkin <paskripkin@gmail.com>
Tue, 10 Aug 2021 12:59:20 +0000 (15:59 +0300)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 11 Aug 2021 09:22:19 +0000 (11:22 +0200)
commite3245a7b7b34bd2e97f744fd79463add6e9d41f4
tree2ac2841ab3b72613e88ce2046d4d6ef9463bd7ef
parent519133debcc19f5c834e7e28480b60bdc234fe02
netfilter: nft_ct: protect nft_ct_pcpu_template_refcnt with mutex

Syzbot hit use-after-free in nf_tables_dump_sets. The problem was in
missing lock protection for nft_ct_pcpu_template_refcnt.

Before commit f102d66b335a ("netfilter: nf_tables: use dedicated
mutex to guard transactions") all transactions were serialized by global
mutex, but then global mutex was changed to local per netnamespace
commit_mutex.

This change causes use-after-free bug, when 2 netnamespaces concurently
changing nft_ct_pcpu_template_refcnt without proper locking. Fix it by
adding nft_ct_pcpu_mutex and protect all nft_ct_pcpu_template_refcnt
changes with it.

Fixes: f102d66b335a ("netfilter: nf_tables: use dedicated mutex to guard transactions")
Reported-and-tested-by: syzbot+649e339fa6658ee623d3@syzkaller.appspotmail.com
Signed-off-by: Pavel Skripkin <paskripkin@gmail.com>
Acked-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nft_ct.c