Note: This bug is displayed in read-only format because the product is no longer active in Red Hat Bugzilla.
RHEL Engineering is moving the tracking of its product development work on RHEL 6 through RHEL 9 to Red Hat Jira (issues.redhat.com). If you're a Red Hat customer, please continue to file support cases via the Red Hat customer portal. If you're not, please head to the "RHEL project" in Red Hat Jira and file new tickets here. Individual Bugzilla bugs in the statuses "NEW", "ASSIGNED", and "POST" are being migrated throughout September 2023. Bugs of Red Hat partners with an assigned Engineering Partner Manager (EPM) are migrated in late September as per pre-agreed dates. Bugs against components "kernel", "kernel-rt", and "kpatch" are only migrated if still in "NEW" or "ASSIGNED". If you cannot log in to RH Jira, please consult article #7032570. That failing, please send an e-mail to the RH Jira admins at rh-issues@redhat.com to troubleshoot your issue as a user management inquiry. The email creates a ServiceNow ticket with Red Hat. Individual Bugzilla bugs that are migrated will be moved to status "CLOSED", resolution "MIGRATED", and set with "MigratedToJIRA" in "Keywords". The link to the successor Jira issue will be found under "Links", have a little "two-footprint" icon next to it, and direct you to the "RHEL project" in Red Hat Jira (issue links are of type "https://issues.redhat.com/browse/RHEL-XXXX", where "X" is a digit). This same link will be available in a blue banner at the top of the page informing you that that bug has been migrated.

Bug 1896804

Summary: [ESXi][open-vm-tools] Coverity detected important defects in open-vm-tools-11.2.0 rebase
Product: Red Hat Enterprise Linux 8 Reporter: Cathy Avery <cavery>
Component: open-vm-toolsAssignee: Cathy Avery <cavery>
Status: CLOSED ERRATA QA Contact: ldu <ldu>
Severity: unspecified Docs Contact:
Priority: high    
Version: 8.4CC: boyang, cavery, jen, jjarvis, jsaks, jsavanyo, jwolfe, ldu, leiwang, mrezanin, ravindrakumar, vmware-gos-qa, yacao
Target Milestone: rcKeywords: Triaged
Target Release: 8.0Flags: pm-rhel: mirror+
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: open-vm-tools-11.2.0-2.el8 Doc Type: If docs needed, set a value
Doc Text:
Story Points: ---
Clone Of: 1886866 Environment:
Last Closed: 2021-05-18 15:19:18 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 1886866    
Bug Blocks:    

Description Cathy Avery 2020-11-11 15:16:32 UTC

Comment 1 Cathy Avery 2020-11-11 15:58:16 UTC
I've run coverity on Mirek's official rebase of 11.2.0. After applying the patch Jonathan gave me 

https://github.com/vmware/open-vm-tools/tree/devel, commit e18e67f727d0354b08a55b685178fd05f542c6da

and discarding the thus far known false positives we now have the list below of 4 defects to be addressed. 

It looks like the last 2 are false positives. I did not check the first 2.

Thanks,

Cathy

Error: RESOURCE_LEAK (CWE-772):
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5938: alloc_fn: Storage is returned from allocation function "UtilSafeCalloc0".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5938: var_assign: Assigning: "entry" = storage returned from "UtilSafeCalloc0(1UL, 16UL)".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5941: noescape: Resource "entry" is not freed or pointed-to in "HgfsCache_Put".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5976: leaked_storage: Variable "entry" going out of scope leaks the storage it points to.
# 5974|      *bufOut = myBufOut;
# 5975|   
# 5976|->    return HGFS_NAME_STATUS_COMPLETE;
# 5977|   
# 5978|   error:

Error: RESOURCE_LEAK (CWE-772):
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8504: alloc_fn: Storage is returned from allocation function "UtilSafeCalloc0".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8504: var_assign: Assigning: "entry" = storage returned from "UtilSafeCalloc0(1UL, 184UL)".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8507: noescape: Resource "entry" is not freed or pointed-to in "HgfsCache_Put".
open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8558: leaked_storage: Variable "entry" going out of scope leaks the storage it points to.
# 8556|   
# 8557|      HgfsServerCompleteRequest(status, replyPayloadSize, input);
# 8558|-> }
# 8559|   
# 8560|   


Error: RESOURCE_LEAK (CWE-772):
open-vm-tools-11.2.0-16938113/vgauth/lib/proto.c:1235: alloc_arg: "VGAuth_CommReadData" allocates memory that is stored into "rawReply".
open-vm-tools-11.2.0-16938113/vgauth/lib/proto.c:1239: leaked_storage: Variable "rawReply" going out of scope leaks the storage it points to.
# 1237|            err = VGAUTH_E_COMM;
# 1238|            Warning("%s: EOF on datastream when trying to parse\n", __FUNCTION__);
# 1239|->          goto abort;
# 1240|         }
# 1241|         if (VGAUTH_E_OK != err) {

Error: RESOURCE_LEAK (CWE-772):
open-vm-tools-11.2.0-16938113/vgauth/serviceImpl/proto.c:1115: alloc_arg: "ServiceNetworkReadData" allocates memory that is stored into "data".
open-vm-tools-11.2.0-16938113/vgauth/serviceImpl/proto.c:1178: leaked_storage: Variable "data" going out of scope leaks the storage it points to.
# 1176|      }
# 1177|   
# 1178|->    return err;
# 1179|   }
# 1180|

Comment 2 jsaks 2020-11-12 12:38:06 UTC
Hi Cathy,

Yes, you're right that the last two are false positives.  The first two are as well.

Explanations below.

Jonathan

>Error: RESOURCE_LEAK (CWE-772):
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5938: alloc_fn: Storage is returned from allocation function "UtilSafeCalloc0".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5938: var_assign: Assigning: "entry" = storage returned from "UtilSafeCalloc0(1UL, 16UL)".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5941: noescape: Resource "entry" is not freed or pointed-to in "HgfsCache_Put".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:5976: leaked_storage: Variable "entry" going out of scope leaks the storage it points to.
># 5974|      *bufOut = myBufOut;
># 5975|   
># 5976|->    return HGFS_NAME_STATUS_COMPLETE;
># 5977|   
># 5978|   error:

False positive.  Contrary to the Coverity analysis, "entry" is pointed-to in HgfsCache_Put.


>Error: RESOURCE_LEAK (CWE-772):
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8504: alloc_fn: Storage is returned from allocation function "UtilSafeCalloc0".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8504: var_assign: Assigning: "entry" = storage returned from "UtilSafeCalloc0(1UL, 184UL)".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8507: noescape: Resource "entry" is not freed or pointed-to in "HgfsCache_Put".
>open-vm-tools-11.2.0-16938113/lib/hgfsServer/hgfsServer.c:8558: leaked_storage: Variable "entry" going out of scope leaks the storage it points to.
># 8556|   
># 8557|      HgfsServerCompleteRequest(status, replyPayloadSize, input);
># 8558|-> }
># 8559|   
># 8560|   

False positive.  Same as previous: Contrary to the Coverity analysis, "entry" is pointed-to in HgfsCache_Put.


>Error: RESOURCE_LEAK (CWE-772):
>open-vm-tools-11.2.0-16938113/vgauth/lib/proto.c:1235: alloc_arg: "VGAuth_CommReadData" allocates memory that is stored into "rawReply".
>open-vm-tools-11.2.0-16938113/vgauth/lib/proto.c:1239: leaked_storage: Variable "rawReply" going out of scope leaks the storage it points to.
># 1237|            err = VGAUTH_E_COMM;
># 1238|            Warning("%s: EOF on datastream when trying to parse\n", __FUNCTION__);
># 1239|->          goto abort;
># 1240|         }
># 1241|         if (VGAUTH_E_OK != err) {

False positive. VGAuthCommReadData passes back a non-NULL value in rawReply if and only if its return value is VGAUTH_E_OK and the value of len it passes back is non-zero.  In that case, the storage rawReply points to is freed by the g_free call immediately after the call to g_markup_parse_context_parse. 


>Error: RESOURCE_LEAK (CWE-772):
>open-vm-tools-11.2.0-16938113/vgauth/serviceImpl/proto.c:1115: alloc_arg: "ServiceNetworkReadData" allocates memory that is stored into "data".
>open-vm-tools-11.2.0-16938113/vgauth/serviceImpl/proto.c:1178: leaked_storage: Variable "data" going out of scope leaks the storage it points to.
># 1176|      }
># 1177|   
># 1178|->    return err;
># 1179|   }
># 1180|

False positive.  Somewhat similar to previous: ServiceNetworkReadData passes back a non-NULL value in data if and only if it returns VGAUTH_E_OK and conn->eof is FALSE.  In that case, the storage data points to is freed by the g_free call that immediately follows the call to g_markup_parse_context_parse.

Comment 3 Cathy Avery 2020-11-12 13:31:57 UTC
(In reply to jsaks from comment #2)

Great!

OK this BZ will remain open as a vehicle to introduce the patch set to our 11.2.0 repo. https://github.com/vmware/open-vm-tools/tree/devel, commit e18e67f727d0354b08a55b685178fd05f542c6da

Thanks,

Cathy

Comment 9 ldu 2020-12-01 13:03:16 UTC
Have completed the auto regression test for open-vm-tools-11.2.0-2.el8, all test cases passed, no regression issue found, add tested flag.

Comment 12 ldu 2020-12-08 03:29:20 UTC
After run regression test on RHEL-8.4.0-20201203.n.0, all open-vm-tools related cases passed, no new issue found.
so change bug status to verified.

Comment 14 errata-xmlrpc 2021-05-18 15:19:18 UTC
Since the problem described in this bug report should be
resolved in a recent advisory, it has been closed with a
resolution of ERRATA.

For information on the advisory (open-vm-tools bug fix and enhancement update), and where to find the updated
files, follow the link below.

If the solution does not work for you, open a new bug report.

https://access.redhat.com/errata/RHEA-2021:1753