]> www.infradead.org Git - users/jedix/linux-maple.git/commit
batman-adv: fix duplicate MAC address check
authorMatthias Schiffer <mschiffer@universe-factory.net>
Wed, 16 Apr 2025 18:37:56 +0000 (20:37 +0200)
committerSimon Wunderlich <sw@simonwunderlich.de>
Wed, 16 Apr 2025 18:52:33 +0000 (20:52 +0200)
commit8772cc49e0b8ab782e475ce5ef659eedab601a09
tree741cabdaf0b1b209d72aa6cc5c00c9319d0e0653
parent61f96e684edd28ca40555ec49ea1555df31ba619
batman-adv: fix duplicate MAC address check

batadv_check_known_mac_addr() is both too lenient and too strict:

- It is called from batadv_hardif_add_interface(), which means that it
  checked interfaces that are not used for batman-adv at all. Move it
  to batadv_hardif_enable_interface(). Also, restrict it to hardifs of
  the same mesh interface; different mesh interfaces should not interact
  at all. The batadv_check_known_mac_addr() argument is changed from
  `struct net_device` to `struct batadv_hard_iface` to achieve this.
- The check only cares about hardifs in BATADV_IF_ACTIVE and
  BATADV_IF_TO_BE_ACTIVATED states, but interfaces in BATADV_IF_INACTIVE
  state should be checked as well, or the following steps will not
  result in a warning then they should:

  - Add two interfaces in down state with different MAC addresses to
    a mesh as hardifs
  - Change the MAC addresses so they conflict
  - Set interfaces to up state

  Now there will be two active hardifs with the same MAC address, but no
  warning. Fix by only ignoring hardifs in BATADV_IF_NOT_IN_USE state.

The RCU lock can be dropped, as we're holding RTNL anyways when the
function is called.

Fixes: c6c8fea29769 ("net: Add batman-adv meshing protocol")
Signed-off-by: Matthias Schiffer <mschiffer@universe-factory.net>
Signed-off-by: Simon Wunderlich <sw@simonwunderlich.de>
net/batman-adv/hard-interface.c