Oliver Kurth [Fri, 15 Sep 2017 18:23:05 +0000 (11:23 -0700)]
Add xmlsec1 to open-vm-tools
Add the new files to open vm tools and add a switch to
turn it on. xml-seccurity-c remains the default for
now.
Also clean up the service Makefile, which was using
the client lib (which also dragged in stuff it shouldn't have)
for common code instead of building it in.
Oliver Kurth [Fri, 15 Sep 2017 18:23:05 +0000 (11:23 -0700)]
Remove libproc linking and packaging (it's dead since v9.10.5).
procps/libproc dependency was killed in Tools v9.10.5. Clean
this up and remove the unnecessary linking and packaging of
libproc that's no longer needed. All references from Tar Tools,
OSPs and open-vm-tools are removed. vm_procps.h was being used
for libproc only, so get rid of that, too.
Oliver Kurth [Fri, 15 Sep 2017 18:23:05 +0000 (11:23 -0700)]
Remove Hostinfo_CPUCounts (hosted)
The Hostinfo_CPUCounts function has an unhappy history
where not all OSes (especially Mac) make it easy to
discover the CPU topology.
There is a good reason for this: the CPU topology generally
does not matter. In fact, it does not matter for us.
So let's remove this enumeration code and instead report
a single CPU package with nCores == nThreads == what the
host OS claims. (Especially as the host OS does not really
expose cores versus threads information...). Then rip out
the underlying functions, all the way down.
Oliver Kurth [Fri, 15 Sep 2017 18:23:03 +0000 (11:23 -0700)]
The lib/AsyncSocket layer on supports SSL_Accept() and the certificate file
is reloaded every time a connection is accepted by calling SSL_Accept().
Add support for an SSL_AcceptWithContext to allow cahing of the SSL context
and avoid loading the certificate file every time.
modified: lib/asyncsocket/asyncsocket.c, lib/asyncsocket/asyncSocketInt.h
lib/asyncsocket/asyncSocketInterface.c, lib/include/asyncsocket.h
Common header file change: not applicable to open-vm-tools.
Oliver Kurth [Fri, 15 Sep 2017 18:23:03 +0000 (11:23 -0700)]
Thaw/resume guest file system when VMX aborts the operation.
When the operation is aborted by VMX after quiescing the
guest, we need to thaw/resume the guest.
In response to VMX message "vmbackup.abort", when guest sends
"vmbackup.eventSet req.aborted 4 Quiesce aborted." message,
it receives "Unknown command" response because VMX side RPC
handler for vmbackup event is removed before guest gets a chance
to respond. That is the behavior without this fix.
With this fix, in addition to the message above the new message
"vmbackup.eventSet req.done" added by this fix also receives
"Unknown command" response. We can fix these by keeping the RPC
handler for longer, but its not worth it because the operation
is being aborted anyway and vmbackup code in the guest is able
to tolerate these errors.
Oliver Kurth [Fri, 15 Sep 2017 18:23:03 +0000 (11:23 -0700)]
dictionary: Limit line data growth
The dictionary code keeps the raw input line around. Since the length
of the line is unknown at parsing time, a DynBuf is used to allocate
the memory for the line.
The DynBuf initial allocation is large - 1K - and this wastes space
when lines are rarely over 64 bytes long. The fix is to have the
dictionary code preallocate a 64 byte buffer before allowing appends
to the DynBuf. This will prevent many time consuming and memory
fragmenting realloc operations.
Oliver Kurth [Fri, 15 Sep 2017 18:23:02 +0000 (11:23 -0700)]
Hgfs Server: write op move argument checks security fixes
Complete the argument verifications in the common code adding the
missing checks for the write request packet size checks and the
write request data size (separated from the request itself as
in V4 of the HGFS protocol). This will now catch any attempts
from a client to pass a write request containing a data size
argument for the data to write that is greater than the amount
of data in the HGFS packet or data buffer passed.
Oliver Kurth [Fri, 15 Sep 2017 18:23:02 +0000 (11:23 -0700)]
Hgfs Server: write op move argument checks security fixes
Consolidate the argument verifications to the common code as these
are often duplicated. This will now explicitly perform the Hgfs write
operation argument verification in the common handler before calling
the platform specific code to actually perform the write.
Oliver Kurth [Fri, 15 Sep 2017 18:23:02 +0000 (11:23 -0700)]
Hgfs Server: add write op arg basic validate write op for security fixes
Add the basic write operation argument validation routine to obtain the data
sizes of the request and data to write for the supported HGFS protocol versions
(1 through 4). Add a call to it from the main write operation handler.
Note the argument validation checks will be added in the next change and moved
from the platform specific routines.
Oliver Kurth [Fri, 15 Sep 2017 18:23:01 +0000 (11:23 -0700)]
Tools RPC: Fix XDR invocation on mac and an uninitialized variable.
Switchng mac tools to clang found these two:
1. Uninitialized variable in rpcin.c: clang's static analyzer seems
to have had trouble figuring out that it is impossible for execution
to reach the "if (status == FALSE) {" line without being set.
To appease it, initialize it to FALSE.
2. xdrproc_t: On many platforms, xdrproc_t is an unprototyped function
pointer that can take either 2 or 3 arguments. Apple changed their
implementation to always take 3 arguments and recommend replacing calls
with 2 arguments to add a 0 3rd argument.
Oliver Kurth [Fri, 15 Sep 2017 18:23:01 +0000 (11:23 -0700)]
The vthreadBase library was not designed to be unloaded and simply leaks
the TLS keys it creates. Since plugins statically link it, loading and
unloading may hit the OS limit. This fix adds a hook into vthreadBase to
delete the TLS keys at plugin unload time.
Oliver Kurth [Fri, 15 Sep 2017 18:23:01 +0000 (11:23 -0700)]
Hgfs Server: write ops clean up for security fixes
Very minor write ops clean up for security fixes which renames
the arguments and local variables to be more consistent.
This is in preparation for moving some of the common argument
checks into a common routine and enhancing the checks to verify
the write data size and buffer.
Oliver Kurth [Fri, 15 Sep 2017 18:23:00 +0000 (11:23 -0700)]
Tools RpcIn: fix an assert triggered by a race condition
RpcIn open channel asserts that the current channel is NULL. This was being
triggered under stress testing. The guest tools service ran slowly, so
the VMX timed out and reset the channel. This caused the tools service
to do a channel check reset and which then called the RpcChannelRestart to
stop and start the channel again. Unfortunately, this call modified the
channel global without synchronizing with the other threads sending RPCs.
DiskWipe plugin was in the middle of a RpcChannel_Send (with the lock
acquired) when the restart call ran concurrently.
To fix this issue the RpcChannelRestart now acquires the same channel lock
to around the channel stop and start calls so that all sending threads wait
or complete first.
Oliver Kurth [Fri, 15 Sep 2017 18:23:00 +0000 (11:23 -0700)]
Update Tools ISO mapping in guest_os_tables.h
Update Tools ISO mapping in guest_os_tables.h for potentially
old/unsupported Linux distros.
Use frozen ISO linuxPreGlibc25.iso for:
1. "otherlinux" because it usually refers to unidentified old Linux
distros. We have "other26xlinux" and "other3xlinux" for newer
versions.
2. "sles" and "suse" because these refer to unidentified old SuSE.
3. "redhat" because it refers to unidentified old Red Hat versions.
4. "turbolinux" because it is not under active development.
Oliver Kurth [Fri, 15 Sep 2017 18:23:00 +0000 (11:23 -0700)]
Hgfs Server: minor clean up of request header size
Consistently use the correct function for determining the header size for
the HGFS packet to be used. This is necessary due to the different protocol
versions that exist, and originally the request and reply contained different
protocol headers.
Oliver Kurth [Fri, 15 Sep 2017 18:22:59 +0000 (11:22 -0700)]
Linux drivers: get_user_pages API changed to get_user_pages_remote.
Linux 4.6.1 introduces a new get_user_pages_remote() which is a
replacement for when get_user_pages() is called. Still use 'newer'
get_user_pages but with less args.
Oliver Kurth [Fri, 15 Sep 2017 18:22:59 +0000 (11:22 -0700)]
Apply various ICU patches between ICU 4.4.1 and 57.1
Parts of ICU 3.8 and 4.4.1 are included in bora/lib/unicode.
ICU is now at version 57.1 (which would have been 5.7.1 in
its old version numbering scheme) and has had some
security-related patches during that time.
Directly updating the ICU bits in bora/lib/unicode with the
corresponding bits from ICU 57.1 no longer seems feasible
because the ICU code has made increasing use of C++
(including C++11), which is something that we'd like to avoid
in widely shared libraries like lib/unicode and lib/misc.
Picked out a handful of fixes (particularly security-relevant
changes) that are applicable to our forked copy:
* r28300: ticket:7783: error checking in U16_GET()
* r29214: ticket:8238: Implement max subpart policy for UTF7
toUnicode, don't consume valid bytes after err
* r30175: ticket:8569: Terminate the UTF-7 byte buffer with
MINUS when flushing
* r30326: ticket:8265: Fix race (=> U_FILE_ACCESS_ERROR) when
loading full set of ICU data
* r31914: ticket:8235: do not call memcpy()/memmove()/...
with a NULL/invalid source pointer
* r31948: ticket:9340: Use bit mask instead of cast to avoid
buffer overflow
* r32021: ticket:9340: Fix potential out of bound error in
ICU4C ISCII converter
* r32041: ticket:9432: fix value of UDATA_FILE_ACCESS_COUNT
* r32242: ticket:9481 : handled segmentation fault issue with
uenum_next
* r32529: ticket:9601: from-UTF-8 m:n conversion: properly
revert to pivoting for m:n matching
* r32574: ticket:9398: avoid use of utf8_countTrailBytes[],
rewrite/optimize U8_COUNT_TRAIL_BYTES() &
U8_NEXT_UNSAFE(), test _UNSAFE macros only with
(mostly) well-formed UTF-8 text
* r32907: ticket:9687: Propagate the ambiguous alias warning
when opening converter
* r37670: ticket:11776 Thread safety fixes in data loading.
* r37889: ticket:11765: fix utrans_stripRules() source
overruns from a comment or an escape at the end of
the source string; make U8_SET_CP_LIMIT() work with
index after NUL terminator, consistent with
U16_SET_CP_LIMIT(), although strictly speaking this
behavior is undefined
* r38086: ticket:11979: Fix max char size for iso-2022-kr in
icu4c
* r38185: ticket:12015: Update the array size to avoid buffer
overflow
Diffs for the ICU changes (with associated links to their
tickets) can be found at:
where REVISION is the corresponding numeric value.
Notes:
* r32907 makes a slight change to ucnv_open's return value
and isn't strictly necessary, but is included as a matter
of correctness and because we would eventually need to
handle the new behavior anyway. Changed sites that
checked directly against U_ZERO_ERROR to use
U_SUCCESS/U_FAILURE instead.
* Included r30326 and r37670 (which both involve race
conditions when loading ICU data), but we do not execute
those code paths.
Oliver Kurth [Fri, 15 Sep 2017 18:22:59 +0000 (11:22 -0700)]
Extend AsyncSocket code to handle a "network unreachable" error on a Linux
connect() system call.
modified: lib/asyncsocket/asyncSocketInt.h, lib/asyncsocket/asyncWebSocket.c,
lib/asyncsocket/asyncsocket.c, lib/include/asyncsocket.h,
Changes to common header files; not applicable to open-vm-tools.
Reorder the includes in services/plugins/dndcp/xutils/xutils.cc to build
with Gtk+ 3.x at a later date.
Oliver Kurth [Fri, 15 Sep 2017 18:22:58 +0000 (11:22 -0700)]
Stop building Linux kernel drivers by default in open-vm-tools.
All drivers have been upstreamed as of Linux kernel version 3.9,
so inhibit building them starting with kernel version 4.0.
Users can specify they want kernel modules by invoking configure
with "--with-kernel-modules".
Note one aspect of AC_WITH_ARGS that is not obvious is that specifying
--with-kernel-modules will automatically set with_kernel_modules=yes,
while specifying --without-kernel-modules will set it to no.
Oliver Kurth [Fri, 15 Sep 2017 18:22:58 +0000 (11:22 -0700)]
Hgfs Win Client: fix upgrade of driver by changing the Hgfs install settings
Some upgrades of the vmhgfs driver are requiring an additional
reboot even after the initial reboot. The Difx APIs replace the
driver with the new one on reboot, but after the old one is loaded.
This means that after the reboot everything looks good on the surface
but the old driver is running and not even on the disk at that point.
To mitigate this we can change the driver start type and fix missed
install settings both of which makes the HGFS driver compatible with
the rest of the Windows redirectors.
Perform to system registry changes to the vmhgfs driver service:
- set the HGFS driver dependent on the MUP component which it is anyway.
- set the driver start type to be demand start and not a standard system driver.
This makes that the vmtools system service responsible for starting the
Shared Folders client driver. This is again more compatible with the
Windows redirector model.
Oliver Kurth [Fri, 15 Sep 2017 18:22:58 +0000 (11:22 -0700)]
Check for a valid shell in pam configuration
When a program is run in a VM using vmrun from the host, the user account
is not checked for a valid shell. This changes adds this to the pam
configuration for vmtoolsd.
Note that /sbin/nologin is a valid shell in CentOS and RHEL, but
not in Ubuntu. Valid shells are those that are listed in /etc/shells.
Oliver Kurth [Fri, 15 Sep 2017 18:22:57 +0000 (11:22 -0700)]
Make Vsock RPC code handle the ECONNRESET
VMX might delay releasing a vsock when the client side closes
the end point first. This makes a later client vsock connect
attempt fail with ECONNRESET using the same source port as the
closed one. Note that the client binds OK on the reused source
port, since the client side has released the socket on that port.
Rewrote the connect code as to clarify it. Explicitly separated
the retry logic. Added code to return the system errno, and
added additional information about which socket API call failed.
Oliver Kurth [Fri, 15 Sep 2017 18:22:57 +0000 (11:22 -0700)]
Hgfs Fuse Client: fix attribute caching from hardcoded 5 seconds
The default attribute caching of 5 seconds is too long and is not
cleared by modifications to the file. This leaves users' applications
receiving stale attribute information for a file which can cause
applications to crash.
Set the default setting for the cache timeout to 1 so that corresponds
to the same as the kernel client.
Fix the rename that purges the cache of stale attribute data for the
target of the rename.
Oliver Kurth [Fri, 15 Sep 2017 18:22:57 +0000 (11:22 -0700)]
Make Vsock RPC code handle the ECONNRESET
VMX might delay releasing a vsock when the client side closes
the end point first. This makes a later client vsock connect
attempt fail with ECONNRESET using the same source port as the
closed one. Note that the client binds OK on the reused source
port, since the client side has released the socket on that port.
Rewrote the connect code as to clarify it. Explicitly separated
the retry logic. Added code to return the system errno, and
added additional information about which socket API call failed.
Oliver Kurth [Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)]
fileIOPosix.c: Add new function FileIO_CreateRetry().
fileIO.h: Add new function FileIO_CreateRetry().
config.h: Add new function Config_TriToBool().
hostinfo.h: Add new function Hostinfo_EnumerateAllProcessPids().
hostname.c: Allow hostname to be UTF8.
posixPosix.c: Using __GLIBC__ define to control use of euidaccess().
vmxnet3_defs.h: Update the coalescing configuration through the guest OS.
Bump the Tx Data Desc Max Size to 2048.
The drag-n-drop plugin clipboard updated to allow the clipboard size to be adjusted by the consumer via new CPClipboard_InitWithSize() function.
Common source and header file changes that are not applicable to open-vm-tools.
Oliver Kurth [Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)]
Fix HGFS mount call to create mount point
For FUSE clients and open-vm-tools installations the package
might not create the shared folders mount point. The only reliable
way to ensure that we have one is to create it ourselves.
This seems okay to do since it is a hardcoded path and has always
been set to this same path without any regard for configuration by
users, although that may change in later change sets.
This also ensures if a user has inadvertently deleted the mount
point after installing tools and before enabling the Shared Folders
feature the mount will be robust enough to still mount.
Secondly, did some clean up of the mount function to move the check
for already mounted into a separate function. This will prove useful
if a umount call is added on a disable of the feature.
Finally, the mount file table check now uses the common mount info
macros and the system calls are replaced with ProcMgr exec calls.
The file access checks now use the glib routines as do the mkdir and
rmdir for mount point creation and deletion.
Oliver Kurth [Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)]
Increase the scope of 'opLock' to avoid the race in VmBackupAsyncCallback.
A previous change fixed a race between worker thread and main thread
VmBackupAsyncCallback that could lead to premature release of
'currentOp' from 'gBackupState'. If the 'currentOp' was set after
VmBackupAsyncCallback had queried status of the 'currentOp' but
VmBackupAsyncCallback was not done with 'status' value check,
it could release the 'currentOp' prematurely because 'status'
was initialized to VMBACKUP_STATUS_FINISHED. The fix was to
initialize the 'status' to VMBACKUP_STATUS_PENDING. The fix
broke tests that invoke quiescing with 'execScripts = false'
option and in that case there is no 'currentOp' setup by the
VmBackupStartScripts() call that leaves VmBackupAsyncCallback
in its initialized 'status' VMBACKUP_STATUS_PENDING forever.
This fix reverts the previous fix by restoring the 'status' initial
value to VMBACKUP_STATUS_FINISHED and increases the scope of the
lock 'opLock' to address the race condition.
This change also adds some Tools configuration settings to make
it easy to test HBR scenario.
As reading configuration is common functionality, moved
the common functions to vmtoolslib.
Oliver Kurth [Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)]
Hgfs Fuse Client: fix for backdoor not available
The client dropped errors for failing to open the backdoor returning FALSE,
when the HGFS server was not enabled which migrated to a protocol error.
This could mislead users when mounting the FUSE file system when the
feature was disabled into thinking there was a different issue when
actually enabling the feature was required before mounting. It was not
a protocol mismatch between the client and server.
The main entry point now logs a message for the user if the transport init
fails and so the mount does not occur.
i
The main issue to prevent the mount being created when the feature is disabled
is addressed by the transport init function now trying to open the
transport and generate an initial connection. This fails when the HGFS
server is disabled because the feature is disabled. Hence, there will not
be a mount made and an error is reported to users.
If a mount is created when the feature is enabled and then later disabled
via the UI settings, the mount will still exist as there is no umount made
at that point. This will be addressed in later fixes. However, it should be
noted that the leftover mount which is now not accessible reports that the
"Transport endpoint is not connected" instead of the previous error of
"protocol error".
Oliver Kurth [Fri, 15 Sep 2017 18:22:56 +0000 (11:22 -0700)]
Don't include errno.h in vsockSocketWrapper.h.
A recent change added errno.h to vsockSocketWrapper.h.
Since errno.h is intended for UNIX compatibility, whereas
vsockSocketWrapper.h redefines the error values to their
Windows equivalentsr, it needed to be removed.
Oliver Kurth [Fri, 15 Sep 2017 18:22:55 +0000 (11:22 -0700)]
Use pkg-config directly instead of $PKG_CONFIG
$PKG_CONFIG isn't set in the configure script, but we do check for
pkg-config in the path. So use it directly to determine udev
directory path for udev rules.