multipathd: crash in reconfigure CLI command
authorHannes Reinecke <hare@suse.de>
Fri, 18 Feb 2011 08:34:18 +0000 (09:34 +0100)
committerHannes Reinecke <hare@suse.de>
Wed, 18 May 2011 08:49:34 +0000 (10:49 +0200)
The 'reconfigure' CLI command doesn't take the vector lock,
so if multipathd is processing a table / udev event at the
same time it'll crash.

Signed-off-by: Hannes Reinecke <hare@suse.de>
multipathd/main.c

index 6867f23..ffde5be 100644 (file)
@@ -1257,7 +1257,9 @@ int
 reconfigure (struct vectors * vecs)
 {
        struct config * old = conf;
+       int retval = 1;
 
+       lock(vecs->lock);
        /*
         * free old map and path vectors ... they use old conf state
         */
@@ -1270,19 +1272,16 @@ reconfigure (struct vectors * vecs)
        vecs->pathvec = NULL;
        conf = NULL;
 
-       if (load_config(DEFAULT_CONFIGFILE))
-               return 1;
-
-       conf->verbosity = old->verbosity;
-
-       if (!conf->checkint) {
-               conf->checkint = DEFAULT_CHECKINT;
-               conf->max_checkint = MAX_CHECKINT(conf->checkint);
+       if (!load_config(DEFAULT_CONFIGFILE)) {
+               conf->verbosity = old->verbosity;
+               conf->daemon = 1;
+               configure(vecs, 1);
+               free_config(old);
+               retval = 0;
        }
-       conf->daemon = 1;
-       configure(vecs, 1);
-       free_config(old);
-       return 0;
+
+       unlock(vecs->lock);
+       return retval;
 }
 
 static struct vectors *
@@ -1336,9 +1335,7 @@ sighup (int sig)
 {
        condlog(2, "reconfigure (SIGHUP)");
 
-       lock(gvecs->lock);
        reconfigure(gvecs);
-       unlock(gvecs->lock);
 
 #ifdef _DEBUG_
        dbg_free_final(NULL);