Skip to content

Commit d2eecc5

Browse files
committed
Merge branch 'bridge-mc-fixes'
Nikolay Aleksandrov says: ==================== net: bridge: multicast: fix automatic router port marking races While working on per-vlan multicast snooping I found two race conditions when multicast snooping is enabled. They're identical and happen when the router port list is modified without the multicast lock. One requires a PIM hello message to be received on a port and the other an MRD advertisement. To fix them we just need to take the multicast_lock when adding the ports to the router port list (marking them as router ports). Tested on an affected setup by generating the required packets while modifying the port list in parallel. ==================== Signed-off-by: David S. Miller <[email protected]>
2 parents a5de4be + 000b728 commit d2eecc5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

net/bridge/br_multicast.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3264,7 +3264,9 @@ static void br_multicast_pim(struct net_bridge *br,
32643264
pim_hdr_type(pimhdr) != PIM_TYPE_HELLO)
32653265
return;
32663266

3267+
spin_lock(&br->multicast_lock);
32673268
br_ip4_multicast_mark_router(br, port);
3269+
spin_unlock(&br->multicast_lock);
32683270
}
32693271

32703272
static int br_ip4_multicast_mrd_rcv(struct net_bridge *br,
@@ -3275,7 +3277,9 @@ static int br_ip4_multicast_mrd_rcv(struct net_bridge *br,
32753277
igmp_hdr(skb)->type != IGMP_MRDISC_ADV)
32763278
return -ENOMSG;
32773279

3280+
spin_lock(&br->multicast_lock);
32783281
br_ip4_multicast_mark_router(br, port);
3282+
spin_unlock(&br->multicast_lock);
32793283

32803284
return 0;
32813285
}
@@ -3343,7 +3347,9 @@ static void br_ip6_multicast_mrd_rcv(struct net_bridge *br,
33433347
if (icmp6_hdr(skb)->icmp6_type != ICMPV6_MRDISC_ADV)
33443348
return;
33453349

3350+
spin_lock(&br->multicast_lock);
33463351
br_ip6_multicast_mark_router(br, port);
3352+
spin_unlock(&br->multicast_lock);
33473353
}
33483354

33493355
static int br_multicast_ipv6_rcv(struct net_bridge *br,

0 commit comments

Comments
 (0)