Without rtnl_lock held, a hardif might be retrieved as primary interface of
a meshif, but then (while operating on this interface) getting decoupled
from the mesh interface. In this case, the meshif still exists but the
pointer from the primary hardif to the meshif is set to NULL.

The mesh_iface must be checked first to be non-NULL before continuing to
send an ARP request using meshif.

Cc: [email protected]
Fixes: 23721387c409 ("batman-adv: add basic bridge loop avoidance code")
Reported-by: Ido Schimmel <[email protected]>
Reported-by: [email protected]
Closes: https://syzkaller.appspot.com/bug?extid=9fdcc9f05a98a540b816
Signed-off-by: Sven Eckelmann <[email protected]>
---
Another reason why I should sit down and rebase + polish Nora Schiffer's
"remove global hardif list" patchset. But first, I need to get the pile of
other fixes out or otherwise I will never get out of these endless
conflicts.

Btw. thanks to Ido for checking the backtrace in more detail and giving a
really precise reason.
---
 net/batman-adv/bridge_loop_avoidance.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/net/batman-adv/bridge_loop_avoidance.c 
b/net/batman-adv/bridge_loop_avoidance.c
index cec11f12..c801b3ed 100644
--- a/net/batman-adv/bridge_loop_avoidance.c
+++ b/net/batman-adv/bridge_loop_avoidance.c
@@ -356,12 +356,14 @@ static void batadv_bla_send_claim(struct batadv_priv 
*bat_priv, const u8 *mac,
               sizeof(local_claim_dest));
        local_claim_dest.type = claimtype;
 
-       mesh_iface = primary_if->mesh_iface;
+       mesh_iface = READ_ONCE(primary_if->mesh_iface);
+       if (!mesh_iface)
+               goto out;
 
        skb = arp_create(ARPOP_REPLY, ETH_P_ARP,
                         /* IP DST: 0.0.0.0 */
                         zeroip,
-                        primary_if->mesh_iface,
+                        mesh_iface,
                         /* IP SRC: 0.0.0.0 */
                         zeroip,
                         /* Ethernet DST: Broadcast */

---
base-commit: ff182fc0c666754e3f35f7b63c9ccf0dff239e52
change-id: 20260519-bla-unchecked-hardif-meshif-deref-ad83d47cba80

Best regards,
--  
Sven Eckelmann <[email protected]>

Reply via email to