Merge ~paelzer/ubuntu/+source/open-vm-tools:fix-1847157-vix-mem-leak-bionic into ubuntu/+source/open-vm-tools:ubuntu/bionic-devel

Proposed by Christian Ehrhardt 
Status: Merged
Approved by: Christian Ehrhardt 
Approved revision: 71891dbe5f1e17a1bae3ef00d780de5fa2eaed91
Merged at revision: 71891dbe5f1e17a1bae3ef00d780de5fa2eaed91
Proposed branch: ~paelzer/ubuntu/+source/open-vm-tools:fix-1847157-vix-mem-leak-bionic
Merge into: ubuntu/+source/open-vm-tools:ubuntu/bionic-devel
Diff against target: 324 lines (+278/-1)
6 files modified
debian/changelog (+9/-0)
debian/control (+2/-1)
debian/patches/lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch (+100/-0)
debian/patches/lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch (+74/-0)
debian/patches/lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch (+90/-0)
debian/patches/series (+3/-0)
Reviewer Review Type Date Requested Status
Andreas Hasenack Approve
Canonical Server packageset reviewers Pending
Canonical Server Pending
Review via email: mp+373944@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :
Revision history for this message
Andreas Hasenack (ahasenack) wrote :

Same change as disco and eoan

d/changelog version ok, considering upgrades from xenial, and to (new) disco.

+1

review: Approve
Revision history for this message
Christian Ehrhardt  (paelzer) wrote :

Tagged and uploaded

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1diff --git a/debian/changelog b/debian/changelog
2index 82edc10..f7e8a4f 100644
3--- a/debian/changelog
4+++ b/debian/changelog
5@@ -1,3 +1,12 @@
6+open-vm-tools (2:10.3.10-1~ubuntu0.18.04.2) bionic; urgency=medium
7+
8+ * Fix memory leaks in vix plugin (LP: #1847157)
9+ - d/p/lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch
10+ - d/p/lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch
11+ - d/p/lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch
12+
13+ -- Christian Ehrhardt <christian.ehrhardt@canonical.com> Wed, 09 Oct 2019 14:06:46 +0200
14+
15 open-vm-tools (2:10.3.10-1~ubuntu0.18.04.1) bionic; urgency=medium
16
17 * Backport recent open-vm-tools (LP: #1822204)
18diff --git a/debian/control b/debian/control
19index 11b0b7c..9858935 100644
20--- a/debian/control
21+++ b/debian/control
22@@ -1,7 +1,8 @@
23 Source: open-vm-tools
24 Section: admin
25 Priority: extra
26-Maintainer: Bernd Zeimetz <bzed@debian.org>
27+Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
28+XSBC-Original-Maintainer: Bernd Zeimetz <bzed@debian.org>
29 Build-Depends:
30 debhelper (>= 11~), autotools-dev, doxygen, libcunit1-dev,
31 libdumbnet-dev, libfuse-dev, libgtkmm-3.0-dev, libgtk-3-dev,
32diff --git a/debian/patches/lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch b/debian/patches/lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch
33new file mode 100644
34index 0000000..9a96fed
35--- /dev/null
36+++ b/debian/patches/lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch
37@@ -0,0 +1,100 @@
38+From 7b874f37f970aab2adddb063a8363594f47abf70 Mon Sep 17 00:00:00 2001
39+From: Oliver Kurth <okurth@vmware.com>
40+Date: Tue, 4 Sep 2018 15:40:58 -0700
41+Subject: [PATCH] End VGAuth impersonation in the case of error.
42+
43+* In GuestAuthPasswordAuthenticateImpersonate():
44+When VGAuth_UserHandleAccessToken fails, unimpersonation is not
45+being done. This can cause issues. Fixed it.
46+
47+* In GuestAuthSAMLAuthenticateAndImpersonate(), fixed the following issues:
48+The 'newHandle' is not being freed which causes a memory leak.
49+When VGAuth_UserHandleAccessToken fails, unimpersonation is not
50+being done.
51+
52+Origin: upstream, https://github.com/vmware/open-vm-tools/commit/7b874f37f970aab2adddb063a8363594f47abf70
53+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1847157
54+Last-Update: 2019-10-09
55+
56+---
57+ open-vm-tools/services/plugins/vix/vixTools.c | 25 +++++++++++++++++--
58+ 1 file changed, 23 insertions(+), 2 deletions(-)
59+
60+diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c
61+index 44369444c..00b40b1ce 100644
62+--- a/open-vm-tools/services/plugins/vix/vixTools.c
63++++ b/open-vm-tools/services/plugins/vix/vixTools.c
64+@@ -11550,6 +11550,7 @@ GuestAuthPasswordAuthenticateImpersonate(
65+ VGAuthError vgErr;
66+ VGAuthUserHandle *newHandle = NULL;
67+ VGAuthExtraParams extraParams[1];
68++ Bool impersonated = FALSE;
69+
70+ extraParams[0].name = VGAUTH_PARAM_LOAD_USER_PROFILE;
71+ extraParams[0].value = VGAUTH_PARAM_VALUE_TRUE;
72+@@ -11585,6 +11586,8 @@ GuestAuthPasswordAuthenticateImpersonate(
73+ goto done;
74+ }
75+
76++ impersonated = TRUE;
77++
78+ #ifdef _WIN32
79+ // this is making a copy of the token, be sure to close it
80+ vgErr = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
81+@@ -11604,6 +11607,10 @@ done:
82+ Util_ZeroFreeString(password);
83+
84+ if (VIX_OK != err) {
85++ if (impersonated) {
86++ vgErr = VGAuth_EndImpersonation(ctx);
87++ ASSERT(vgErr == VGAUTH_E_OK);
88++ }
89+ VGAuth_UserHandleFree(newHandle);
90+ newHandle = NULL;
91+ }
92+@@ -11638,12 +11645,13 @@ GuestAuthSAMLAuthenticateAndImpersonate(
93+ {
94+ #if SUPPORT_VGAUTH
95+ VixError err;
96+- char *token;
97+- char *username;
98++ char *token = NULL;
99++ char *username = NULL;
100+ VGAuthContext *ctx = NULL;
101+ VGAuthError vgErr;
102+ VGAuthUserHandle *newHandle = NULL;
103+ VGAuthExtraParams extraParams[1];
104++ Bool impersonated = FALSE;
105+
106+ extraParams[0].name = VGAUTH_PARAM_LOAD_USER_PROFILE;
107+ extraParams[0].value = VGAUTH_PARAM_VALUE_TRUE;
108+@@ -11735,6 +11743,8 @@ impersonate:
109+ goto done;
110+ }
111+
112++ impersonated = TRUE;
113++
114+ #ifdef _WIN32
115+ // this is making a copy of the token, be sure to close it
116+ vgErr = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
117+@@ -11750,6 +11760,17 @@ impersonate:
118+ err = VIX_OK;
119+
120+ done:
121++ Util_ZeroFreeString(token);
122++ Util_ZeroFreeString(username);
123++
124++ if (VIX_OK != err) {
125++ if (impersonated) {
126++ vgErr = VGAuth_EndImpersonation(ctx);
127++ ASSERT(vgErr == VGAUTH_E_OK);
128++ }
129++ VGAuth_UserHandleFree(newHandle);
130++ newHandle = NULL;
131++ }
132+
133+ return err;
134+ #else
135+--
136+2.23.0
137+
138diff --git a/debian/patches/lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch b/debian/patches/lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch
139new file mode 100644
140index 0000000..0050f47
141--- /dev/null
142+++ b/debian/patches/lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch
143@@ -0,0 +1,74 @@
144+From 26b9edbeb79d1c67b9ae73a0c97c48999c1fb503 Mon Sep 17 00:00:00 2001
145+From: Oliver Kurth <okurth@vmware.com>
146+Date: Wed, 2 Oct 2019 17:48:35 -0700
147+Subject: [PATCH] Fix leaks in ListAliases and ListMappedAliases
148+ (9bc72f0b09702754b429115658a85223cb3058bd from devel)
149+
150+
151+Origin: upstream, https://github.com/vmware/open-vm-tools/commit/26b9edbeb79d1c67b9ae73a0c97c48999c1fb503
152+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1847157
153+Last-Update: 2019-10-09
154+
155+---
156+ open-vm-tools/services/plugins/vix/vixTools.c | 10 ++++++++--
157+ 1 file changed, 8 insertions(+), 2 deletions(-)
158+
159+diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c
160+index 00b40b1ce..b0bd4d023 100644
161+--- a/open-vm-tools/services/plugins/vix/vixTools.c
162++++ b/open-vm-tools/services/plugins/vix/vixTools.c
163+@@ -9621,7 +9621,6 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
164+ char *endDestPtr;
165+ char *tmpBuf = NULL;
166+ char *tmpBuf2 = NULL;
167+- char *recordBuf;
168+ size_t recordSize;
169+ char *escapedStr = NULL;
170+ char *escapedStr2 = NULL;
171+@@ -9680,6 +9679,8 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
172+ destPtr += Str_Sprintf(destPtr, endDestPtr - destPtr, "%s",
173+ VIX_XML_ESCAPED_TAG);
174+ for (i = 0; i < num; i++) {
175++ char *recordBuf = NULL;
176++
177+ escapedStr = VixToolsEscapeXMLString(uaList[i].pemCert);
178+ if (escapedStr == NULL) {
179+ err = VIX_E_OUT_OF_MEMORY;
180+@@ -9750,6 +9751,8 @@ VixToolsListAuthAliases(VixCommandRequestHeader *requestMsg, // IN
181+ Log("%s: ListAuth list results too large, truncating", __FUNCTION__);
182+ goto abort;
183+ }
184++ free(recordBuf);
185++ recordBuf = NULL;
186+ }
187+
188+ *result = resultBuffer;
189+@@ -9817,7 +9820,6 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
190+ char *endDestPtr;
191+ char *tmpBuf = NULL;
192+ char *tmpBuf2 = NULL;
193+- char *recordBuf;
194+ char *escapedStr = NULL;
195+ char *escapedStr2 = NULL;
196+ size_t recordSize;
197+@@ -9870,6 +9872,8 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
198+ destPtr += Str_Sprintf(destPtr, endDestPtr - destPtr, "%s",
199+ VIX_XML_ESCAPED_TAG);
200+ for (i = 0; i < num; i++) {
201++ char *recordBuf = NULL;
202++
203+ escapedStr = VixToolsEscapeXMLString(maList[i].pemCert);
204+ if (escapedStr == NULL) {
205+ err = VIX_E_OUT_OF_MEMORY;
206+@@ -9938,6 +9942,8 @@ VixToolsListMappedAliases(VixCommandRequestHeader *requestMsg, // IN
207+ Log("%s: ListMapped results too large, truncating", __FUNCTION__);
208+ goto abort;
209+ }
210++ free(recordBuf);
211++ recordBuf = NULL;
212+ }
213+
214+ *result = resultBuffer;
215+--
216+2.23.0
217+
218diff --git a/debian/patches/lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch b/debian/patches/lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch
219new file mode 100644
220index 0000000..e2c87f1
221--- /dev/null
222+++ b/debian/patches/lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch
223@@ -0,0 +1,90 @@
224+From 015db4c06a8be65eb96cf62421e8b5366993452f Mon Sep 17 00:00:00 2001
225+From: Oliver Kurth <okurth@vmware.com>
226+Date: Wed, 29 Aug 2018 13:29:45 -0700
227+Subject: [PATCH] Fix memory leaks in 'vix' tools plugin.
228+
229+* vix plugin retrieves the power script file paths from the
230+config file but doesn't free them and this causes a memory leak.
231+Fixed the code to free the filepaths.
232+
233+* In GuestAuthPasswordAuthenticateImpersonate function, the VGAuth
234+handle is not freed when the impersonation fails. Fixed the
235+code to call VGAuth_UserHandleFree in the error path.
236+
237+Note: I executed one guest operation with wrong credentials.
238+Every failure leaks 75 bytes of memory. (in Centos 64-bit VM)
239+
240+* Fixed another minor issue in the code. At couple of places in
241+the code, replaced 'err' with 'vgErr' for storing the return value
242+of VGAuth_UserHandleAccessToken.
243+
244+Origin: upstream, https://github.com/vmware/open-vm-tools/commit/015db4c06a8be65eb96cf62421e8b5366993452f
245+Bug-Ubuntu: https://bugs.launchpad.net/bugs/1847157
246+Last-Update: 2019-10-09
247+
248+---
249+ open-vm-tools/services/plugins/vix/vixTools.c | 20 +++++++++++++------
250+ 1 file changed, 14 insertions(+), 6 deletions(-)
251+
252+diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c
253+index 55b1f0a51..44369444c 100644
254+--- a/open-vm-tools/services/plugins/vix/vixTools.c
255++++ b/open-vm-tools/services/plugins/vix/vixTools.c
256+@@ -2522,10 +2522,10 @@ VixTools_GetToolsPropertiesImpl(GKeyFile *confDictRef, // IN
257+ char *guestName;
258+ int osFamily;
259+ char *packageList = NULL;
260+- const char *powerOffScript = NULL;
261+- const char *powerOnScript = NULL;
262+- const char *resumeScript = NULL;
263+- const char *suspendScript = NULL;
264++ char *powerOffScript = NULL;
265++ char *powerOnScript = NULL;
266++ char *resumeScript = NULL;
267++ char *suspendScript = NULL;
268+ char *osName = NULL;
269+ char *osNameFull = NULL;
270+ Bool foundHostName;
271+@@ -2726,6 +2726,10 @@ abort:
272+ free(tempDir);
273+ free(osName);
274+ free(osNameFull);
275++ free(suspendScript);
276++ free(resumeScript);
277++ free(powerOnScript);
278++ free(powerOffScript);
279+ #else
280+ /*
281+ * FreeBSD. We do not require all the properties above.
282+@@ -11583,7 +11587,7 @@ GuestAuthPasswordAuthenticateImpersonate(
283+
284+ #ifdef _WIN32
285+ // this is making a copy of the token, be sure to close it
286+- err = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
287++ vgErr = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
288+ if (VGAUTH_FAILED(vgErr)) {
289+ err = VixToolsTranslateVGAuthError(vgErr);
290+ goto done;
291+@@ -11599,6 +11603,10 @@ done:
292+ free(username);
293+ Util_ZeroFreeString(password);
294+
295++ if (VIX_OK != err) {
296++ VGAuth_UserHandleFree(newHandle);
297++ newHandle = NULL;
298++ }
299+ return err;
300+ #else
301+ return VIX_E_NOT_SUPPORTED;
302+@@ -11729,7 +11737,7 @@ impersonate:
303+
304+ #ifdef _WIN32
305+ // this is making a copy of the token, be sure to close it
306+- err = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
307++ vgErr = VGAuth_UserHandleAccessToken(ctx, newHandle, userToken);
308+ if (VGAUTH_FAILED(vgErr)) {
309+ err = VixToolsTranslateVGAuthError(vgErr);
310+ goto done;
311+--
312+2.23.0
313+
314diff --git a/debian/patches/series b/debian/patches/series
315index 8140b20..0950b30 100644
316--- a/debian/patches/series
317+++ b/debian/patches/series
318@@ -1,3 +1,6 @@
319 debian/pam-use-common-auth-account
320 debian/max_nic_count
321 debian/scsi-udev-rule
322+lp-1847157-Fix-memory-leaks-in-vix-tools-plugin.patch
323+lp-1847157-End-VGAuth-impersonation-in-the-case-of-error.patch
324+lp-1847157-Fix-leaks-in-ListAliases-and-ListMappedAliases-9bc72.patch

Subscribers

People subscribed via source and target branches