Oliver Kurth [Thu, 13 Feb 2020 00:49:09 +0000 (16:49 -0800)]
lib/file: memory leak in File_WalkDirectoryNext
During a sequence of POSIX readdir calls it is possible for a directory
to be rearranged and a file that was previously reported may be found
again. The code that protects the caller from seeing this isn't freeing
the file name string if a duplicate is discovered. Fix this.
Oliver Kurth [Mon, 6 Jan 2020 23:46:20 +0000 (15:46 -0800)]
Changes to common header files.
Make ALIGNED() functional for 64-bit Windows
The current implementation of ALIGNED in vm_basic_types.h only
works for compilers that are, or pretend to be, GCC. However,
it is reasonable to conclude that data specifically aligned
for one OS / compiler should be aligned the same way when built
with other tools or for OSes.
This change updates the ALIGNED macro to correctly function when
building on 64-bit Windows. If not using GCC-alike, or Windows,
the macro continues to expand to nothing.
The MSVC __declspec construct accepts a limited syntax, basically
requiring an integer literal (see pciPassthruInfo_public.h). It
must be a prefix operation.
The GCC __attribute__ is more expressive and can be postfix or
prefix, so it is moved to be prefix.
The bulk of the change moves the use of ALIGNED to be prefix in
all places that compile for the Workstation product on Windows.
Oliver Kurth [Mon, 6 Jan 2020 23:46:20 +0000 (15:46 -0800)]
Tools: More support for "VMware Tools for Linux-arm64"
Preliminary touch-ups in the main branch to support the upcoming upstreaming
of the "VMware Tools for Linux-arm64" build code.
bora-vmsoft/vgauth/service/servicePosix.c:
The glibc on arm64 does not have <sys/io.h>. It makes sense because I/O
ports are an x86-ism (for more details, sees
https://bugzilla.redhat.com/show_bug.cgi?id=1116162#c1 ). Instead of
making the inclusion conditions more complex, It was noticed that none
of the symbols defined in <sys/io.h> and <sys/sysinfo.h> are used in
this C file. So these inclusions are not necessary.
Oliver Kurth [Fri, 20 Dec 2019 20:25:51 +0000 (12:25 -0800)]
Changes to common source files not directly applicable to open-vm-tools.
Depriv the file locking code, part 1
This is the first change in a series of changes toward removing the
need to be root to use the file locking code. Here, doing some cleanup
and separate the file locking code from the device locking code.
Another later change will depriv the file locking code.
Oliver Kurth [Fri, 20 Dec 2019 20:25:50 +0000 (12:25 -0800)]
[Dynbuf] Rename DynBuf_GrowToFit to DynBuf_EnsureMinSize
As suggested, GrowToFit isn't a verb, suggest renaming the function to
DynBuf_EnsureMinSize, and change the description as "Ensure that the
size of the DynBuf is at least 'size'"
Change all references of DynBuf_GrowToFit to DynBuf_EnsureMinSize.
Oliver Kurth [Fri, 20 Dec 2019 20:25:50 +0000 (12:25 -0800)]
[Dynbuf] Fix minor bug in DynBuf_GrowToFit
DynBuf_GrowToFit tries to provide a dynbuf with size greater than the
given size. However, the second argument passed to DynBuf_Enlarge doesn't
match the intention. The size should be directly passed, not the
difference between the target and current size.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)]
Avoid vmtoolsd crash in HostInfo.
The guest identification code causes vmtoolsd to crash in certain
versions of some distros. The crash is caused by recent changes to
the lsb_release command. Previously, if the command existed, all
of its options worked. Now, some of the options no longer exist.
Change the code to check for an lsb_release failure whenever it is
invoked.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)]
Configurable environment for vmtoolsd.
If a user wants to override(*) an environment variable e.g.
TMPDIR for vmtoolsd, the only choices for the user are:
1. Change system environment variable, that may affect more
than vmtoolsd
2. Change vmtoolsd service startup scripts on Linux.
Some of these methods, especially #2 gets overwritten by
upgrades and user is forced to re-apply the change on every
upgrade of VMTools. Also, #2 is somewhat complex due to
different type of VMTools installations and differences
in Linux distros.
We can't override the environment completely from within
service but we can configure the environment to a large
extent once vmtoolsd comes up and reads tools.conf.
*=> "override" term here applies to setting, modifying and/or
unsetting an environment variable.
This is mainly required for system service vmsvc, but
given that vmusr shares code with vmsvc, we can provide
this functionality for both.
Updated example tools.conf with the new configuration.
Oliver Kurth [Wed, 11 Dec 2019 18:19:09 +0000 (10:19 -0800)]
nicinfo: report real nameservers used when using systemd-resolved
If systemd-resolved is used, report the external DNS server, not the
locally installed one. This is detected by checking if /etc/resolv.conf
is a link to /run/systemd/resolve/stub-resolv.conf. In that case,
/run/systemd/resolve/resolv.conf will hold the actual DNS server. See
https://www.freedesktop.org/software/systemd/man/systemd-resolved.service.html
Oliver Kurth [Wed, 11 Dec 2019 18:19:08 +0000 (10:19 -0800)]
Remove residual data when the DNS nameserver configuration changes.
If the list of DNS nameservers available should shorten or both IPv4 and
IPv6 entries are present, residual data can still be available for display.
This change to nicInfoPosix.c corrects the problem.
Oliver Kurth [Wed, 11 Dec 2019 18:19:08 +0000 (10:19 -0800)]
Avoid securing disk device info for ZFS pools (at this time)
ZFS filesystem pools device names can appear as single directory name
at the root directory. The current logic to locate the
/sys/class/blocks/<device> PCI structure based on typical device name
format will fail for ZFS pools. As an immediate fix to the SIGSEGV,
avoid attempting to locate the PCI info; keep vmtoolsd running.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)]
Avoid vmtoolsd crash in HostInfo.
The guest identification code causes vmtoolsd to crash in certain
versions of some distros. The crash is caused by recent changes to
the lsb_release command. Previously, if the command existed, all
of its options worked. Now, some of the options no longer exist.
Change the code to check for an lsb_release failure whenever it is
invoked.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)]
Remove an unused variable from the "VMware Tools for Linux-Arm" build
The gHvVendor variable is unused when building for arm64. So move the
variable declaration next to the only x86 code which uses the variable,
and rename the variable since it is no longer global.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)]
Introduce Clang SA-specific assert
Introduce an assert which would only be generated during clang SA
execution. With it we would avoid generating extra code from
assertations which might be needed specifically for Clang SA's correct
working (even with enabled analyzer, binary wouldn't grow, as
__clang_analyzer__ is only defined while the analyzer is parsing
the files for analysis, and not during Clang's compilation).
Cases in which might be used is for example before a statement which
we are fine just to fail or to possibly silence a false positive.
A real example where we would require such assertion is for the attached
report in the review. There seem to be a bug with the analyzer where it
will falsely ignore branches if we assert a parent class pointer before
using dynamic_cast as it will evaluate both pointers to be same.
To show more precisely, we would use helper functions from debug checker
ExprInspection.
Even knowing 'e' is not a nullptr, the analyzer falsely evaluates 'e'
and 'mfe' to be the same, which leads to many other wrong assumptions.
Example 5 (What would be best way to work around this bug with least
analyzer impact):
745 void
746 DvsKeeper::GetMethodFault(Exception *e, Ref<MethodFault>& fault)
747 {
748 MethodFault::Exception *mfe = dynamic_cast<MethodFault::Exception *>(e);
749 clang_analyzer_warnIfReached();
750 if (mfe != nullptr) {
751 clang_analyzer_warnIfReached();
752 fault = mfe->GetFault();
753 } else {
754 clang_analyzer_warnIfReached();
755 ASSERT(e != nullptr);
756 clang_analyzer_warnIfReached();
757 fault = new SystemError(e->what());
758 }
759 clang_analyzer_warnIfReached();
760 }
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:749:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:751:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:754:7: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
bora/vpx/vpxd/dvs/core/dvsKeeper.cpp:759:4: warning: REACHABLE
clang_analyzer_warnIfReached();
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
4 warnings generated.
In such cases, we could look into the problem as both real and analyzer
issue and other ways to "fix" it either don't work, or impact the further
work of the analyzer, which we would like to be as minimal as possible.
Oliver Kurth [Thu, 5 Dec 2019 19:34:43 +0000 (11:34 -0800)]
Add arm64 support in open-vm-tools
This adds the required files and fixes to be able to build
the open-vm-tools for arm64.
One major change is the update of autoconf from 2.61 to 2.69,
with automake. The autoconf update forced to add the libtool
include path to properly run autoreconf on the tools. I don't
know if these AUTOCONF/AUTORECONF variables are used anywhere
else.
The open-vm-tools have been tested on debian 10 and fedora 31
VMs (thanks to Andreas Scherr).
Also fixed Hostinfo_TouchVirtualPC() which was incorrectly
testing if vm_x86_64 was defined. It is always defined, to
either to 0 or 1.
Oliver Kurth [Fri, 22 Nov 2019 22:52:35 +0000 (14:52 -0800)]
Fix a potential NULL pointer dereference in the vmbackup plugin.
In some circumtances, VmBackupAsyncCallback might dereference
gBackupState after calling VmBackupDoAbort even though the
latter function can potentially set gBackupState to NULL. Add
a check to prevent the potential NULL pointer dereference.
Oliver Kurth [Fri, 22 Nov 2019 22:52:34 +0000 (14:52 -0800)]
Enable appinfo plugin for hosted products.
Currently, with TOT code, appInfo plugin is loaded only when
the VM is managed by VMware ESX server. In this changeset, that
limitation is removed and the plugin will be loaded for hosted
products also.
Oliver Kurth [Tue, 12 Nov 2019 02:12:23 +0000 (18:12 -0800)]
open-vm-tools: Do not build the appInfo plugin on FreeBSD
The appInfo plugin is supported only on Linux and Windows guests.
Modify the bora-vmsoft/install/Source/services/plugins/Makefile.am
to only include appInfo in the build if OVT is being built for a Linux
guest.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)]
Fix issues of unchecked return value reported by Coverity.
CID 80926 (#2 of 2): Unchecked return value (CHECKED_RETURN)
8. check_return: Calling ForkExecAndWaitCommand without checking return value
CID 80934 (#2 of 2): Unchecked return value from library (CHECKED_RETURN)
3. check_return: Calling lseek(pkgFd, 512L, 0) without checking return value.
This library function may fail and return an error code.
CID 80927 (#4 of 4): Unchecked return value from library (CHECKED_RETURN)
5. check_return: Calling fcntl(p->stdoutFd, 4, flags | 0x800) without
checking return value. This library function may fail and return an error
code.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)]
Use malloc everywhere in linux deploypkg plugin code
This change is replacing Util_SafeMalloc() by malloc() in Linux
deploypkg plugin code. Also changing if statement to == NULL
or != NULL for char* type.
Oliver Kurth [Tue, 12 Nov 2019 02:12:22 +0000 (18:12 -0800)]
Configurable environment for vmtoolsd.
If a user wants to override(*) an environment variable e.g.
TMPDIR for vmtoolsd, the only choices for the user are:
1. Change system environment variable, that may affect more
than vmtoolsd
2. Change vmtoolsd service startup scripts on Linux.
Some of these methods, especially #2 gets overwritten by
upgrades and user is forced to re-apply the change on every
upgrade of VMTools. Also, #2 is somewhat complex due to
different type of VMTools installations and differences
in Linux distros.
We can't override the environment completely from within
service but we can configure the environment to a large
extent once vmtoolsd comes up and reads tools.conf.
*=> "override" term here applies to setting, modifying and/or
unsetting an environment variable.
This is mainly required for system service vmsvc, but
given that vmusr shares code with vmsvc, we can provide
this functionality for both.
Updated example tools.conf with the new configuration.