netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call
@ 2018-10-24 11:15 Taehee Yoo
  2018-10-24 17:56 ` Song Liu
  2018-10-25 22:56 ` Daniel Borkmann
  0 siblings, 2 replies; 3+ messages in thread
From: Taehee Yoo @ 2018-10-24 11:15 UTC (permalink / raw)
  To: daniel, ast; +Cc: netdev, john.fastabend, ap420073

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>
---
 kernel/bpf/devmap.c | 3 +--
 1 file changed, 1 insertion(+), 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)
-- 
2.17.1

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call
  2018-10-24 11:15 [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call Taehee Yoo
@ 2018-10-24 17:56 ` Song Liu
  2018-10-25 22:56 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Song Liu @ 2018-10-24 17:56 UTC (permalink / raw)
  To: ap420073; +Cc: Daniel Borkmann, Alexei Starovoitov, Networking, John Fastabend

On Wed, Oct 24, 2018 at 4:16 AM Taehee Yoo <ap420073@gmail.com> wrote:
>
> 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>

> ---
>  kernel/bpf/devmap.c | 3 +--
>  1 file changed, 1 insertion(+), 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)
> --
> 2.17.1
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call
  2018-10-24 11:15 [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call Taehee Yoo
  2018-10-24 17:56 ` Song Liu
@ 2018-10-25 22:56 ` Daniel Borkmann
  1 sibling, 0 replies; 3+ messages in thread
From: Daniel Borkmann @ 2018-10-25 22:56 UTC (permalink / raw)
  To: Taehee Yoo, ast; +Cc: netdev, john.fastabend

On 10/24/2018 01:15 PM, Taehee Yoo wrote:
> 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>

Applied to bpf, thanks Taehee!

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-10-26  7:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-10-24 11:15 [PATCH v2 bpf] bpf: devmap: fix wrong interface selection in notifier_call Taehee Yoo
2018-10-24 17:56 ` Song Liu
2018-10-25 22:56 ` Daniel Borkmann

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).