summary refs log tree commit diff
path: root/seccomp
Commit message (Collapse)AuthorAge
...
* seccomp: refactor policy into common_device.policyZach Reizner2019-02-07
| | | | | | | | | | | | | CQ-DEPEND=CL:1449895 BUG=None TEST=vmc start termina Change-Id: Ia3edaafc1d2958bd40e6b1adc89dd5e29b679b06 Reviewed-on: https://chromium-review.googlesource.com/1448292 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* devices: gpu: allow brk syscallDavid Riley2019-02-05
| | | | | | | | | | | | BUG=chromium:926415 TEST=start Tomb Raider Change-Id: I55352a84a4edd03337f262e1474e0888abfc8c81 Reviewed-on: https://chromium-review.googlesource.com/1446939 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Riley <davidriley@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Riley <davidriley@chromium.org>
* Adds Virtio-Input device simulationJorge E. Moreira2019-02-01
| | | | | | | | | | | | | | | | | | | | | | | | This allows decoupling input from the wayland socket while using a standard virtio device for it. The proposed virtio input spec can be found at https://www.kraxel.org/virtio/virtio-v1.0-cs03-virtio-input.pdf, it has already been implemented in qemu and (guest) kernel support exists since version 4.1. This change adds the following options to crosvm: --evdev: Grabs a host device and passes it through to the guest --<device>: Creates a default configuration for <device>, receives the input events from a unix socket. <device> can be 'keyboard', 'mouse' or 'trackpad'. Bug=chromium:921271 Test=booted on x86 linux and manually tried virtio-input devices Change-Id: I8455b72c53ea2f431009ee8140799b0797775e76 Reviewed-on: https://chromium-review.googlesource.com/1412355 Commit-Ready: Jorge Moreira Broche <jemoreira@google.com> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: gpu: dup stdout to stderr to allow virglrenderer loggingDavid Riley2019-01-31
| | | | | | | | | | | | | | | | By default virglrenderer logs to stderr with VREND_DEBUG. dup stdout which is logged via logger to stderr so that virglrenderer logs can be seen. BUG=chromium:925590 TEST=cat /var/log/messages Change-Id: I3e1a5056dab9cfd895867b1835b421b144ee536b Reviewed-on: https://chromium-review.googlesource.com/1441352 Commit-Ready: David Riley <davidriley@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: gpu: name gpu threadDavid Riley2019-01-30
| | | | | | | | | | | | BUG=chromium:925590 TEST=pstree Change-Id: I2f591894db2a40a812f1720e1fc8422049d85902 Reviewed-on: https://chromium-review.googlesource.com/1440031 Commit-Ready: David Riley <davidriley@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: David Riley <davidriley@chromium.org>
* linux: Add ac97 device with CRAS backendpaulhsia2019-01-27
| | | | | | | | | | | | | | | | | | Add an ac97 device that plays audio through CRAS audio server. BUG=chromium:781398 BUG=chromium:907520 TEST=Test building by $ cargo build TEST=Deploy crosvm to DUT and test audio functionality CQ-DEPEND=CL:1429311 CQ-DEPEND=CL:1429542 Change-Id: Ia273d8f1e82c20d1f1882f088886458339399aae Reviewed-on: https://chromium-review.googlesource.com/1426282 Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
* linux: add ac97 to the pci busDylan Reid2019-01-26
| | | | | | | | | | | | | | | Add an ac97 device that plays audio to /dev/null. BUG=chromium:781398 TEST=Test crosvm with null device Change-Id: I3849974b732fc1550ec2bf0f805726bf2ca296f6 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1398641 Commit-Ready: Chih-Yang Hsia <paulhsia@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Tested-by: Chih-Yang Hsia <paulhsia@chromium.org> Reviewed-by: Chih-Yang Hsia <paulhsia@chromium.org>
* tpm: Virtio tpm deviceDavid Tolnay2019-01-24
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This CL adds a "tpm" Cargo cfg to crosvm which enables a TPM device backed by libtpm2 simulator. Tested by running the following inside cros_sdk: LIBRARY_PATH=~/src/minijail LD_LIBRARY_PATH=~/src/minijail \ cargo run --release \ --features tpm \ -- \ run \ -r rootfs.ext4 \ --seccomp-policy-dir seccomp/x86_64/ \ -p init=/bin/bash \ -p panic=-1 \ --disable-sandbox \ vmlinux.bin with a Linux image built from CL:1387655. The TPM self test completes successfully with the following output: https://paste.googleplex.com/5996075978588160?raw Justin's TPM playground runs with the following trace output. https://paste.googleplex.com/4909751007707136?raw Design doc: go/vtpm-for-glinux TEST=ran TPM playground program inside crosvm TEST=local kokoro BUG=chromium:911799 Change-Id: I2feb24a3e38cba91f62c6d2cd1f378de4dd03ecf Reviewed-on: https://chromium-review.googlesource.com/1387624 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: gpu: add lstat to gpu device seccompDavid Riley2019-01-09
| | | | | | | | | | | BUG=chromium:837073 TEST=vmc start --enable-gpu tatl; lxc start stretch-x; xterm && glxgears Change-Id: I42a096384cb536ec835de69b34db9b9a941bfeaf Reviewed-on: https://chromium-review.googlesource.com/1401110 Commit-Ready: David Riley <davidriley@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: block: fix seccomp failures from free()Daniel Verkamp2018-10-31
| | | | | | | | | | | | | | | | | | | It looks like free() will sometimes try to open /proc/sys/vm/overcommit_memory in order to decide whether to return freed heap memory to the kernel; change the seccomp filter to fail the open syscalls with an error code (ENOENT) rather than killing the process. Also allow madvise to free memory for the same free() codepath. BUG=chromium:888212 TEST=Run fio loop test on kevin Change-Id: I1c27b265b822771f76b7d9572d9759476770000e Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1305756 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: add getpid and prlimit to seccompYunlian Jiang2018-10-23
| | | | | | | | | | | | | This is needed to make sure seccomp work with glibc 2.27 BUG=chromium:897477 TEST=None Change-Id: I101aa07bffd8db2b449be1a697dafcd7d6f1cb58 Reviewed-on: https://chromium-review.googlesource.com/1294729 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Mike Frysinger <vapier@chromium.org>
* crosvm: add openat to seccompYunlian Jiang2018-10-21
| | | | | | | | | | | | | | This adds openat to a seccomp policy file if open is already there. We need this because glibc 2.25 changed it system call for open(). BUG=chromium:894614 TEST=None Change-Id: Ie5b45d858e8d9ea081fd7bfda81709bda048d965 Reviewed-on: https://chromium-review.googlesource.com/1292129 Commit-Ready: Yunlian Jiang <yunlian@chromium.org> Tested-by: Yunlian Jiang <yunlian@chromium.org> Reviewed-by: Manoj Gupta <manojgupta@chromium.org>
* qcow: track deallocated clusters as unreferencedDaniel Verkamp2018-10-05
| | | | | | | | | | | | | | | | | | | | | In deallocate_cluster(), we call set_cluster_refcount() to unref the cluster that is being deallocated, but we never actually added the deallocated cluster to the unref_clusters list. Add clusters whose refcounts reach 0 to the unref_clusters list as well. Also add mremap() to the seccomp whitelist for the block device, since this is being triggered by libc realloc() and other devices already include it in the whitelist. BUG=chromium:850998 TEST=cargo test -p qcow; test crosvm on nami and verify that qcow file size stays bounded when creating a 1 GB file and deleting it repeatedly Change-Id: I1bdd96b2176dc13069417e0ac77f0768f9f26012 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1259404 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* seccomp: Update 9p policyChirantan Ekbote2018-09-21
| | | | | | | | | | | | | | Add newfstatat for x86 and fstatat64 for arm to the seccomp policy file for the 9p device and server program. BUG=chromium:886535 TEST=`vmc share termina foo` and then `ls /mnt/shared` inside the VM works Change-Id: I6871f54ae885e080dca0ea5751987d59c55a59d6 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1232556 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* seccomp: whitelist connect for wl_deviceDaniel Verkamp2018-09-20
| | | | | | | | | | | | | | | The path to the wayland socket changed, so the previous whitelist based on the connect() arg2 sockaddr_un size now fails. BUG=None TEST=Verify that release build of crosvm starts again on chromebook Change-Id: I3c30977e7c1487b937d69e1dbce4b7fd87136978 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1234827 Reviewed-by: David Riley <davidriley@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: block: allow timerfd syscalls in seccompDaniel Verkamp2018-09-19
| | | | | | | | | | | | | | | | "devices: block: Flush a minute after a write" introduced new timerfd_ syscalls into the block device but did not add them to the seccomp whitelist. BUG=chromium:885238 TEST=Run crosvm in multiprocess mode and verify that it boots Change-Id: I1568946c64d86ab7dba535a430a8cbe235f64454 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1231513 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* gpu: add sandboxing via minijail for virtio gpu device.David Riley2018-09-17
| | | | | | | | | | | | | | | | | Sandboxing only works when started as chronos via concierge client. If started directly via crosvm as root, the jail will not have proper group permissions to access the Wayland socket. BUG=chromium:837073 TEST=build with --features=gpu; null_platform_test without --disable-sandbox CQ-DEPEND=CL:1213779 Change-Id: I6331f7ae1f5b99d31ad44cf158f72337294771f0 Reviewed-on: https://chromium-review.googlesource.com/1181168 Commit-Ready: David Riley <davidriley@chromium.org> Tested-by: David Riley <davidriley@chromium.org> Reviewed-by: Jorge Lucangeli Obes <jorgelo@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* devices: block: implement discard and write zeroesDaniel Verkamp2018-09-10
| | | | | | | | | | | | | | | | | Discard and Write Zeroes commands have been added to the virtio block specification: https://github.com/oasis-tcs/virtio-spec/commit/88c8553838346b26be4460485cc57c38850b36f7 Implement both commands using the WriteZeroes trait. BUG=chromium:850998 TEST=fstrim within termina on a writable qcow image Change-Id: I33e54e303202328c10f7f2d6e69ab19f419f3998 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1188680 Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* seccomp: move 9s policy aarch64 -> armStephen Barber2018-08-20
| | | | | | | | | | | | | | Seccomp policy for ARM hosts was recently moved from aarch64 to arm to accurately match the ABI used on the host. Move 9s policy to match this. BUG=none TEST=vm.Webserver on kevin succeeds Change-Id: I97daa524edcd411618561ce07525738bc65457cb Reviewed-on: https://chromium-review.googlesource.com/1180470 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* virtio: Implement the 9P deviceChirantan Ekbote2018-08-08
| | | | | | | | | | | | | | | | | | | | | | | Implement a new virtio_9p device to be used for sharing directories with the VM. BUG=chromium:703939 TEST=mount inside a VM and run `bonnie++ -r 256` Append the shared directory to the crosvm command line: --shared-dir /path/to/dir:test_9p Then mount in the guest: mkdir /tmp/9p mount -t 9p -o trans=virtio test_9p /tmp/9p -oversion=9p2000.L Or for a 9p root: run --shared-dir /mnt/vm_root:/dev/root -p 'root=/dev/root ro rootflags=ro,trans=virtio,version=9p2000.L,cache=loose rootfstype=9p' vmlinux.bin CQ-DEPEND=CL:1065170 Change-Id: I41fc21306ab5fa318a271f172d7057b767b29f31 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1065173 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* 9s: Server binary for the 9p file systemChirantan Ekbote2018-08-08
| | | | | | | | | | | | | | | | | | Add the 9s crate, which provides an executable that can serve the 9p file system protocol. It initially only supports connections over vsock but can easily be extended to support network and unix domain socket based connections. BUG=chromium:703939 TEST=Run the server, have maitred connect to it over vsock, mount the 9p file system in the guest kernel, share it with the penguin container, and run `bonnie++ -r 256 -s 512` CQ-DEPEND=CL:1121550, CL:1166446 Change-Id: Ia0c72bcf29188bba4c07b6c0a2dd5a83d02339b5 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1112870 Reviewed-by: Dylan Reid <dgreid@chromium.org>
* balloon: Implement device policyChirantan Ekbote2018-07-27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement a policy for the balloon device so that it starts taking memory away from the VM when the system is under low memory conditions. There are a few pieces here: * Change the madvise call in MemoryMapping::dont_need_range to use MADV_REMOVE instead of MADV_DONTNEED. The latter does nothing when the memory mapping is shared across multiple processes while the former immediately gives the pages in the specified range back to the kernel. Subsequent accesses to memory in that range returns zero pages. * Change the protocol between the balloon device process and the main crosvm process. Previously, the device process expected the main process to send it increments in the amount of memory consumed by the balloon device. Now, it instead just expects the absolute value of the memory that should be consumed. To properly implement the policy the main process needs to keep track of the total memory consumed by the balloon device so this makes it easier to handle all the policy in one place. * Add a policy for dealing with low memory situations. When the VM starts up, we determine the maximum amount of memory that the balloon device should consume: * If the VM has more than 1.5GB of memory, the balloon device max is the size of the VM memory minus 1GB. * Otherwise, if the VM has at least 500MB, the balloon device max is 50% of the size of the VM memory. * Otherwise, the max is 0. The increment used to change the size of the balloon is defined as 1/16 of the max memory that the balloon device will consume. When the crosvm main process detects that the system is low on memory, it immediately increases the balloon size by the increment (unless it has already reached the max). It then starts 2 timers: one to check for low memory conditions again in 1 seconds (+ jitter) and another to check if the system is no longer low on memory in 1 minute (+ jitter) with a subsequent interval of 30 seconds (+ jitter). Under persistent low memory conditions the balloon device will consume the maximum memory after 16 seconds. Once there is enough available memory the balloon size will shrink back down to 0 after at most 9 minutes. BUG=chromium:866193 TEST=manual Start 2 VMs and write out a large file (size > system RAM) in each. Observe /sys/kernel/mm/chromeos-low_mem/available and see that the available memory steadily decreases until it goes under the low memory margin at which point the available memory bounces back up as crosvm frees up pages. CQ-DEPEND=CL:1152214 Change-Id: I2046729683aa081c9d7ed039d902ad11737c1d52 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1149155 Reviewed-by: Sonny Rao <sonnyrao@chromium.org>
* seccomp: rename aarch64 -> armSonny Rao2018-07-23
| | | | | | | | | | | | | | | | | | | | These policies are not for aarch64 but use the 32-bit system calls. We call it aarch64 support because that's what we're targetting for the guest kernel, but it doesn't really make any sense to call the seccomp policies aarch64 when we're building a 32-bit binary. We can add real aarch64 seccomp policies when we start building a aarch64 crosvm binary. BUG=chromium:866197 TEST=emerge-kevin crosvm, run vm_CrosVmStart CQ-DEPEND=CL:1145903 Change-Id: I7c5e70fbc127e4209ed392cfcf10ea36a6dd4b2c Reviewed-on: https://chromium-review.googlesource.com/1145909 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* wl: add pipe2 and fcntl64 to wl_device.policyZach Reizner2018-07-23
| | | | | | | | | | | | | | | | | These syscalls were added to the x86 policy when vfd pipe support was added, but they were never added to the arm version, for whatever reason. This is needed to keep crosvm from getting killed by SIGSYS whenver the user copies to or from guest applications. BUG=chromium:864218 TEST=on kevin, copy/paste to/from gedit Change-Id: Ibe385d50e367c362e911badd640bab2c98e07030 Reviewed-on: https://chromium-review.googlesource.com/1145876 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* virtwl: implement dmabuf sync supportDavid Reveman2018-06-19
| | | | | | | | | | | | | | | | | | | | | This provides proper synchronization for guest access to DMABufs. Virtio wayland device is given access to the DMA_BUF_SYNC ioctl in order to implement this. Being able to use this directly in the virtio wayland device process is important as these calls can sometimes be relatively expensive and they are frequent enough that avoiding another context switch is useful for good performance. TEST=cache-line artifacts no longer noticeable BUG=chromium:837209 Change-Id: Ibb8d7c01f70ed5b74afd69288015a65186fec52a Reviewed-on: https://chromium-review.googlesource.com/1076928 Commit-Ready: David Reveman <reveman@chromium.org> Tested-by: David Reveman <reveman@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: aarch64: whitelist gettimeofday for error messagesSonny Rao2018-06-01
| | | | | | | | | | | | | | | It looks like on ARM we use the real gettimeofday system call when we're outputting error messages, so we need to whitelist this to avoid crashing instead of seeing the error messages. BUG=chromium:843807 TEST=run vm_CrosVmStart and make sure there are no crashes for crosvm Change-Id: I9f47da8dabe31f0677bcaa1d431e56545e20c9c9 Reviewed-on: https://chromium-review.googlesource.com/1081390 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* qcow: Call fsync(2) when we want to flush to diskDylan Reid2018-05-18
| | | | | | | | | | Signal to the OS that we want these writes committed all the way to disk. Replace an existing call to flush as that's not sufficient. Change-Id: I9df9e55d2182e283e15eebc02a54c1ce08434f42 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1060696 Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: aarch64: fix truncate on wayland policySonny Rao2018-05-09
| | | | | | | | | | | | | | Like block_device, also needs to use ftruncate64 instead of ftruncate. BUG=chromium:840048 TEST=manual test of graphics on kevin Change-Id: Ib24b12fd681c96ecc2fec796fe480e94a96a0626 Reviewed-on: https://chromium-review.googlesource.com/1050916 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: aarch64: fix seccomp entry for ftruncate on aarch64Sonny Rao2018-04-26
| | | | | | | | | | | | | | Aarch64 seems to use ftruncate64 rather than ftruncate. BUG=chromium:816692 TEST=run VM on kevin using concierge Change-Id: I944f52d75fb9f5a3aaf5fe9e85708c48f249bb1a Reviewed-on: https://chromium-review.googlesource.com/1031175 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: aarch64: add epoll syscalls to seccomp policy for waylandSonny Rao2018-04-11
| | | | | | | | | | | | | | Match the configuration for x86_64 BUG=chromium:816692 TEST=run wayland under crosvm on kevin Change-Id: If21bccddba362656fc02b213b9f30166f2c4be13 Reviewed-on: https://chromium-review.googlesource.com/1006488 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* devices: use nested PollContext in wayland deviceZach Reizner2018-04-06
| | | | | | | | | | | | | The wl device was the last user of the old Poller. BUG=chromium:816692 TEST=run wayland under crosvm Change-Id: I6c1c1db2774a6e783b7bd1109288328d75ad2223 Reviewed-on: https://chromium-review.googlesource.com/1000102 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* crosvm: aarch64: add seccomp policy for wl_waylandSonny Rao2018-04-06
| | | | | | | | | | | | | | | Add a seccomp policy for virtio wayland devices on aarch64. BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on kevin built with USE="kvm_host" with a wayland socket passed in Change-Id: I89e9904b48598d78be0721ba8b3242d1b43f7aa3 Reviewed-on: https://chromium-review.googlesource.com/999169 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* wl: add pipe vfd supportZach Reizner2018-04-05
| | | | | | | | | | | | | | Pipe VFDs are used to send and recieve data offer bytes, often used for copy/paste and drag/drop operations. TEST=use copy/paste with wayland app BUG=chromium:793688 Change-Id: Ifc3f231dcdf90ce6791a98039405c7c404cf6942 Reviewed-on: https://chromium-review.googlesource.com/983037 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* devices: use PollContext for all virtio deivcesZach Reizner2018-04-05
| | | | | | | | | | | BUG=chromium:816692 TEST=run any VM Change-Id: I4219050fdb7947ca513f599f1ac57cde6052d397 Reviewed-on: https://chromium-review.googlesource.com/996917 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* devices: block: use PollContext in block deviceZach Reizner2018-04-04
| | | | | | | | | | | | | | Switching to PollContext so that there is one less user of Poller, which will be removed. TEST=run any vm with a block device BUG=chromium:816692 Change-Id: I2e1301ea9d66012262f1fcb69eaeee9f7464f3b3 Reviewed-on: https://chromium-review.googlesource.com/983036 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* crosvm: aarch64 guest supportSonny Rao2018-04-03
| | | | | | | | | | | | | | | | | | | - removes old ARMv7a (32-bit) bindings as we're only supporting aarch64 guests right now - switches both ARMv7 and aarch64 builds to use aarch64 kvm bindings - adds support for ARMv8 Linux guest with dynamic flattened-device-tree CQ-DEPEND=990894 BUG=chromium:797868 TEST=./build_test passes on all architectures TEST=crosvm runs on caroline TEST=crosvm runs on kevin built with USE="kvm_host" Change-Id: I7fc4fc4017ed87fd23a1bc50e3ebb05377040006 Reviewed-on: https://chromium-review.googlesource.com/969987 Commit-Ready: Sonny Rao <sonnyrao@chromium.org> Tested-by: Sonny Rao <sonnyrao@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* sys_util: use MADV_DONTDUMP for new mmapsZach Reizner2018-03-30
| | | | | | | | | | | | | | | | The mmaps made through the sys_util API are usually for guest memory or other large shared memory chunks that will pollute the file system with huge dumps on crash. By using MADV_DONTDUMP, we save the file system from storing these useless data segments when crosvm crashes. TEST=./build_test BUG=None Change-Id: I2041523648cd7c150bbdbfceef589f42d3f9c2b9 Reviewed-on: https://chromium-review.googlesource.com/890279 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* sys_util: add ppoll to seccomp policiesZach Reizner2018-01-27
| | | | | | | | | | | | | | This really should have been added along with the poll timeout support, which changed the syscalls used in every jailed device. TEST=run crosvm with sandboxing enabled BUG=None Change-Id: I6129fa589640bb2b85fb4274775192bdd49db672 Reviewed-on: https://chromium-review.googlesource.com/890379 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* main: Allow qcow files to be used as disksDylan Reid2018-01-19
| | | | | | | | | Using qcow to allow for growable disk. These will be used for user data. Change-Id: Iefb54eb4255db2ea7693db0020c5f1429acd73fd Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/862629 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* wl: fix seccomp filter for memfd_createZach Reizner2018-01-06
| | | | | | | | | | | | | | The memfd_create flags changed with "add memfd seal support", which breaks the seccomp filter for the wayland device. TEST=run a wayland app in crosvm BUG=chromium:799523 Change-Id: I266e305bc3179a7b9fd105a684de92e944fe1fc6 Reviewed-on: https://chromium-review.googlesource.com/852937 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* devices: Add balloonDylan Reid2017-12-18
| | | | | | | | | | The balloon device is used to take regions of unused memory from the guest and allow other host processes to use that memory. Change-Id: I06c821365a58672d605fc7555beaec599cae1b15 Signed-off-by: Dylan Reid <dgreid@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/759306 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: don't die on suspend/resumeStephen Barber2017-11-02
| | | | | | | | | | | | | | | Suspend/resume can cause syscall restarts and will cause KVM_RUN ioctls to return with EINTR. Handle these so the VM doesn't shut down. BUG=none TEST=vm survives suspend/resume Change-Id: I1fab624cb8fe0949d341408f0c962c859a034205 Reviewed-on: https://chromium-review.googlesource.com/750054 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm/devices: set thread namesStephen Barber2017-10-30
| | | | | | | | | | | | | | | | crosvm spawns a lot of processes/threads, and having these all use the same name as the original process can be confusing. So at least in the instances where Rust threads are spawned (vs. minijail_fork()), use a thread::Builder to allow setting the thread name. BUG=none TEST=start crosvm, check thread names with top Change-Id: I6e55ff5fd60f258880bda8e656ab7f9da82c656e Reviewed-on: https://chromium-review.googlesource.com/742394 Commit-Ready: Stephen Barber <smbarber@chromium.org> Tested-by: Stephen Barber <smbarber@chromium.org> Reviewed-by: Stephen Barber <smbarber@chromium.org>
* Add ability to minijail_forkDylan Reid2017-10-25
| | | | | | | | Change-Id: I0c774816067449cbb838dcf29c6fa947ae5916e1 Reviewed-on: https://chromium-review.googlesource.com/719442 Commit-Ready: Dylan Reid <dgreid@chromium.org> Tested-by: Dylan Reid <dgreid@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* Implement virtio-vsockChirantan Ekbote2017-09-18
| | | | | | | | | | | | | Implement the virtual sockets device using vhost subsystem of the host kernel to handle data transfer. BUG=chromium:708267 TEST=build and run maitred in guest VM without issue Change-Id: I35b542c0fc7e0fd9296f7ba3e1dfce60bf524d15 Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/638838 Reviewed-by: Stephen Barber <smbarber@chromium.org>
* crosvm: add virtio wayland deviceZach Reizner2017-09-08
| | | | | | | | | | | | | | | This adds the virtio wayland device which is activated by default. The wayland device needs the XDG_RUNTIME_DIR env variable to be set and a running wayland compositor to connect to in that directory. TEST=crosvm run <other args> BUG=chromium:738638 Change-Id: Iaa417c6bb74739896042318451b4befcac0c1d0e Reviewed-on: https://chromium-review.googlesource.com/559860 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* sys_util: use libc's openlog to connect to syslogZach Reizner2017-09-06
| | | | | | | | | | | | | | | | | | | | | | | By using libc's openlog, we can ensure that the internal state of the libc syslogger is consistent with the syslog module. Minijail will be able to print to stderr and the syslog in the same way the logging macros in crosvm do. The FD the syslog module uses is shared with libc and via `syslog::get_fds`, jailed processes can inherit the needed FDs to continue logging. Now that `sys_log::init()` must be called in single threaded process, this moves its tests to the list of the serially run ones in build_test.py. TEST=./build_test BUG=None Change-Id: I8dbc8ebf9d97ef670185259eceac5f6d3d6824ea Reviewed-on: https://chromium-review.googlesource.com/649951 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jason Clinton <jclinton@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* Put seccomp policy files in a common directoryChirantan Ekbote2017-08-25
We will almost certainly require different seccomp policy files for different architectures. Move all the existing secommp policy files into a common directory grouped by architecture. This will make it easier to install them via the ebuild later. BUG=none TEST=none Change-Id: I0495789cd4143dc374ee6ebe083dc20ce724edbb Signed-off-by: Chirantan Ekbote <chirantan@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/630058 Reviewed-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>