Merge tag 'arm64-fixes' of git://git.kernel.org/pub/scm/linux/kernel/git/arm64/linux
[platform/kernel/linux-starfive.git] / ipc / namespace.c
index a26860a..6ecc30e 100644 (file)
@@ -145,10 +145,11 @@ void free_ipcs(struct ipc_namespace *ns, struct ipc_ids *ids,
 
 static void free_ipc_ns(struct ipc_namespace *ns)
 {
-       /* mq_put_mnt() waits for a grace period as kern_unmount()
-        * uses synchronize_rcu().
+       /*
+        * Caller needs to wait for an RCU grace period to have passed
+        * after making the mount point inaccessible to new accesses.
         */
-       mq_put_mnt(ns);
+       mntput(ns->mq_mnt);
        sem_exit_ns(ns);
        msg_exit_ns(ns);
        shm_exit_ns(ns);
@@ -169,6 +170,12 @@ static void free_ipc(struct work_struct *unused)
        struct ipc_namespace *n, *t;
 
        llist_for_each_entry_safe(n, t, node, mnt_llist)
+               mnt_make_shortterm(n->mq_mnt);
+
+       /* Wait for any last users to have gone away. */
+       synchronize_rcu();
+
+       llist_for_each_entry_safe(n, t, node, mnt_llist)
                free_ipc_ns(n);
 }