linux-stable/net/batman-adv
Sven Eckelmann a9c4a74ad5 batman-adv: Don't expect inter-netns unique iflink indices
commit 6c1f41afc1 upstream.

The ifindex doesn't have to be unique for multiple network namespaces on
the same machine.

  $ ip netns add test1
  $ ip -net test1 link add dummy1 type dummy
  $ ip netns add test2
  $ ip -net test2 link add dummy2 type dummy

  $ ip -net test1 link show dev dummy1
  6: dummy1: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
      link/ether 96:81:55:1e:dd:85 brd ff:ff:ff:ff:ff:ff
  $ ip -net test2 link show dev dummy2
  6: dummy2: <BROADCAST,NOARP> mtu 1500 qdisc noop state DOWN mode DEFAULT group default qlen 1000
      link/ether 5a:3c:af:35:07:c3 brd ff:ff:ff:ff:ff:ff

But the batman-adv code to walk through the various layers of virtual
interfaces uses this assumption because dev_get_iflink handles it
internally and doesn't return the actual netns of the iflink. And
dev_get_iflink only documents the situation where ifindex == iflink for
physical devices.

But only checking for dev->netdev_ops->ndo_get_iflink is also not an option
because ipoib_get_iflink implements it even when it sometimes returns an
iflink != ifindex and sometimes iflink == ifindex. The caller must
therefore make sure itself to check both netns and iflink + ifindex for
equality. Only when they are equal, a "physical" interface was detected
which should stop the traversal. On the other hand, vxcan_get_iflink can
also return 0 in case there was currently no valid peer. In this case, it
is still necessary to stop.

Fixes: b7eddd0b39 ("batman-adv: prevent using any virtual device created on batman-adv as hard-interface")
Fixes: 5ed4a460a1 ("batman-adv: additional checks for virtual interfaces on top of WiFi")
Reported-by: Sabrina Dubroca <sd@queasysnail.net>
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-08 19:09:33 +01:00
..
bat_algo.c
bat_algo.h
bat_iv_ogm.c batman-adv: Avoid WARN_ON timing related checks 2021-06-23 14:42:41 +02:00
bat_iv_ogm.h
bat_v.c
bat_v.h
bat_v_elp.c batman-adv: Migrate to linux/prandom.h 2020-08-18 19:39:54 +02:00
bat_v_elp.h
bat_v_ogm.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-09-04 21:28:59 -07:00
bat_v_ogm.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c net: batman-adv: fix error handling 2021-11-02 19:48:22 +01:00
bridge_loop_avoidance.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-09-15 10:05:24 +02:00
debugfs.c
debugfs.h
distributed-arp-table.c batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
distributed-arp-table.h batman-adv: remove unused inline function batadv_arp_change_timeout 2020-04-24 15:22:41 +02:00
fragmentation.c batman-adv: Don't always reallocate the fragmentation skb head 2020-11-27 08:02:55 +01:00
fragmentation.h
gateway_client.c batman-adv: Avoid uninitialized chaddr when handling DHCP 2020-08-18 19:40:03 +02:00
gateway_client.h
gateway_common.c
gateway_common.h
hard-interface.c batman-adv: Don't expect inter-netns unique iflink indices 2022-03-08 19:09:33 +01:00
hard-interface.h batman-adv: Drop unused function batadv_hardif_remove_interfaces() 2020-08-18 19:39:53 +02:00
hash.c
hash.h
icmp_socket.c batadv_socket_read(): get rid of pointless access_ok() 2020-05-20 20:31:33 -04:00
icmp_socket.h
Kconfig batman-adv: Disable CONFIG_BATMAN_ADV_SYSFS by default 2020-01-01 00:57:07 +01:00
log.c batman-adv: set .owner to THIS_MODULE 2020-11-15 11:43:56 +01:00
log.h batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
main.c net: batman-adv: fix error handling 2021-11-02 19:48:22 +01:00
main.h batman-adv: Start new development cycle 2020-08-18 19:39:53 +02:00
Makefile
multicast.c batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-11 15:25:00 +01:00
multicast.h batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-11 15:25:00 +01:00
netlink.c batman-adv: allow netlink usage in unprivileged containers 2022-01-27 10:54:11 +01:00
netlink.h
network-coding.c net: batman-adv: fix error handling 2021-11-02 19:48:22 +01:00
network-coding.h
originator.c batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
originator.h
routing.c batman-adv: mcast/TT: fix wrongly dropped or rerouted packets 2020-09-05 08:45:46 +02:00
routing.h
send.c batman-adv: Drop repeated words in comments 2020-08-18 19:39:54 +02:00
send.h
soft-interface.c batman-adv: mcast: don't send link-local multicast to mcast routers 2022-01-11 15:25:00 +01:00
soft-interface.h
sysfs.c batman-adv: Fix refcnt leak in batadv_store_throughput_override 2020-04-21 10:08:05 +02:00
sysfs.h
tp_meter.c batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
tp_meter.h
trace.c
trace.h batman-adv: trace: Drop unneeded types.h include 2020-04-21 10:07:31 +02:00
translation-table.c net: batman-adv: fix error handling 2021-11-02 19:48:22 +01:00
translation-table.h
tvlv.c batman-adv: Fix typos and grammar in documentation 2020-06-26 10:36:30 +02:00
tvlv.h
types.h batman-adv: types.h: delete duplicated words 2020-08-18 19:39:53 +02:00