From 8b9b8abd4878d3116dda1c7d7b9736cda09691b6 Mon Sep 17 00:00:00 2001 From: Xie Changlong Date: Fri, 9 Aug 2019 14:19:07 +0800 Subject: nlm: check if nlm4 is initialized in nlm_priv Otherwise, gnfs will crash in following steps. 1) gluster v set nfs.disable off 2) gluster v set nfs.nlm off 3) kill -SIGUSR1 4) gnfs crash with SIGSEGV as follows: nlm_priv (this=this@entry=0x7f1ad00173b0) at nlm4.c:2742 0x00007f1acf89d29d in nfs_priv (this=0x7f1ad00173b0) at nfs.c:1662 0x00007f1ae2941085 in gf_proc_dump_single_xlator_info (trav=trav@entry=0x7f1ad00173b0) at statedump.c:502 0x00007f1ae29410b8 in gf_proc_dump_per_xlator_info (top=top@entry=0x7f1ad00173b0) at statedump.c:519 fixes: bz#1739360 Change-Id: Ib9b207a4ccb3226dbc2c449b77de348cbc9a3d3c Signed-off-by: Xie Changlong --- xlators/nfs/server/src/nlm4.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/xlators/nfs/server/src/nlm4.c b/xlators/nfs/server/src/nlm4.c index c3c1453a091..957f424fd42 100644 --- a/xlators/nfs/server/src/nlm4.c +++ b/xlators/nfs/server/src/nlm4.c @@ -57,6 +57,8 @@ gf_lock_t nlm_client_list_lk; /* race on this is harmless */ int nlm_grace_period = 50; +static gf_boolean_t nlm4_inited = _gf_false; + #define nlm4_validate_nfs3_state(request, state, status, label, retval) \ do { \ state = rpcsvc_request_program_private(request); \ @@ -2574,7 +2576,6 @@ nlm4svc_init(xlator_t *nfsx) }; FILE *pidfile = NULL; pid_t pid = -1; - static gf_boolean_t nlm4_inited = _gf_false; /* Already inited */ if (nlm4_inited) @@ -2733,7 +2734,7 @@ nlm_priv(xlator_t *this) gf_proc_dump_add_section("nfs.nlm"); - if (TRY_LOCK(&nlm_client_list_lk)) + if ((nlm4_inited == _gf_false) || TRY_LOCK(&nlm_client_list_lk)) goto out; list_for_each_entry(client, &nlm_client_list, nlm_clients) @@ -2766,7 +2767,8 @@ out: gf_proc_dump_build_key(key, "nlm", "statedump_error"); gf_proc_dump_write(key, "Unable to dump nlm state because " - "nlm_client_list_lk lock couldn't be acquired"); + "nlm is not initialised or nlm_client_list_lk " + "lock couldn't be acquired"); } return ret; -- cgit