Oliver Kurth [Wed, 10 Apr 2019 21:14:57 +0000 (14:14 -0700)]
Remove use of "-Wno-address-of-packed-member" option for OVT builds on FBSD
With the HGFS source code refactor to avoid taking the address of a
packed structure memberuse of "-Wno-address-of-packed-member"
is no longer needed to build OVT on FBSD 11.x and FBSD 12.x.
Oliver Kurth [Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)]
Add a 64 bit pseudo random number generator
This change adds a 64 bit pseudo random number generator to the public
library by calling the existing 32 bit Random_Fast function twice.
Since the period of Random_Fast is 2^64, this should be sufficient.
Oliver Kurth [Wed, 10 Apr 2019 21:14:56 +0000 (14:14 -0700)]
Remove some "always TRUE" comparisons reported by clang 6.0 on FBSD.
A recent refactoring of HGFS fuse code to avoid taking the address of
a field in a packed structure introduced a comparision of an array
address != NULL which will always evaluate to "true". Removing the
unnecessary "if" statements.
Oliver Kurth [Wed, 10 Apr 2019 21:14:55 +0000 (14:14 -0700)]
DnD Phase II] - Avoid potential memory overflow.
In the case when dragging a format whose size is exactly the same as the
size threshold and plain text is provided, the plain text can't be added.
Current logic does not handle this case. Instead it will result in a
large unsigned number (0-1 = 0xffff_ffff) of bytes to be allocated to
store plain text which causes memory overflow.
Just return in the case that no more size left to add plain text or the
plain text is empty.
Oliver Kurth [Wed, 10 Apr 2019 21:14:53 +0000 (14:14 -0700)]
Asyncsocket in low latency send mode may write into freed memory
Blast service encounters access violation exception during scale tests
in AsyncTCPSocketSend() at bora\lib\asyncsocket\asyncsocket.c.
Root cause is asock refcount is not incremented before the inline
invocation of AsyncTCPSocketSendCallback() in the low latency send
mode and asock is accessed right after this invocation to decrement
inLowLatencySendCb counter. AsyncTCPSocketSendCallback() on error
would invoke error handler which in turn could close the asock
leading to freeing of asock.
Issue wouldn't happen if AsyncWebSocket impl guarded all of its
transport->send(transport) calls with AsyncSocketAddRef(transport)
and AsyncSocketRelease(transport) but isn't the case currently.
Fix is to add and release asock reference around the inline
invocation of AsyncTCPSocketSendCallback().
Oliver Kurth [Wed, 10 Apr 2019 21:14:52 +0000 (14:14 -0700)]
InitiateFileTransferToGuest fails when uploading file to root directory
File upload to '/' on Linux fails the directory exists check.
This is caused by the file dirname being an empty string when parsed from
the guest file path name per the documented behavior of File_GetPathName.
The caller of File_GetPathName needs to handle the expected empty dirname
string when dealing with file path in the root ('/') filesystem on Linux.
Proposed fix is to replace the dirname string with the root path ('/') when:
A. dirname obtained from File_GetPathName call is an empty string AND
B. the original file path name starts with the path separator ('/') on
Linux (or *nix like) GOSes
This allows for the directory checks to inspect the root folder before
proceeding with the file transfer.
Oliver Kurth [Wed, 10 Apr 2019 21:14:49 +0000 (14:14 -0700)]
InitiateFileTransferToGuest fails when uploading file to root directory
File upload to '/' on Linux fails the directory exists check.
This is caused by the file dirname being an empty string when parsed from the guest file path name per the documented behavior of File_GetPathName.
The caller of File_GetPathName needs to handle the expected empty dirname string when dealing with file path in the root ('/') filesystem on Linux.
Proposed fix is to replace the dirname string with the root path ('/') when:
A. dirname obtained from File_GetPathName call is an empty string AND
B. the original file path name starts with the path separator ('/') on Linux (or *nix like) GOSes
This allows for the directory checks to inspect the root folder before proceedeing with the file transfer.
Oliver Kurth [Thu, 28 Mar 2019 19:43:00 +0000 (12:43 -0700)]
Remove the /etc/security directory from the guest vm-support bundle.
This directory contains sensitive guest side data that we should not
expose to the host side.
Although running the vm-support requires the root privilege in the guest,
the guest admin might not be aware of the ramification of running the script.
Therefore, better be cautious.
No file from the /etc/security has been needed in the past. If any file is
needed in the future, that need will be evaluated case-by-case at that time.
Oliver Kurth [Thu, 28 Mar 2019 19:42:59 +0000 (12:42 -0700)]
Fix a memory leak in vmbackup.
Note: vm_free() is called here because GuestApp_GetConfPath() is calling
Util_SafeStrdup() to allocate the memory. Both GuestApp_GetConfPath and
vm_free are implemented inside libvmtools.so.
Oliver Kurth [Thu, 28 Mar 2019 19:42:59 +0000 (12:42 -0700)]
Fix memory leak in GetFormattedCommandLine() function (linuxDeployment.c)
1. There are malloc() calls happening in a loop; this function returns
NULL when one of malloc fails. If a malloc call fails in the loop,
all memory allocated in previous iterations should be freed before
the return NULL.
2. Clear allocated resources before return NULL in this file.
3. Add NULL check following malloc calls in this file.
4. Encapsulate %s in () only if %s is strerror(errno), otherwise encapsulate
%s in single quotes.
5. End with \n in sLog.
Oliver Kurth [Wed, 27 Feb 2019 22:39:58 +0000 (14:39 -0800)]
Remove dead code in vmtoolsConfig.c
There is a lot code in vmtoolsConfig.c that handles the 'tools upgrades'
from legacy tools versions.
But as per
https://docs.vmware.com/en/VMware-Tools/10.1/rn/vmware-tools-1010-release-notes.html#installupgrade,
legacy tools versions (prior to 9.4.x) must be first upgraded to 10.1.0 before
upgrading to the latest tools versions. Hence, removed all the code which is
no longer applicable for the 'latest tools version'.
Oliver Kurth [Wed, 27 Feb 2019 22:39:57 +0000 (14:39 -0800)]
Tools Vix Plugin: minor cleanup remove unnecessary undefs
A minor cleanup remove unnecessary undefs and fixing a misspelling in
a function header. The function header somehow got removed from the
previous clean up so here it is again anyway, with the addition of the
spelling correction.
Oliver Kurth [Wed, 27 Feb 2019 22:39:57 +0000 (14:39 -0800)]
Linux DeployPkg should provide a configurable timeout for the spanning
customization process.
Change the upper limit of the timeout value in tools.conf to 3600 instead
of MAX_UINT16. Revise the log message displayed when an invalid value
is configured in tools.conf.
Oliver Kurth [Wed, 27 Feb 2019 22:39:55 +0000 (14:39 -0800)]
GCC 9 caught several misaligned accesses and a format overflow.
GCC 9 generated several instances of "Werror=address-of-packed-member"
in HGFS Fuse support code and hgfsmounter. There is also one instance of
"Werror=format-overflow" generated in util_misc.c.
According to stackoverflow discussion -
https://stackoverflow.com/questions/8568432/is-gccs-attribute-packed-pragma-pack-unsafe,
x86 hardware handles misaligned access and does not exhibit any real
issues. However, GCC 9 generates misaligned access warning
("Werror=address-of-packed-member) for all architectures. In case of
open-vm-tools build we treat warnings as errors and also we want code
to be as portable as possible in general unless there is a reason not
to do so.
Oliver Kurth [Tue, 19 Feb 2019 20:51:33 +0000 (12:51 -0800)]
Hgfs Server Manager Tools: fix a memory leak
The Hgfs server manager interface assumes that it is called only once
for each application that uses it. However, in the tools services there
are multiple clients. Hence, the initialization is done multiple times
and causes the previous initializations which allocate resources to be
overwritten and lost. Thus memory is being leaked.
Initialize the policy shares once on the first register and cleanup
the policy shares on final unregister by introducing a reference count.
The channel is already reference counted and initializes the channel once.
However it is necessary to call the channel init on each register
and exit on each unregister as it saves a channel reference in the data manager
object passed to it by the caller for subsequent retrieval.
Add an additional log to the policy init and cleanup calls for tracking purposes.
Oliver Kurth [Tue, 19 Feb 2019 20:51:32 +0000 (12:51 -0800)]
Fix the missing IP aliases in the guest info.
IP aliases were missing in the guest info when libdnet is not used.
Previously tried to use the MAC address as the key to identify the IP aliases
on Linux. However, that didn't work for vlan devices which share the same
MAC as the parent NIC. The previous attempt was backed out.
Ideally, need to find a way to map the label name to the NIC name, but
have not been able to find a simple solution for this. There might be a
netlink based solution but it is way too costly to do.
After more investigation, found out that a valid IP alias name must start
with the original NIC name followed by a colon. Even though the ip addr allows
any string as the start of the NIC name, configuration file requires the colon.
In addition, ifconfig would error out when the name is not of the standard:
ens192wwwww: error fetching interface information: Device not found
Therefore, a correctly configured system should use eth0:1, ens192:2 etc.
A lookup of libdnet source revealed the same assumption in the libdnet code.
/* Get addresses for this interface. */
for (ifr = intf->ifc.ifc_req; ifr < lifr && (ap + 1) < lap;
ifr = NEXTIFR(ifr)) {
/* XXX - Linux, Solaris ifaliases */
if ((p = strchr(ifr->ifr_name, ':')) != NULL)
*p = '\0';
Therefore, doing just the same. Look for the colon, then trim it, and then
compare it with the NIC name.
Oliver Kurth [Tue, 19 Feb 2019 20:51:32 +0000 (12:51 -0800)]
GuestOS: Improve the guest OS identification code
Now that we often have an explicit, unambiguous version string for
a distro, use it. In the rare case we don't have one, search the
distro string for a digit and use that. If we can't find anything,
note this and let the code fall into the default appropriate to the
distro.
With this change, we stop using strings and so are no longer confused
by things like "7.5". For a few of the distros, we now no longer care
about the upper bound, we can report what we find. Anything above what
the release supports will be fixed by the GuestMapper.
Oliver Kurth [Tue, 19 Feb 2019 20:51:32 +0000 (12:51 -0800)]
Fix the missing IP aliases in the guest info.
IP aliases were missing in the guest info when the libdnet is not used.
ESX does not seem to support IP aliases, so the ESX code path is kept logically
the same as before.
On Linux, for each IP entry, get the label name, and use ioctl to get its MAC.
Use the MAC to match the current device MAC.
The getifaddrs() call ensures that the ifa_name is not NULL, so there is no
need to check for NULL pointers.