]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
bpf: devmap: fix wrong interface selection in notifier_call
authorTaehee Yoo <ap420073@gmail.com>
Wed, 24 Oct 2018 11:15:17 +0000 (20:15 +0900)
committerDaniel Borkmann <daniel@iogearbox.net>
Thu, 25 Oct 2018 22:32:21 +0000 (00:32 +0200)
The dev_map_notification() removes interface in devmap if
unregistering interface's ifindex is same.
But only checking ifindex is not enough because other netns can have
same ifindex. so that wrong interface selection could occurred.
Hence netdev pointer comparison code is added.

v2: compare netdev pointer instead of using net_eq() (Daniel Borkmann)
v1: Initial patch

Fixes: 2ddf71e23cc2 ("net: add notifier hooks for devmap bpf map")
Signed-off-by: Taehee Yoo <ap420073@gmail.com>
Acked-by: Song Liu <songliubraving@fb.com>
Signed-off-by: Daniel Borkmann <daniel@iogearbox.net>
kernel/bpf/devmap.c

index 141710b82a6c4b117ecc819c856921f416a7aaf6..191b79948424f4b21b7aa120abc03801264bf0a6 100644 (file)
@@ -512,8 +512,7 @@ static int dev_map_notification(struct notifier_block *notifier,
                                struct bpf_dtab_netdev *dev, *odev;
 
                                dev = READ_ONCE(dtab->netdev_map[i]);
-                               if (!dev ||
-                                   dev->dev->ifindex != netdev->ifindex)
+                               if (!dev || netdev != dev->dev)
                                        continue;
                                odev = cmpxchg(&dtab->netdev_map[i], dev, NULL);
                                if (dev == odev)