]> asedeno.scripts.mit.edu Git - linux.git/commit
netfilter: nf_tables: fix module unload race
authorFlorian Westphal <fw@strlen.de>
Mon, 11 Jun 2018 11:20:35 +0000 (13:20 +0200)
committerPablo Neira Ayuso <pablo@netfilter.org>
Tue, 12 Jun 2018 17:28:18 +0000 (19:28 +0200)
commit71ad00c50d77e507138c792a9646b53c16f22e11
treec1e02e45c573ae8003390fc95923e48cc70440b0
parent215a31f19dedd4e92a67cf5a9717ee898d012b3a
netfilter: nf_tables: fix module unload race

We must first remove the nfnetlink protocol handler when nf_tables module
is unloaded -- we don't want userspace to submit new change requests once
we've started to tear down nft state.

Furthermore, nfnetlink must not call any subsystem function after
call_batch returned -EAGAIN.

EAGAIN means the subsys mutex was dropped, so its unlikely but possible that
nf_tables subsystem was removed due to 'rmmod nf_tables' on another cpu.

Therefore, we must abort batch completely and not move on to next part of
the batch.

Last, we can't invoke ->abort unless we've checked that the subsystem is
still registered.

Change netns exit path of nf_tables to make sure any incompleted
transaction gets removed on exit.

Signed-off-by: Florian Westphal <fw@strlen.de>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
net/netfilter/nf_tables_api.c
net/netfilter/nfnetlink.c