Home Home > GIT Browse
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.com>2018-11-01 14:04:41 +1100
committerNeilBrown <neilb@suse.com>2018-11-01 14:05:03 +1100
commit89f81b69fd1635e2e3902196087d722550a8400f (patch)
treec6e0c4a9a5ce0f4c4ee546ec19ecaf69ed300d2e
parente5770368ac5b21f751723c0863c87d51aaea6fa9 (diff)
lockd: fix "list_add double add" caused by legacy signal
interface (git-fixes).
-rw-r--r--patches.fixes/lockd-fix-list_add-double-add-caused-by-legacy-signa.patch82
-rw-r--r--series.conf1
2 files changed, 83 insertions, 0 deletions
diff --git a/patches.fixes/lockd-fix-list_add-double-add-caused-by-legacy-signa.patch b/patches.fixes/lockd-fix-list_add-double-add-caused-by-legacy-signa.patch
new file mode 100644
index 0000000000..fed74317b3
--- /dev/null
+++ b/patches.fixes/lockd-fix-list_add-double-add-caused-by-legacy-signa.patch
@@ -0,0 +1,82 @@
+From: Vasily Averin <vvs@virtuozzo.com>
+Date: Mon, 13 Nov 2017 07:25:40 +0300
+Subject: [PATCH] lockd: fix "list_add double add" caused by legacy signal
+ interface
+Git-commit: 81833de1a46edce9ca20cfe079872ac1c20ef359
+Patch-mainline: v4.15
+References: git-fixes
+
+restart_grace() uses hardcoded init_net.
+It can cause to "list_add double add" in following scenario:
+
+1) nfsd and lockd was started in several net namespaces
+2) nfsd in init_net was stopped (lockd was not stopped because
+ it have users from another net namespaces)
+3) lockd got signal, called restart_grace() -> set_grace_period()
+ and enabled lock_manager in hardcoded init_net.
+4) nfsd in init_net is started again,
+ its lockd_up() calls set_grace_period() and tries to add
+ lock_manager into init_net 2nd time.
+
+Jeff Layton suggest:
+"Make it safe to call locks_start_grace multiple times on the same
+lock_manager. If it's already on the global grace_list, then don't try
+to add it again. (But we don't intentionally add twice, so for now we
+WARN about that case.)
+
+With this change, we also need to ensure that the nfsd4 lock manager
+initializes the list before we call locks_start_grace. While we're at
+it, move the rest of the nfsd_net initialization into
+nfs4_state_create_net. I see no reason to have it spread over two
+functions like it is today."
+
+Suggested patch was updated to generate warning in described situation.
+
+Suggested-by: Jeff Layton <jlayton@redhat.com>
+Signed-off-by: Vasily Averin <vvs@virtuozzo.com>
+Signed-off-by: J. Bruce Fields <bfields@redhat.com>
+Acked-by: NeilBrown <neilb@suse.com>
+
+---
+ fs/nfs_common/grace.c | 6 +++++-
+ fs/nfsd/nfs4state.c | 7 ++++---
+ 2 files changed, 9 insertions(+), 4 deletions(-)
+
+--- a/fs/nfs_common/grace.c
++++ b/fs/nfs_common/grace.c
+@@ -30,7 +30,11 @@ locks_start_grace(struct net *net, struc
+ struct list_head *grace_list = net_generic(net, grace_net_id);
+
+ spin_lock(&grace_lock);
+- list_add(&lm->list, grace_list);
++ if (list_empty(&lm->list))
++ list_add(&lm->list, grace_list);
++ else
++ WARN(1, "double list_add attempt detected in net %x %s\n",
++ net->ns.inum, (net == &init_net) ? "(init_net)" : "");
+ spin_unlock(&grace_lock);
+ }
+ EXPORT_SYMBOL_GPL(locks_start_grace);
+--- a/fs/nfsd/nfs4state.c
++++ b/fs/nfsd/nfs4state.c
+@@ -6963,6 +6963,10 @@ static int nfs4_state_create_net(struct
+ INIT_LIST_HEAD(&nn->sessionid_hashtbl[i]);
+ nn->conf_name_tree = RB_ROOT;
+ nn->unconf_name_tree = RB_ROOT;
++ nn->boot_time = get_seconds();
++ nn->grace_ended = false;
++ nn->nfsd4_manager.block_opens = true;
++ INIT_LIST_HEAD(&nn->nfsd4_manager.list);
+ INIT_LIST_HEAD(&nn->client_lru);
+ INIT_LIST_HEAD(&nn->close_lru);
+ INIT_LIST_HEAD(&nn->del_recall_lru);
+@@ -7022,9 +7026,6 @@ nfs4_state_start_net(struct net *net)
+ ret = nfs4_state_create_net(net);
+ if (ret)
+ return ret;
+- nn->boot_time = get_seconds();
+- nn->grace_ended = false;
+- nn->nfsd4_manager.block_opens = true;
+ locks_start_grace(net, &nn->nfsd4_manager);
+ nfsd4_client_tracking_init(net);
+ printk(KERN_INFO "NFSD: starting %ld-second grace period (net %p)\n",
diff --git a/series.conf b/series.conf
index a47d969cfa..58c034c86d 100644
--- a/series.conf
+++ b/series.conf
@@ -10261,6 +10261,7 @@
patches.fixes/0004-lockd-lost-rollback-of-set_grace_period-in-lockd_dow.patch
patches.fixes/0005-nfsd-fix-panic-in-posix_unblock_lock-called-from-nfs.patch
patches.fixes/race-of-lockd-inetaddr-notifiers-vs-nlmsvc_rqst-chan.patch
+ patches.fixes/lockd-fix-list_add-double-add-caused-by-legacy-signa.patch
patches.fixes/mm-memory_hotplug-do-not-back-off-draining-pcp-free-.patch
patches.fixes/mm-oom_reaper-gather-each-vma-to-prevent-leaking-TLB.patch
patches.fixes/mm-cma-fix-alloc_contig_range-ret-code-potential-lea.patch