]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add a null undo function to the vmbackup null provider.
authorJohn Wolfe <jwolfe@vmware.com>
Tue, 13 Sep 2022 17:31:15 +0000 (10:31 -0700)
committerJohn Wolfe <jwolfe@vmware.com>
Tue, 13 Sep 2022 17:31:15 +0000 (10:31 -0700)
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__.

open-vm-tools/services/plugins/vmbackup/nullProvider.c

index 1abc5f606f0280f8ec13d2d4d8de3c3c50a874df..e07d2b72bff44c557098b2f6c43d8f609cbf6c5b 100644 (file)
@@ -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;