linux-stable/net/batman-adv
Sven Eckelmann 01b0a8c047 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>
[ bp: 4.9 backported: drop modification of non-existing batadv_get_real_netdevice. ]
Signed-off-by: Sven Eckelmann <sven@narfation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2022-03-16 12:49:01 +01:00
..
Kconfig
Makefile
bat_algo.c
bat_algo.h
bat_iv_ogm.c batman-adv: Avoid WARN_ON timing related checks 2021-06-30 08:49:13 -04:00
bat_iv_ogm.h
bat_v.c batman-adv: Fix check of retrieved orig_gw in batadv_v_gw_is_eligible 2020-03-20 09:07:53 +01:00
bat_v.h
bat_v_elp.c batman-adv: Use explicit tvlv padding for ELP packets 2020-03-20 09:07:56 +01:00
bat_v_elp.h
bat_v_ogm.c batman-adv: Fix own OGM check in aggregated OGMs 2021-11-26 11:48:43 +01:00
bat_v_ogm.h
bitarray.c
bitarray.h
bridge_loop_avoidance.c batman-adv: mcast: fix duplicate mcast packets from BLA backbone to mesh 2021-11-26 11:48:43 +01:00
bridge_loop_avoidance.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from mesh 2020-10-01 20:40:18 +02:00
debugfs.c batman-adv: Fix debugfs path for renamed softif 2020-03-20 09:07:54 +01:00
debugfs.h batman-adv: Fix debugfs path for renamed softif 2020-03-20 09:07:54 +01:00
distributed-arp-table.c batman-adv: Fix rx packet/bytes stats on local ARP reply 2020-03-20 09:07:51 +01:00
distributed-arp-table.h
fragmentation.c batman-adv: Don't always reallocate the fragmentation skb head 2021-11-26 11:48:43 +01:00
fragmentation.h
gateway_client.c batman-adv: Avoid uninitialized chaddr when handling DHCP 2020-09-12 11:47:32 +02:00
gateway_client.h
gateway_common.c batman-adv: Initialize gw sel_class via batadv_algo 2020-03-20 09:07:50 +01:00
gateway_common.h
hard-interface.c batman-adv: Don't expect inter-netns unique iflink indices 2022-03-16 12:49:01 +01:00
hard-interface.h
hash.c
hash.h
icmp_socket.c
icmp_socket.h
log.c batman-adv: set .owner to THIS_MODULE 2020-12-02 08:31:27 +01:00
log.h
main.c net: batman-adv: fix error handling 2021-11-02 17:39:23 +01:00
main.h
multicast.c batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2021-11-26 11:48:43 +01:00
multicast.h batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2021-11-26 11:48:43 +01:00
netlink.c batman-adv: fix uninit-value in batadv_netlink_get_ifindex() 2019-09-16 08:19:33 +02:00
netlink.h
network-coding.c net: batman-adv: fix error handling 2021-11-02 17:39:23 +01:00
network-coding.h
originator.c batman-adv: Fix internal interface indices types 2020-03-20 09:07:53 +01:00
originator.h batman-adv: Fix internal interface indices types 2020-03-20 09:07:53 +01:00
packet.h
routing.c batman-adv: mcast/TT: fix wrongly dropped or rerouted packets 2020-10-01 20:40:17 +02:00
routing.h
send.c
send.h
soft-interface.c batman-adv: mcast: fix duplicate mcast packets in BLA backbone from LAN 2021-11-26 11:48:43 +01:00
soft-interface.h
sysfs.c batman-adv: Fix refcnt leak in batadv_store_throughput_override 2020-05-20 08:15:28 +02:00
sysfs.h
tp_meter.c
tp_meter.h
translation-table.c net: batman-adv: fix error handling 2021-11-02 17:39:23 +01:00
translation-table.h
tvlv.c batman-adv: Prevent duplicated tvlv handler 2018-10-20 09:51:30 +02:00
tvlv.h
types.h batman-adv: Avoid free/alloc race when handling OGM buffer 2020-03-20 09:07:55 +01:00