]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
netfilter: nf_tables: Fix for duplicate device in netdev hooks
authorPhil Sutter <phil@nwl.cc>
Thu, 5 Mar 2026 12:01:44 +0000 (13:01 +0100)
committerFlorian Westphal <fw@strlen.de>
Tue, 10 Mar 2026 13:10:42 +0000 (14:10 +0100)
When handling NETDEV_REGISTER notification, duplicate device
registration must be avoided since the device may have been added by
nft_netdev_hook_alloc() already when creating the hook.

Suggested-by: Florian Westphal <fw@strlen.de>
Reported-by: syzbot+bb9127e278fa198e110c@syzkaller.appspotmail.com
Closes: https://syzkaller.appspot.com/bug?extid=bb9127e278fa198e110c
Fixes: a331b78a5525 ("netfilter: nf_tables: Respect NETDEV_REGISTER events")
Tested-by: Helen Koike <koike@igalia.com>
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
net/netfilter/nf_tables_api.c
net/netfilter/nft_chain_filter.c

index 1862bd7fe804a4d59af97917c21c493b7f66a0af..710f0ee21a34a425aa6987b692d8a34cb55a986a 100644 (file)
@@ -9688,7 +9688,7 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
                        break;
                case NETDEV_REGISTER:
                        /* NOP if not matching or already registered */
-                       if (!match || (changename && ops))
+                       if (!match || ops)
                                continue;
 
                        ops = kzalloc_obj(struct nf_hook_ops,
index b16185e9a6dd7211400e36e7ec34aefcf2c7b9ce..041426e3bdbf16cff7d721c6c31c1bb04d04722e 100644 (file)
@@ -344,7 +344,7 @@ static int nft_netdev_event(unsigned long event, struct net_device *dev,
                        break;
                case NETDEV_REGISTER:
                        /* NOP if not matching or already registered */
-                       if (!match || (changename && ops))
+                       if (!match || ops)
                                continue;
 
                        ops = kmemdup(&basechain->ops,