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,URIBL_BLOCKED,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 46DB3C4743C for ; Fri, 4 Jun 2021 19:03:27 +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 7753B613FA for ; Fri, 4 Jun 2021 19:03:26 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7753B613FA 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 8698B82EF0; Fri, 4 Jun 2021 21:02:55 +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="qrLHutXp"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8358382F1C; Fri, 4 Jun 2021 21:02:53 +0200 (CEST) Received: from mail-ej1-x630.google.com (mail-ej1-x630.google.com [IPv6:2a00:1450:4864:20::630]) (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 23A6E82EFE for ; Fri, 4 Jun 2021 21:02:49 +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-ej1-x630.google.com with SMTP id c10so15989102eja.11 for ; Fri, 04 Jun 2021 12:02:49 -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=ViIig1Htt87QHZeNnB983I3TQnp0qljAFGmqRTmRfz8=; b=qrLHutXpWprlV6c8egz3W7Njn/ow/StOjwtr7T3g34L0+DHsZYMAR6xbhgWSqDk541 5RvgvCkSAJqZAMUOhz4nP8ofg+5sUJTrhXrFYRSOBqm/OFgRaR3ledZq5pmoE0klaSc+ YrBdOXZXYFvUzM9FVtBh7YxmDVknza5lL3bwF+CP/4pnwkDEO6vFvh/oKudjSDQyhtgR vwS1ejN7qsGx74/7IudA5qlQfz69CNk4LOzQb2NVw5IPBLsFJ3u2a3g3gF4uK4et4OeD 1+TNz9D0p9UHh0GAVUVUsLyJeM4qjUIbTDHVwhNw7VStiKnmu8p/SIbDUb496pggcOnc y4lQ== 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=ViIig1Htt87QHZeNnB983I3TQnp0qljAFGmqRTmRfz8=; b=CkaiLiLDCPD4jcXCRdCwuoVkb4uRBsHMMkiPGvxQ6zzOD9w7+KdOSN6uIWE4PL/AZu SVcz6pGT9K0So1/lFwzcjsiJ6kiFm2zlkDE8ucpwcK8JoBVu4do7Vzan7tjrejMGMFuN Gds3eJuTZgMJRgmdZYP7Y33itfBKdW2NjIjYqa10c+lOeehbsWRTr6IrboKzoWkffFi3 Pre7hlURe1xJUzal6LTTgIPV73j+vqrUfG3oDaTEO2m7R2+cex/8OfzESrKJTmVQ/u6k ViBveQA8+wsNJry2z/yaoGO1W04jG8cWtFhQ39mya2svWL1Ti94MfmRHST/iIaklKbOa xCOQ== X-Gm-Message-State: AOAM530JiIVNzGtqVX5uXM7nImwU22vzNPvwmmhwLJNfFE0KcqWRi3AV 8d4EflxTv77wBwc1UgrA0KOym0qvm8U= X-Google-Smtp-Source: ABdhPJzIpCPoWAhP4vtMViqbw1efaPlqq/EGVh9vn2UucRYaypT/4f4wWDXBCUERrkJoehpe8+40iQ== X-Received: by 2002:a17:906:22c7:: with SMTP id q7mr5524736eja.547.1622833368437; Fri, 04 Jun 2021 12:02:48 -0700 (PDT) Received: from localhost.localdomain ([178.233.26.119]) by smtp.gmail.com with ESMTPSA id n2sm3668819edi.32.2021.06.04.12.02.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 04 Jun 2021 12:02:48 -0700 (PDT) From: Alper Nebi Yasak To: u-boot@lists.denx.de Cc: Bin Meng , Heinrich Schuchardt , Tom Rini , Daniel Schwierzeck , Simon Glass , Marek Vasut , Alper Nebi Yasak Subject: [PATCH 3/4] Azure: Add loop devices and CAP_SYS_ADMIN for sandbox test.py tests Date: Fri, 4 Jun 2021 22:02:05 +0300 Message-Id: <20210604190207.44805-4-alpernebiyasak@gmail.com> X-Mailer: git-send-email 2.32.0.rc2 In-Reply-To: <20210604190207.44805-1-alpernebiyasak@gmail.com> References: <20210604190207.44805-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.102.4 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 --- .azure-pipelines.yml | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml index a4d796c41895..3ec396ae8905 100644 --- a/.azure-pipelines.yml +++ b/.azure-pipelines.yml @@ -318,13 +318,23 @@ jobs: # as sandbox testing need create files like spi flash images, etc. # (TODO: clean up this in the future) chmod 777 . - # Some EFI tests need extra docker args to run + # Filesystem tests and some EFI tests need extra docker args to run set -- if [[ "${TEST_PY_BD}" == "sandbox" ]]; then - # virt-make-fs needs the fuse device + # virt-make-fs, guestmount, etc. need the fuse device if modprobe fuse; then set -- "$@" --device /dev/fuse:/dev/fuse fi + # 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 docker run "$@" -v $PWD:$(work_dir) $(ci_runner_image) /bin/bash $(work_dir)/test.sh -- 2.32.0.rc2