CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: agk@sourceware.org 2006-12-01 22:48:47 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Fix VG clustered read locks to use PR not CR. VG metadata reads were not being locked out during metadata updates. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.512&r2=1.513 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.11&r2=1.12 --- LVM2/WHATS_NEW 2006/11/30 23:11:39 1.512 +++ LVM2/WHATS_NEW 2006/12/01 22:48:47 1.513 @@ -1,5 +1,6 @@ Version 2.02.16 - ==================================== + Fix VG clustered read locks to use PR not CR. Adjust some alignments for ia64/sparc. Fix mirror segment removal to use temporary error segment. Always compile debug logging into clvmd. --- LVM2/daemons/clvmd/clvmd-command.c 2006/10/09 14:11:57 1.11 +++ LVM2/daemons/clvmd/clvmd-command.c 2006/12/01 22:48:47 1.12 @@ -191,7 +191,11 @@ dm_hash_remove(lock_hash, lockname); } else { - + /* Read locks need to be PR; other modes get passed through */ + if ((lock_cmd & LCK_TYPE_MASK) == LCK_READ) { + lock_cmd &= ~LCK_TYPE_MASK; + lock_cmd |= LKM_PRMODE; + } status = sync_lock(lockname, (int)lock_cmd, (lock_flags & LCK_NONBLOCK) ? LKF_NOQUEUE : 0, &lkid); if (status) status = errno;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-11-30 22:11:26 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Check reallocated buffer for NULL before use As *buf is reallocated in case CLVMD_CMD_TEST: test for NULL is needed before printing status. (realloc() == NULL and status != 0) Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1814&r2=1.1815 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.41&r2=1.42 --- LVM2/WHATS_NEW 2010/11/29 18:35:37 1.1814 +++ LVM2/WHATS_NEW 2010/11/30 22:11:26 1.1815 @@ -1,5 +1,6 @@ Version 2.02.78 - ==================================== + Check reallocated buffer for NULL before use in clvmd do_command(). Fix memory leak when VG allocation policy in metadata is invalid. Ignore unrecognised allocation policy found in metadata instead of aborting. Factor out tag printing into _out_tags and avoid leaking string buffer. --- LVM2/daemons/clvmd/clvmd-command.c 2010/10/20 14:51:18 1.41 +++ LVM2/daemons/clvmd/clvmd-command.c 2010/11/30 22:11:26 1.42 @@ -169,7 +169,8 @@ /* Check the status of the command and return the error text */ if (status) { - *retlen = 1 + snprintf(*buf, buflen, "%s", strerror(status)); + *retlen = 1 + (*buf) ? snprintf(*buf, buflen, "%s", + strerror(status)) : -1; } return status;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2010-11-30 22:16:25 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Replace snprintf with dm_snprintf Use dm_snprintf with known error case return code (-1). Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.1815&r2=1.1816 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.42&r2=1.43 --- LVM2/WHATS_NEW 2010/11/30 22:11:26 1.1815 +++ LVM2/WHATS_NEW 2010/11/30 22:16:25 1.1816 @@ -1,5 +1,6 @@ Version 2.02.78 - ==================================== + Replace snprintf with dm_snprintf in clvmd-command.c. Check reallocated buffer for NULL before use in clvmd do_command(). Fix memory leak when VG allocation policy in metadata is invalid. Ignore unrecognised allocation policy found in metadata instead of aborting. --- LVM2/daemons/clvmd/clvmd-command.c 2010/11/30 22:11:26 1.42 +++ LVM2/daemons/clvmd/clvmd-command.c 2010/11/30 22:16:25 1.43 @@ -97,10 +97,10 @@ } if (*buf) { uname(&nodeinfo); - *retlen = 1 + snprintf(*buf, buflen, - "TEST from %s: %s v%s", - nodeinfo.nodename, args, - nodeinfo.release); + *retlen = 1 + dm_snprintf(*buf, buflen, + "TEST from %s: %s v%s", + nodeinfo.nodename, args, + nodeinfo.release); } break; @@ -121,9 +121,8 @@ status = do_lock_lv(lock_cmd, lock_flags, lockname); /* Replace EIO with something less scary */ if (status == EIO) { - *retlen = - 1 + snprintf(*buf, buflen, "%s", - get_last_lvm_error()); + *retlen = 1 + dm_snprintf(*buf, buflen, "%s", + get_last_lvm_error()); return EIO; } break; @@ -133,7 +132,7 @@ if (buflen < 3) return EIO; if ((locktype = do_lock_query(lockname))) - *retlen = 1 + snprintf(*buf, buflen, "%s", locktype); + *retlen = 1 + dm_snprintf(*buf, buflen, "%s", locktype); break; case CLVMD_CMD_REFRESH: @@ -169,8 +168,8 @@ /* Check the status of the command and return the error text */ if (status) { - *retlen = 1 + (*buf) ? snprintf(*buf, buflen, "%s", - strerror(status)) : -1; + *retlen = 1 + (*buf) ? dm_snprintf(*buf, buflen, "%s", + strerror(status)) : -1; } return status; @@ -377,7 +376,7 @@ /* Propogate debug options */ if (debug) { if (!(debug_arg = malloc(16)) || - snprintf(debug_arg, 16, "-d%d", (int)debug) < 0) + dm_snprintf(debug_arg, 16, "-d%d", (int)debug) < 0) goto_out; argv[argc++] = debug_arg; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-22 09:45:24 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Add all exclusive locks to clvmd restart option args Fix bug when only every even lock has been passed. Warning: currently -E causes clvmd to exit with usage text being printed. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2127&r2=1.2128 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.56&r2=1.57 --- LVM2/WHATS_NEW 2011/09/21 13:40:46 1.2127 +++ LVM2/WHATS_NEW 2011/09/22 09:45:24 1.2128 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add all exclusive locks to clvmd restart option args. Always send the whole clvmd packet header in refresh commands. Add missing error checks for some system calls in cmirrord. Add missing log_error() to lvresize command when fsadm tool fails. --- LVM2/daemons/clvmd/clvmd-command.c 2011/06/03 09:05:30 1.56 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:45:24 1.57 @@ -369,7 +369,6 @@ DEBUGLOG("clvmd restart requested\n"); /* Count exclusively-open LVs */ - hn = NULL; do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) @@ -403,6 +402,7 @@ */ /* Now add the exclusively-open LVs */ + hn = NULL; do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) { @@ -414,7 +414,6 @@ goto_out; DEBUGLOG("excl lock: %s\n", lv_name); - hn = get_next_excl_lock(hn, &lv_name); } } while (hn && *lv_name); argv[argc++] = NULL;
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2011-09-22 09:47:34 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Clvmd restart cleanup Patch fixes Clang warnings about possible access via lv_name NULL pointer. Replaces allocation of memory (strdup) with just pointer assignment (since execve is being called anyway). Checks for !*lv_name only when lv_name is defined. (and as I'm not quite sure what state this really is - putting a FIXME around - as this rather looks suspicios ??). Add debug print of passed clvmd args. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2128&r2=1.2129 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.57&r2=1.58 --- LVM2/WHATS_NEW 2011/09/22 09:45:24 1.2128 +++ LVM2/WHATS_NEW 2011/09/22 09:47:34 1.2129 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Cleanup restart clvmd code (no memory allocation, debug print passed args). Add all exclusive locks to clvmd restart option args. Always send the whole clvmd packet header in refresh commands. Add missing error checks for some system calls in cmirrord. --- LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:45:24 1.57 +++ LVM2/daemons/clvmd/clvmd-command.c 2011/09/22 09:47:34 1.58 @@ -361,39 +361,38 @@ static int restart_clvmd(void) { - char **argv = NULL; - char *debug_arg = NULL, *lv_name; - int i, argc = 0, max_locks = 0; + const char **argv; + char *lv_name; + int argc = 0, max_locks = 0; struct dm_hash_node *hn = NULL; + char debug_arg[16]; DEBUGLOG("clvmd restart requested\n"); /* Count exclusively-open LVs */ do { hn = get_next_excl_lock(hn, &lv_name); - if (lv_name) + if (lv_name) { max_locks++; - } while (hn && *lv_name); + if (!*lv_name) + break; /* FIXME: Is this error ? */ + } + } while (hn); /* clvmd + locks (-E uuid) + debug (-d X) + NULL */ - argv = malloc((max_locks * 2 + 4) * sizeof(*argv)); - if (!argv) + if (!(argv = malloc((max_locks * 2 + 4) * sizeof(*argv)))) goto_out; /* * Build the command-line */ - argv[argc++] = strdup("clvmd"); - if (!argv[0]) - goto_out; + argv[argc++] = "clvmd"; /* Propogate debug options */ if (clvmd_get_debug()) { - if (!(debug_arg = malloc(16)) || - dm_snprintf(debug_arg, 16, "-d%u", clvmd_get_debug()) < 0) + if (dm_snprintf(debug_arg, sizeof(debug_arg), "-d%u", clvmd_get_debug()) < 0) goto_out; argv[argc++] = debug_arg; - debug_arg = NULL; } /* @@ -406,30 +405,26 @@ do { hn = get_next_excl_lock(hn, &lv_name); if (lv_name) { - argv[argc] = strdup("-E"); - if (!argv[argc++]) - goto_out; - argv[argc] = strdup(lv_name); - if (!argv[argc++]) - goto_out; - + if (!*lv_name) + break; /* FIXME: Is this error ? */ + argv[argc++] = "-E"; + argv[argc++] = lv_name; DEBUGLOG("excl lock: %s\n", lv_name); } - } while (hn && *lv_name); - argv[argc++] = NULL; + } while (hn); + argv[argc] = NULL; /* Exec new clvmd */ DEBUGLOG("--- Restarting %s ---\n", CLVMD_PATH); + for (argc = 1; argv[argc]; argc++) DEBUGLOG("--- %d: %s\n", argc, argv[argc]); + /* NOTE: This will fail when downgrading! */ - execve(CLVMD_PATH, argv, NULL); + execve(CLVMD_PATH, (char **)argv, NULL); out: /* We failed */ DEBUGLOG("Restart of clvmd failed.\n"); - for (i = 0; i < argc && argv[i]; i++) - free(argv[i]); free(argv); - free(debug_arg); return EIO; }
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-01-25 22:17:57 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Test for uname result in fail path initialize to 0. Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2243&r2=1.2244 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.62&r2=1.63 --- LVM2/WHATS_NEW 2012/01/25 22:16:04 1.2243 +++ LVM2/WHATS_NEW 2012/01/25 22:17:57 1.2244 @@ -1,5 +1,6 @@ Version 2.02.89 - ================================== + Add missing check for uname result in clvmd TEST processing. Fix memleak in target_version() error path (unsupported LIST_VERSIONS). Limit alignment to 32bit values. Check for correctness of uint64 dev_size value. --- LVM2/daemons/clvmd/clvmd-command.c 2011/12/08 18:32:33 1.62 +++ LVM2/daemons/clvmd/clvmd-command.c 2012/01/25 22:17:57 1.63 @@ -99,7 +99,9 @@ *buf = new_buf; } if (*buf) { - uname(&nodeinfo); + if (uname(&nodeinfo)) + memset(&nodeinfo, 0, sizeof(nodeinfo)); + *retlen = 1 + dm_snprintf(*buf, buflen, "TEST from %s: %s v%s", nodeinfo.nodename, args,
CVSROOT: /cvs/lvm2 Module name: LVM2 Changes by: zkabelac@sourceware.org 2012-03-23 09:48:18 Modified files: . : WHATS_NEW daemons/clvmd : clvmd-command.c Log message: Return mem fail if hash insert fails Patches: http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.2363&r2=1.2364 http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/daemons/clvmd/clvmd-command.c.diff?cvsroot=lvm2&r1=1.67&r2=1.68 --- LVM2/WHATS_NEW 2012/03/23 09:42:36 1.2363 +++ LVM2/WHATS_NEW 2012/03/23 09:48:17 1.2364 @@ -1,5 +1,7 @@ Version 2.02.96 - ================================ + Check hash insert success in lock_vg clvmd. + Check for buffer overwrite in get_cluster_type() clvmd. Fix global/detect_internal_vg_cache_corruption config check. Update lcov Makefile target to support all dmeventd plugins. Fix initializiation of thin monitoring (2.02.92). --- LVM2/daemons/clvmd/clvmd-command.c 2012/03/01 21:14:43 1.67 +++ LVM2/daemons/clvmd/clvmd-command.c 2012/03/23 09:48:18 1.68 @@ -240,7 +240,8 @@ if (status) status = errno; else - dm_hash_insert(lock_hash, lockname, (void *)(long)lkid); + if (!dm_hash_insert(lock_hash, lockname, (void *)(long)lkid)) + return ENOMEM; } return status;