From f7009c53afdab9a9507257c77bfeb30d8baaac8c Mon Sep 17 00:00:00 2001 From: John Wolfe Date: Thu, 10 Nov 2022 12:01:14 -0800 Subject: [PATCH] Add a null undo function to the vmbackup null provider. If a snapshot operation times out, vmbackup can attempt to undo quiescing. Since no quiescing is done for the null backup provider, no undo function was provided. If vmbackup attempts to call the undo function, it dereferences a garbage pointer resulting in a segfault. Rather than add null backup provider specific checks to vmbackup, this change adds a null undo function to provide vmbackup with a valid function pointer it can call. The new undo function updates the vmbackup state machine state with a new currentOpName, but has no other effect. currentOpName is set to the calling function name, e.g. __FUNCTION__. --- .../services/plugins/vmbackup/nullProvider.c | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/open-vm-tools/services/plugins/vmbackup/nullProvider.c b/open-vm-tools/services/plugins/vmbackup/nullProvider.c index 1abc5f606..e07d2b72b 100644 --- a/open-vm-tools/services/plugins/vmbackup/nullProvider.c +++ b/open-vm-tools/services/plugins/vmbackup/nullProvider.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2010-2016 VMware, Inc. All rights reserved. + * Copyright (C) 2010-2016, 2022 VMware, Inc. All rights reserved. * * This program is free software; you can redistribute it and/or modify it * under the terms of the GNU Lesser General Public License as published @@ -243,6 +243,32 @@ VmBackupNullSnapshotDone(VmBackupState *state, return TRUE; } + +/* + ****************************************************************************** + * VmBackupNullUndo -- */ /** + * + * Update the state machine state with the currentOpName. + * + * Can be called when snapshot times out. See PR2993571 and PR3003917. + * + * @param[in] state the backup state + * @param[in] clientData client data + * + * @return TRUE + * + ****************************************************************************** + */ + +static Bool +VmBackupNullUndo(VmBackupState *state, + void *clientData) +{ + g_debug("*** %s\n", __FUNCTION__); + VmBackup_SetCurrentOp(state, NULL, NULL, __FUNCTION__); + return TRUE; +} + #endif /* @@ -281,6 +307,9 @@ VmBackup_NewNullProvider(void) provider = g_new(VmBackupSyncProvider, 1); provider->start = VmBackupNullStart; +#if !defined(_WIN32) + provider->undo = VmBackupNullUndo; +#endif provider->snapshotDone = VmBackupNullSnapshotDone; provider->release = VmBackupNullRelease; provider->clientData = NULL;