libvirt/src
Michal Privoznik 52970dec5b virt-aa-helper: Improve valid_path
So, after some movement in virt-aa-helper, I've noticed the
virt-aa-helper-test failing. I've ran gdb (it took me a while to
realize how to do that) and this showed up immediately:

  Program received signal SIGSEGV, Segmentation fault.
  strlen () at ../sysdeps/x86_64/strlen.S:106
  106     ../sysdeps/x86_64/strlen.S: No such file or directory.
  (gdb) bt
  #0  strlen () at ../sysdeps/x86_64/strlen.S:106
  #1  0x0000555555561a13 in array_starts_with (str=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", arr=0x7fffffffd160, size=-1540438016) at security/virt-aa-helper.c:525
  #2  0x0000555555561d49 in valid_path (path=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", readonly=false) at security/virt-aa-helper.c:617
  #3  0x0000555555562506 in vah_add_path (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw", recursive=false) at security/virt-aa-helper.c:823
  #4  0x0000555555562693 in vah_add_file (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw") at security/virt-aa-helper.c:854
  #5  0x0000555555562918 in add_file_path (disk=0x5555557d4440, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", depth=0, opaque=0x7fffffffd3e0) at security/virt-aa-helper.c:931
  #6  0x00007ffff78f18b1 in virDomainDiskDefForeachPath (disk=0x5555557d4440, ignoreOpenFailure=true, iter=0x5555555628a6 <add_file_path>, opaque=0x7fffffffd3e0) at conf/domain_conf.c:23286
  #7  0x0000555555562b5f in get_files (ctl=0x7fffffffd670) at security/virt-aa-helper.c:982
  #8  0x0000555555564100 in vahParseArgv (ctl=0x7fffffffd670, argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1277
  #9  0x00005555555643d6 in main (argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1332

So I've taken look at valid_path() because it is obviously
calling array_starts_with() with malformed @size. And here's the
result: there are two variables to hold the size of three arrays
and their value is recalculated before each call of
array_starts_with(). What if we just use three variables,
initialize them and do not touch them afterwards?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-08-27 15:05:25 +02:00
..
access viraccessperm.h: Fix some typos 2015-07-17 09:41:31 +02:00
admin admin: Tiny cleanups 2015-07-27 09:33:24 +02:00
bhyve bhyve: add UTC clock support 2015-07-22 19:05:09 +03:00
conf conf: Check for attach disk usage of iothread=0 2015-08-20 12:10:21 -04:00
cpu cpu: Move check for NULL CPU model inside the driver 2015-08-21 15:42:38 -07:00
esx maint: remove incorrect apostrophes from 'its' 2015-06-04 10:01:42 +02:00
hyperv domain: Convert os.type to VIR_DOMAIN_OSTYPE enum 2015-04-20 16:40:09 -04:00
interface Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
libxl conf: Pass private data to Parse function of XML options 2015-08-13 15:06:06 +02:00
locking locking: Remove redundant 'srv' element from virLockDaemon 2015-08-24 10:37:12 +02:00
lxc lxc: Resolve Coverity RESOURCE_LEAK 2015-08-27 07:10:20 -04:00
network networkBandwidthGenericChecks: Drop useless check 2015-08-12 10:57:36 +02:00
node_device nodedev: update netdev feature bits before each dumpxml 2015-06-17 13:51:33 -04:00
nwfilter nwfilter: Fix sscanf off-by-one error in virNWFilterSnoopLeaseFileLoad 2015-06-02 10:16:29 +02:00
openvz nodeinfo: Add sysfs_prefix to nodeGetMemoryStats 2015-07-13 15:59:32 -04:00
phyp nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA 2015-07-13 15:59:32 -04:00
qemu qemu: Emit correct audit message for memory hot unplug 2015-08-26 17:47:49 -04:00
remote protocol: Don't use rename as a variable name 2015-08-15 17:15:33 +02:00
rpc virNetSocketCheckProtocols: handle EAI_NONAME as IPv6 unavailable 2015-08-11 22:08:50 +02:00
secret Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
security virt-aa-helper: Improve valid_path 2015-08-27 15:05:25 +02:00
storage storage: only run safezero if allocation is > 0 2015-08-24 13:51:44 +02:00
test test: introduce a function in test driver to check get vcpupin info 2015-07-24 06:49:54 -04:00
uml nodeinfo: Add sysfs_prefix to nodeGetMemoryStats 2015-07-13 15:59:32 -04:00
util utils: Remove the logging of errors from virNetDevSendEthtoolIoctl 2015-08-26 17:11:27 -04:00
vbox nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA 2015-07-13 15:59:32 -04:00
vmware nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA 2015-07-13 15:59:32 -04:00
vmx conf: Check for hostdev conflicts when assign default disk address 2015-08-12 16:09:05 -04:00
vz nodeinfo: Add sysfs_prefix to nodeCapsInitNUMA 2015-07-13 15:59:32 -04:00
xen Improve some errors for openconsole/channel 2015-06-24 10:11:56 +02:00
xenapi domain: conf: Drop expectedVirtTypes 2015-04-20 16:43:43 -04:00
xenconfig Use the correct symbol for 'onCrash' 2015-06-30 11:32:50 -04:00
admin_protocol-structs Revert "admin: Add virAdmHello function" 2015-06-16 14:08:59 +02:00
check-aclperms.pl
check-aclrules.pl
check-driverimpls.pl Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
check-drivername.pl
check-symfile.pl
check-symsorting.pl
datatypes.c Add libvirt-admin library 2015-06-16 13:46:20 +02:00
datatypes.h fix typo in comments 2015-08-10 09:39:13 +02:00
driver-hypervisor.h Introduce virDomainRename API 2015-08-14 10:50:20 +02:00
driver-interface.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-network.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-nodedev.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-nwfilter.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-secret.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-state.h Split driver.h into multiple parts 2014-10-23 11:10:05 +01:00
driver-storage.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
driver-stream.h Split driver.h into multiple parts 2014-10-23 11:10:05 +01:00
driver.c Use the DEFAULT_DRIVER_DIR macro 2015-04-02 10:27:56 +02:00
driver.h Removing probing of secondary drivers 2015-01-27 12:02:04 +00:00
dtrace2systemtap.pl
fdstream.c storage: tweak condition to properly test lseek 2015-03-04 14:51:44 +01:00
fdstream.h fdstream: introduce virFDStreamOpenBlockDevice 2014-08-25 10:46:13 +04:00
gnutls_1_0_compat.h
internal.h internal: Introduce virCheckNonEmptyStringArgGoto and reuse it 2015-06-26 16:05:10 +02:00
libvirt_admin_private.syms libvirt-admin: Generate symbols file 2015-08-20 10:19:27 +02:00
libvirt_admin_public.syms libvirt-admin: Generate symbols file 2015-08-20 10:19:27 +02:00
libvirt_atomic.syms
libvirt_driver_modules.syms
libvirt_esx.syms
libvirt_gnutls.syms
libvirt_internal.h don't disable state driver when libvirtd is not built 2015-01-27 12:02:04 +00:00
libvirt_libssh2.syms
libvirt_linux.syms
libvirt_lxc.syms
libvirt_openvz.syms
libvirt_private.syms security: Add virSecurityDomainSetDirLabel 2015-08-24 11:53:17 +02:00
libvirt_probes.d Add systemd/dtrace probes for DBus APIs 2015-01-15 11:07:13 +00:00
libvirt_public.syms Introduce virDomainRename API 2015-08-14 10:50:20 +02:00
libvirt_qemu_probes.d
libvirt_qemu.syms
libvirt_remote.syms rpc: Remove keepalive_required option 2015-08-10 13:15:56 +02:00
libvirt_sasl.syms
libvirt_vmware.syms
libvirt_vmx.syms
libvirt_xenconfig.syms Revert "src/xenconfig: Xen-xl parser" 2015-01-12 10:15:13 -07:00
libvirt_xenxlconfig.syms Introduce support for parsing/formatting Xen xl config format 2015-01-14 08:28:50 -07:00
libvirt-admin.c admin: Fix mingw build by reordering includes 2015-06-23 13:22:15 +02:00
libvirt-domain-snapshot.c Fix typo incomaptible -> incompatible 2015-06-30 12:26:25 +02:00
libvirt-domain.c virDomainRename: Extend API documentation 2015-08-24 15:20:35 +02:00
libvirt-host.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-interface.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-lxc.c Remove unnecessary curly brackets in rest of src/[a-n]*/ 2014-11-14 17:13:36 +01:00
libvirt-lxc.pc.in Fix build-time pkg-config files in VPATH 2014-11-06 15:59:28 +01:00
libvirt-network.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-nodedev.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-nwfilter.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-qemu.c
libvirt-qemu.pc.in Fix build-time pkg-config files in VPATH 2014-11-06 15:59:28 +01:00
libvirt-secret.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-storage.c debug: assure NULLSTR() around all %s args in debug at top of public APIs 2015-05-28 13:13:45 -04:00
libvirt-stream.c Move virStream related APIs out of libvirt.c 2014-10-24 16:42:49 +01:00
libvirt.c parallels: substitute parallels with vz spec file and Makefile 2015-06-17 15:07:55 +03:00
libvirt.conf
libvirt.pc.in Fix build-time pkg-config files in VPATH 2014-11-06 15:59:28 +01:00
lock_protocol-structs
lxc_monitor_protocol-structs Remove explicit enum from protocol structures 2015-07-08 14:34:38 +02:00
lxc_protocol-structs
Makefile.am lxc: Inherit namespace feature 2015-08-26 11:28:30 +01:00
nodeinfo.c nodeinfo: Fix build failure when KVM headers are not available 2015-08-03 17:14:16 +02:00
nodeinfo.h nodeinfo: Fix output on PPC64 KVM hosts 2015-08-03 08:38:46 -04:00
nodeinfopriv.h nodeinfo: Make sysfs_prefix usage more consistent 2015-07-14 17:11:36 -04:00
qemu_protocol-structs
README
remote_protocol-structs protocol: Don't use rename as a variable name 2015-08-15 17:15:33 +02:00
virkeepaliveprotocol-structs
virnetprotocol-structs

       libvirt library code README
       ===========================

The directory provides the bulk of the libvirt codebase. Everything
except for the libvirtd daemon and client tools. The build uses a
large number of libtool convenience libraries - one for each child
directory, and then links them together for the final libvirt.so,
although some bits get linked directly to libvirtd daemon instead.

The files directly in this directory are supporting the public API
entry points & data structures.

There are two core shared modules to be aware of:

 * util/  - a collection of shared APIs that can be used by any
            code. This directory is always in the include path
            for all things built

 * conf/  - APIs for parsing / manipulating all the official XML
            files used by the public API. This directory is only
            in the include path for driver implementation modules

 * vmx/   - VMware VMX config handling (used by esx/ and vmware/)


Then there are the hypervisor implementations:

 * bhyve         - bhyve - The BSD Hypervisor
 * esx/          - VMware ESX and GSX support using vSphere API over SOAP
 * hyperv/       - Microsoft Hyper-V support using WinRM
 * lxc/          - Linux Native Containers
 * openvz/       - OpenVZ containers using cli tools
 * phyp/         - IBM Power Hypervisor using CLI tools over SSH
 * qemu/         - QEMU / KVM using qemu CLI/monitor
 * remote/       - Generic libvirt native RPC client
 * test/         - A "mock" driver for testing
 * uml/          - User Mode Linux
 * vbox/         - Virtual Box using native API
 * vmware/       - VMware Workstation and Player using the vmrun tool
 * xen/          - Xen using hypercalls, XenD SEXPR & XenStore
 * xenapi/       - Xen using libxenserver


Finally some secondary drivers that are shared for several HVs.
Currently these are used by LXC, OpenVZ, QEMU, UML and Xen drivers.
The ESX, Hyper-V, Power Hypervisor, Remote, Test & VirtualBox drivers all
implement the secondary drivers directly

 * cpu/          - CPU feature management
 * interface/    - Host network interface management
 * network/      - Virtual NAT networking
 * nwfilter/     - Network traffic filtering rules
 * node_device/  - Host device enumeration
 * secret/       - Secret management
 * security/     - Mandatory access control drivers
 * storage/      - Storage management drivers


Since both the hypervisor and secondary drivers can be built as
dlopen()able modules, it is *FORBIDDEN* to have build dependencies
between these directories. Drivers are only allowed to depend on
the public API, and the internal APIs in the util/ and conf/
directories