]> Git Repo - linux.git/commitdiff
can: gw: synchronize rcu operations before removing gw job entry
authorOliver Hartkopp <[email protected]>
Fri, 18 Jun 2021 17:36:45 +0000 (19:36 +0200)
committerMarc Kleine-Budde <[email protected]>
Sat, 19 Jun 2021 21:53:43 +0000 (23:53 +0200)
can_can_gw_rcv() is called under RCU protection, so after calling
can_rx_unregister(), we have to call synchronize_rcu in order to wait
for any RCU read-side critical sections to finish before removing the
kmem_cache entry with the referenced gw job entry.

Link: https://lore.kernel.org/r/[email protected]
Fixes: c1aabdf379bc ("can-gw: add netlink based CAN routing")
Cc: linux-stable <[email protected]>
Signed-off-by: Oliver Hartkopp <[email protected]>
Signed-off-by: Marc Kleine-Budde <[email protected]>
net/can/gw.c

index ba4124805602972bcbef0b0fa2e1b352aa345497..d8861e862f157aec36c417b71eb7e8f59bd064b9 100644 (file)
@@ -596,6 +596,7 @@ static int cgw_notifier(struct notifier_block *nb,
                        if (gwj->src.dev == dev || gwj->dst.dev == dev) {
                                hlist_del(&gwj->list);
                                cgw_unregister_filter(net, gwj);
+                               synchronize_rcu();
                                kmem_cache_free(cgw_cache, gwj);
                        }
                }
@@ -1154,6 +1155,7 @@ static void cgw_remove_all_jobs(struct net *net)
        hlist_for_each_entry_safe(gwj, nx, &net->can.cgw_list, list) {
                hlist_del(&gwj->list);
                cgw_unregister_filter(net, gwj);
+               synchronize_rcu();
                kmem_cache_free(cgw_cache, gwj);
        }
 }
@@ -1222,6 +1224,7 @@ static int cgw_remove_job(struct sk_buff *skb, struct nlmsghdr *nlh,
 
                hlist_del(&gwj->list);
                cgw_unregister_filter(net, gwj);
+               synchronize_rcu();
                kmem_cache_free(cgw_cache, gwj);
                err = 0;
                break;
This page took 0.060752 seconds and 4 git commands to generate.