summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTaehee Yoo2018-10-24 13:15:17 +0200
committerDaniel Borkmann2018-10-26 00:32:21 +0200
commitf592f804831f1cf9d1f9966f58c80f150e6829b5 (patch)
tree1b4368acf0867c3ace26466ee8b44e20755acf34
parentocteontx2-af: Use GFP_ATOMIC under spin lock (diff)
downloadkernel-qcow2-linux-f592f804831f1cf9d1f9966f58c80f150e6829b5.tar.gz
kernel-qcow2-linux-f592f804831f1cf9d1f9966f58c80f150e6829b5.tar.xz
kernel-qcow2-linux-f592f804831f1cf9d1f9966f58c80f150e6829b5.zip
bpf: devmap: fix wrong interface selection in notifier_call
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>
-rw-r--r--kernel/bpf/devmap.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/kernel/bpf/devmap.c b/kernel/bpf/devmap.c
index 141710b82a6c..191b79948424 100644
--- a/kernel/bpf/devmap.c
+++ b/kernel/bpf/devmap.c
@@ -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)