Skip to content

Commit b7cdc5a

Browse files
Phil SutterFlorian Westphal
authored andcommitted
netfilter: nf_tables: Fix for duplicate device in netdev hooks
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: a331b78 ("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>
1 parent 6f1a914 commit b7cdc5a

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

net/netfilter/nf_tables_api.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9688,7 +9688,7 @@ static int nft_flowtable_event(unsigned long event, struct net_device *dev,
96889688
break;
96899689
case NETDEV_REGISTER:
96909690
/* NOP if not matching or already registered */
9691-
if (!match || (changename && ops))
9691+
if (!match || ops)
96929692
continue;
96939693

96949694
ops = kzalloc_obj(struct nf_hook_ops,

net/netfilter/nft_chain_filter.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ static int nft_netdev_event(unsigned long event, struct net_device *dev,
344344
break;
345345
case NETDEV_REGISTER:
346346
/* NOP if not matching or already registered */
347-
if (!match || (changename && ops))
347+
if (!match || ops)
348348
continue;
349349

350350
ops = kmemdup(&basechain->ops,

0 commit comments

Comments
 (0)