[Devel] [PATCH RHEL9 COMMIT] netfilter: nf_tables: netlink notifier might race to release objects

Konstantin Khorenko khorenko at virtuozzo.com
Thu Mar 2 14:29:40 MSK 2023


The commit is pushed to "branch-rh9-5.14.0-162.6.1.vz9.18.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh9-5.14.0-162.6.1.vz9.18.11
------>
commit 29778479d71b88333b413f910a07b8537bf7049a
Author: Pablo Neira Ayuso <pablo at netfilter.org>
Date:   Thu Feb 16 11:18:08 2023 +0200

    netfilter: nf_tables: netlink notifier might race to release objects
    
    commit release path is invoked via call_rcu and it runs lockless to
    release the objects after rcu grace period. The netlink notifier handler
    might win race to remove objects that the transaction context is still
    referencing from the commit release path.
    
    Call rcu_barrier() to ensure pending rcu callbacks run to completion
    if the list of transactions to be destroyed is not empty.
    
    mFixes: 6001a930ce03 ("netfilter: nftables: introduce table ownership")
    Reported-by: syzbot+8f747f62763bc6c32916 at syzkaller.appspotmail.com
    Signed-off-by: Pablo Neira Ayuso <pablo at netfilter.org>
    
    (cherry picked from ms commit d4bc8271db21ea9f1c86a1ca4d64999f184d4aae)
    https://jira.sw.ru/browse/PSBM-144955
    Signed-off-by: Alexander Atanasov <alexander.atanasov at virtuozzo.com>
    
    Feature: fix ms/net
---
 net/netfilter/nf_tables_api.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 77446ce9548d..b22854e34427 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -9821,6 +9821,8 @@ static int nft_rcv_nl_event(struct notifier_block *this, unsigned long event,
 	nft_net = nft_pernet(net);
 	deleted = 0;
 	mutex_lock(&nft_net->commit_mutex);
+	if (!list_empty(&nf_tables_destroy_list))
+		rcu_barrier();
 again:
 	list_for_each_entry(table, &nft_net->tables, list) {
 		if (nft_table_has_owner(table) &&


More information about the Devel mailing list