]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
netfilter: nft_compat: destroy function must not have side effects
authorFlorian Westphal <fw@strlen.de>
Mon, 14 Jan 2019 13:28:50 +0000 (14:28 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 13 Mar 2019 21:03:59 +0000 (14:03 -0700)
commitb990e9ce05c0a7999e2b85fc911ccf78392d03a9
tree5c6f023de438bb32a0b2d0518e6ca30bf39697f8
parentae9dc017941ca3e8f815e261714719943f41d161
netfilter: nft_compat: destroy function must not have side effects

[ Upstream commit b2e3d68d1251a051a620f9086e18f7ffa6833b5b ]

The nft_compat destroy function deletes the nft_xt object from a list.
This isn't allowed anymore. Destroy functions are called asynchronously,
i.e. next batch can find the object that has a pending ->destroy()
invocation:

cpu0                       cpu1
 worker
   ->destroy               for_each_entry()
                     if (x == ...
        return x->ops;
     list_del(x)
     kfree_rcu(x)
                           expr->ops->... // ops was free'd

To resolve this, the list_del needs to occur before the transaction
mutex gets released.  nf_tables has a 'deactivate' hook for this
purpose, so use that to unlink the object from the list.

Fixes: 0935d5588400 ("netfilter: nf_tables: asynchronous release")
Reported-by: Taehee Yoo <ap420073@gmail.com>
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>
net/netfilter/nft_compat.c