Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 08B73C4743C for ; Mon, 21 Jun 2021 18:52:54 +0000 (UTC) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 37A8E6115A for ; Mon, 21 Jun 2021 18:52:53 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 37A8E6115A Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4A40B829E7; Mon, 21 Jun 2021 20:52:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="gzTmhwW4"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id BD2F7829C8; Mon, 21 Jun 2021 20:52:24 +0200 (CEST) Received: from mail-ed1-x532.google.com (mail-ed1-x532.google.com [IPv6:2a00:1450:4864:20::532]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5D2C2829B9 for ; Mon, 21 Jun 2021 20:52:20 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=alpernebiyasak@gmail.com Received: by mail-ed1-x532.google.com with SMTP id df12so17906570edb.2 for ; Mon, 21 Jun 2021 11:52:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Zv74EUTei5ChD04Roy8TIdX9e4wVRKnpWDip0/c2TZ8=; b=gzTmhwW4kXQBPk3ZA8Dk5cC6BO4GZxqHofgem5X03APAw9qbBgs4xtVkAGXZ5b08w1 /ppY7bNkHubgAq702Bh+oh0zCziLQ9au/2wVlcmAY4xu1qbK1vRymH5cPBny9d7Q3vB/ ekVROhX5uF/ZExr4h1qhY1lBQxzpYBh1TWWddKSIOaEKpKlESU2PNHJzSiCQ/aLg+KHF 4kYEjCJsanbdVGIun7w2+8oOuLqx1u2iVlv8nTs9AB6wKXvN+vY+5aqY5pztAuBiZquq wFNRQo/Ort9jL5mXFZWjO0PevZxne2jMVpBBbMiRkZHkNDp8+of3fe2ibsMb2ctzkkD6 BhEQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Zv74EUTei5ChD04Roy8TIdX9e4wVRKnpWDip0/c2TZ8=; b=dVvCUz7/1uHuS4KbSSE31yMFIeifrhuBcVbVzLhNv9GgcPKNTI4KAgYX76H/LSEdFd 5KVNFv3wIYv81iqz6IIOrySMg3Ol8C9SybV909tqtecA5781RPZeifDf6ovUmdqGQgTu TPsWMIGUosSS7byhiYHcj1f/ecSPv2AD/kJL2kQsPzhOx+8vO2NTHIkUhfGMv1CFn8Xd /IrFUHRPCVjmhpVmiGLe6pRZHe5dVOiy53nO71a/Y987cuPDmzDbVgRTfLFTpjXuZI8B ilpnZQ8oztDTg2Jrqw+U4g7331An8YtDxpF6RB5n3AnYwExfzr5g4msJezVPeHT25ORO U6dA== X-Gm-Message-State: AOAM531aFiA7CLAvGruVxtP4IWzftZieNwAyEWvHBQcvNL7uxke7wjfh MMnEuX7YdyH9gQPRCanJXE0s5ulZOVs= X-Google-Smtp-Source: ABdhPJzo3GuJvWJ9s0zeFKnsPm48+09GSC7Kc6OjOQcvJnh2COu1nkJVCoRgapk/TqvCf4Xzui1QLQ== X-Received: by 2002:a50:bf0f:: with SMTP id f15mr23239295edk.205.1624301539480; Mon, 21 Jun 2021 11:52:19 -0700 (PDT) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id n11sm5205690ejg.43.2021.06.21.11.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Jun 2021 11:52:18 -0700 (PDT) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Daniel Schwierzeck , Simon Glass , Bin Meng , AKASHI Takahiro , Heinrich Schuchardt , Marek Vasut , Tom Rini , Alper Nebi Yasak Subject: [PATCH v3 3/3] Azure: Add loop devices and CAP_SYS_ADMIN for sandbox test.py tests Date: Mon, 21 Jun 2021 21:51:56 +0300 Message-Id: <20210621185156.9108-4-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210621185156.9108-1-alpernebiyasak@gmail.com> References: <20210621185156.9108-1-alpernebiyasak@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.2 at phobos.denx.de X-Virus-Status: Clean 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 --- (no changes since v2) Changes in v2: - Always pass in /dev/fuse to Azure's docker run invocation. - Remove "and some EFI tests" from comment (no longer applies to that block of code). .azure-pipelines.yml | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index 976868dd2eb7..e36a27c97d56 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' -- 2.32.0