Commit b7cdc5a9 authored by Phil Sutter's avatar Phil Sutter Committed by Florian Westphal
Browse files

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: default avatarFlorian Westphal <fw@strlen.de>
Reported-by: default avatar <syzbot+bb9127e278fa198e110c@syzkaller.appspotmail.com>
Closes: https://syzkaller.appspot.com/bug?extid=bb9127e278fa198e110c


Fixes: a331b78a ("netfilter: nf_tables: Respect NETDEV_REGISTER events")
Tested-by: default avatarHelen Koike <koike@igalia.com>
Signed-off-by: default avatarPhil Sutter <phil@nwl.cc>
Signed-off-by: default avatarFlorian Westphal <fw@strlen.de>
parent 6f1a9140
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -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,
+1 −1
Original line number Diff line number Diff line
@@ -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,