net: bridge: multicast: use rcu to access port list from br_multicast_start_querier [Linux 3.16.72]

This Linux kernel change "net: bridge: multicast: use rcu to access port list from br_multicast_start_querier" is included in the Linux 3.16.72 release. This change is authored by Nikolay Aleksandrov <nikolay [at] cumulusnetworks.com> on Thu Apr 11 15:08:25 2019 +0300. The commit for this change in Linux stable tree is 83a138f (patch) which is from upstream commit c5b493c. The same Linux upstream change may have been applied to various maintained Linux releases and you can find all Linux releases containing changes from upstream c5b493c.

net: bridge: multicast: use rcu to access port list from br_multicast_start_querier

commit c5b493ce192bd7a4e7bd073b5685aad121eeef82 upstream.

br_multicast_start_querier() walks over the port list but it can be
called from a timer with only multicast_lock held which doesn't protect
the port list, so use RCU to walk over it.

Fixes: c83b8fab06fc ("bridge: Restart queries when last querier expires")
Signed-off-by: Nikolay Aleksandrov <[email protected]>
Signed-off-by: David S. Miller <[email protected]>
Signed-off-by: Ben Hutchings <[email protected]>

There are 4 lines of Linux source code added/deleted in this change. Code changes to Linux kernel are as follows.

 net/bridge/br_multicast.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c
index 3c59418..7725dd9 100644
--- a/net/bridge/br_multicast.c
+++ b/net/bridge/br_multicast.c
@@ -2036,7 +2036,8 @@ static void br_multicast_start_querier(struct net_bridge *br,

    __br_multicast_open(br, query);

-   list_for_each_entry(port, &br->port_list, list) {
+   rcu_read_lock();
+   list_for_each_entry_rcu(port, &br->port_list, list) {
        if (port->state == BR_STATE_DISABLED ||
            port->state == BR_STATE_BLOCKING)
            continue;
@@ -2048,6 +2049,7 @@ static void br_multicast_start_querier(struct net_bridge *br,
            br_multicast_enable(&port->ip6_own_query);
 #endif
    }
+   rcu_read_unlock();
 }

 int br_multicast_toggle(struct net_bridge *br, unsigned long val)

Leave a Reply

Your email address will not be published. Required fields are marked *