summaryrefslogtreecommitdiff
path: root/.azure-pipelines.yml
diff options
context:
space:
mode:
authorAlper Nebi Yasak <alpernebiyasak@gmail.com>2021-06-21 21:51:56 +0300
committerTom Rini <trini@konsulko.com>2021-07-05 22:28:32 +0300
commite22ec9c6927bb565b89556eb7dc7856790778e46 (patch)
treec7aa069e5020a44cff91ba6c72d7007b236515ef /.azure-pipelines.yml
parent1aaaf60d200c6bdc556626d586d8b57b8a86d832 (diff)
downloadu-boot-e22ec9c6927bb565b89556eb7dc7856790778e46.tar.xz
Azure: Add loop devices and CAP_SYS_ADMIN for sandbox test.py tests
The filesystem test setup needs to prepare disk images for its tests, with either guestmount or loop mounts. The former requires access to the host fuse device (added in a previous patch), the latter requires access to host loop devices. Both mounts also need additional privileges since docker's default configuration prevents the containers from mounting filesystems (for host security). Add any available loop devices to the container and try to add as few privileges as possible to run these tests, which narrow down to adding SYS_ADMIN capability and disabling apparmor confinement. However, this much still seems to be insecure enough to let malicious container processes escape as root on the host system [1]. [1] https://blog.trailofbits.com/2019/07/19/understanding-docker-container-escapes/ Since the mentioned tests are marked to run only on the sandbox board, add these additional devices and privileges only when testing with that. An alternative to using mounts is modifying the filesystem tests to use virt-make-fs (like some EFI tests do), but it fails to generate a partitionless FAT filesystem image on Debian systems. Other more feasible alternatives are using guestfish or directly using libguestfs Python bindings to create and populate the images, but switching the test setups to these is nontrivial and is left as future work. Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
Diffstat (limited to '.azure-pipelines.yml')
-rw-r--r--.azure-pipelines.yml16
1 files changed, 15 insertions, 1 deletions
diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml
index e8f3c9baa6..99964be53c 100644
--- a/.azure-pipelines.yml
+++ b/.azure-pipelines.yml
@@ -318,8 +318,22 @@ jobs:
# as sandbox testing need create files like spi flash images, etc.
# (TODO: clean up this in the future)
chmod 777 .
+ # Filesystem tests need extra docker args to run
+ set --
+ if [[ "${TEST_PY_BD}" == "sandbox" ]]; then
+ # mount -o loop needs the loop devices
+ if modprobe loop; then
+ for d in $(find /dev -maxdepth 1 -name 'loop*'); do
+ set -- "$@" --device $d:$d
+ done
+ fi
+ # Needed for mount syscall (for guestmount as well)
+ set -- "$@" --cap-add SYS_ADMIN
+ # Default apparmor profile denies mounts
+ set -- "$@" --security-opt apparmor=unconfined
+ fi
# Some tests using libguestfs-tools need the fuse device to run
- docker run --device /dev/fuse:/dev/fuse -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/test.sh
+ docker run "$@" --device /dev/fuse:/dev/fuse -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/test.sh
- job: build_the_world
displayName: 'Build the World'