OSDN Git Service

netfilter: nftables: fix possible UAF over chains from packet path in netns
authorPablo Neira Ayuso <pablo@netfilter.org>
Tue, 2 Feb 2021 15:07:37 +0000 (16:07 +0100)
committerPablo Neira Ayuso <pablo@netfilter.org>
Wed, 3 Feb 2021 23:33:09 +0000 (00:33 +0100)
commit767d1216bff82507c945e92fe719dff2083bb2f4
tree89aa5dc4df79d38b67a479ace62e396d3b78dd11
parenta3005b0f83f217c888393c6bf9cd36e3d1616bca
netfilter: nftables: fix possible UAF over chains from packet path in netns

Although hooks are released via call_rcu(), chain and rule objects are
immediately released while packets are still walking over these bits.

This patch adds the .pre_exit callback which is invoked before
synchronize_rcu() in the netns framework to stay safe.

Remove a comment which is not valid anymore since the core does not use
synchronize_net() anymore since 8c873e219970 ("netfilter: core: free
hooks with call_rcu").

Suggested-by: Florian Westphal <fw@strlen.de>
Fixes: df05ef874b28 ("netfilter: nf_tables: release objects on netns destruction")
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c