Forwarded: Don't allow device double-register

syzbot
2026-03-04T13:38:26Z

Subject: Don't allow device double-register
Author: fw@strlen.de

#syz test: https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git main

diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index fd7f7e4e2a43..b0fd94427a5a 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -9677,8 +9677,11 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
kfree_rcu(ops, rcu);
break;
case NETDEV_REGISTER:
+ if (ops)
+ pr_warn("reg %px for %s, again, hook ifname %s (%d) cn %d\n", ops, dev->name, hook->ifname, hook->ifnamelen, changename);
+
/* NOP if not matching or already registered */
- if (!match || (changename && ops))
+ if (!match || ops)
continue;

ops = kzalloc_obj(struct nf_hook_ops,
@@ -9701,7 +9704,6 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
list_add_tail_rcu(&ops->list, &hook->ops_list);
break;
}
- break;
}
return 0;
}