From patchwork Thu Dec 3 19:14:34 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11949443 X-Patchwork-Delegate: bpf@iogearbox.net 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 5F3E6C4167B for ; Thu, 3 Dec 2020 19:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 11458206F6 for ; Thu, 3 Dec 2020 19:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727017AbgLCTP2 (ORCPT ); Thu, 3 Dec 2020 14:15:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgLCTP2 (ORCPT ); Thu, 3 Dec 2020 14:15:28 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D7735C061A4F for ; Thu, 3 Dec 2020 11:14:41 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id e25so5036502wme.0 for ; Thu, 03 Dec 2020 11:14:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8J/w1vYL09UzAzi8602VoSkrOGO0D/bhvaHOEFu6hMc=; b=ANp3Tcj3/UuHs5Rp+fT1drvw4SM1uZ91+FxC1c6RLNMe55T/NHfPLFLRHknW54Ef6a GhJnysSFt8TR1uswCec22ItfBPa5Gf5zpRjZkXdmXkQ1ixTfS7xLxzFcj8xs6SGrLks0 CDYfV4ro3s2IaXqJkJ3LFNKV2KLp9DFoASp+4= 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=8J/w1vYL09UzAzi8602VoSkrOGO0D/bhvaHOEFu6hMc=; b=KCZcTdDkINOTaF7EpzdODk7vC7djTgnpPNuBdcRJ+jnmvr8W6E/qIpG/nltwrss0Mo kLQzMRIjAXaOCXb8GuZL+hhlyh4RkZiNKWpEunsU73HgoSFhFa4wD/+3wlhJRkrBsit2 2gvR3QvmOsoGJ7iA2Ko176FsVpSOJYmwwwS99SK1LCw0mDP8V9BeP6K+5dV4eRKITzvF 7b6OVb1lTRcZxIMvok9DbxYG8TIy4JfZFceudaZBRhv2THApqJHqhBVpaO6sAAcozgqd 0wiaID3upRG0qM68u5O5a8rXzdX8woXGisIIgvUbraaTl4BVU+CtOnTdlqsC6TtL9Tv/ NE0w== X-Gm-Message-State: AOAM530VEyihZyQnJQa43Uc5coYrnAn/mwYz0V6C5shQsyycC7tGaJtm Ywc0/LcpOjtuxMHIXdcSPA5hRqFIxz0/j6RD X-Google-Smtp-Source: ABdhPJypqerqINxs8hu/3QRjvFNuheQdKi2rztZ7v8iz7iXPKFljO2IuD++xzMTVV4aMMv1BH5TMLA== X-Received: by 2002:a1c:4645:: with SMTP id t66mr321675wma.152.1607022880187; Thu, 03 Dec 2020 11:14:40 -0800 (PST) Received: from kpsingh.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id q17sm516480wro.36.2020.12.03.11.14.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 11:14:39 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v4 1/4] selftests/bpf: Update ima_setup.sh for busybox Date: Thu, 3 Dec 2020 19:14:34 +0000 Message-Id: <20201203191437.666737-2-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203191437.666737-1-kpsingh@chromium.org> References: <20201203191437.666737-1-kpsingh@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: KP Singh losetup on busybox does not output the name of loop device on using -f with --show. It also doesn't support -j to find the loop devices for a given backing file. losetup is updated to use "-a" which is available on busybox. blkid does not support options (-s and -o) to only display the uuid, so parse the output instead. Not all environments have mkfs.ext4, the test requires a loop device with a backing image file which could formatted with any filesystem. Update to using mkfs.ext2 which is available on busybox. Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash") Reported-by: Andrii Nakryiko Signed-off-by: KP Singh Acked-by: Andrii Nakryiko --- tools/testing/selftests/bpf/ima_setup.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh index 15490ccc5e55..137f2d32598f 100755 --- a/tools/testing/selftests/bpf/ima_setup.sh +++ b/tools/testing/selftests/bpf/ima_setup.sh @@ -3,6 +3,7 @@ set -e set -u +set -o pipefail IMA_POLICY_FILE="/sys/kernel/security/ima/policy" TEST_BINARY="/bin/true" @@ -23,13 +24,15 @@ setup() dd if=/dev/zero of="${mount_img}" bs=1M count=10 - local loop_device="$(losetup --find --show ${mount_img})" + losetup -f "${mount_img}" + local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) - mkfs.ext4 "${loop_device}" + mkfs.ext2 "${loop_device:?}" mount "${loop_device}" "${mount_dir}" cp "${TEST_BINARY}" "${mount_dir}" - local mount_uuid="$(blkid -s UUID -o value ${loop_device})" + local mount_uuid="$(blkid ${loop_device} | sed 's/.*UUID="\([^"]*\)".*/\1/')" + echo "measure func=BPRM_CHECK fsuuid=${mount_uuid}" > ${IMA_POLICY_FILE} } @@ -38,7 +41,8 @@ cleanup() { local mount_img="${tmp_dir}/test.img" local mount_dir="${tmp_dir}/mnt" - local loop_devices=$(losetup -j ${mount_img} -O NAME --noheadings) + local loop_devices=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) + for loop_dev in "${loop_devices}"; do losetup -d $loop_dev done From patchwork Thu Dec 3 19:14:35 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11949445 X-Patchwork-Delegate: bpf@iogearbox.net 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 F0A5EC193FE for ; Thu, 3 Dec 2020 19:15:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3B63221EA for ; Thu, 3 Dec 2020 19:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728354AbgLCTPX (ORCPT ); Thu, 3 Dec 2020 14:15:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgLCTPW (ORCPT ); Thu, 3 Dec 2020 14:15:22 -0500 Received: from mail-wm1-x343.google.com (mail-wm1-x343.google.com [IPv6:2a00:1450:4864:20::343]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 75681C061A51 for ; Thu, 3 Dec 2020 11:14:42 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id w206so3272250wma.0 for ; Thu, 03 Dec 2020 11:14:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=v1b2sG2SIN3nDPtUc25i64mqNZeXcPSGhHhM6es0j9s=; b=OLhcLPPXuwLc+Di3BkYVe5yTBmotq1VupwQ3hc2wQBMSKJ6kjTgOEnKuOcdzjF67IQ MaBaXpBdWm+kctZO2eDSzC6I+d1FKm/B5KSV9UHSvBvKWa3nsHWns/+N2J2BzzJKu69O RAUZd5j12JO7Rio7u2r8pymAZwOhH0pUOHxBM= 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=v1b2sG2SIN3nDPtUc25i64mqNZeXcPSGhHhM6es0j9s=; b=VqgXZNG6snBAlIxfzrDNnyhF4uXCVk9JeRoQXTr6x7TW99D9wRjwuzmkH/asSdDdVK eJIMjP6Eg1bI87DYH2HXUNHNCIGrQv5ix/fcgPGYaXx1EcDlKJYhejmzY+m/yOPhKKVR AOq3hBnR5gO/6uBGJ8k7dS70UbuPEMweoGH4c0LMaMA2pvElpr4i1TyHKhegY1ruB2zC 2nl0ERm5j6oeqgxRzw58zEGN8mLwclhsEuf5xZkUzUR6WAp6ltuE5d/grMPTJBYY6uGh xiDQY5FcoYlFTKAjvQkzvvaUYZPJ6hgedUL41T8hiM3yz6RS/1ix+LXpYzQ3RC7foPef /Opg== X-Gm-Message-State: AOAM530k1JOuuh9nKuzMy50cLl7czG1bua++MK9UKUS0FQOqDbmo6wCi 0ON13V5yf+JFLF671AhImIMDbwdZFBpRkBv8 X-Google-Smtp-Source: ABdhPJyg5QW5KX7IxNx0LzZJNMkY1Ki6yPOZ0nRKMsGStDuDfKam6HdLQQobakL+HqRqTzFlSPIXgQ== X-Received: by 2002:a1c:4d13:: with SMTP id o19mr346325wmh.58.1607022880932; Thu, 03 Dec 2020 11:14:40 -0800 (PST) Received: from kpsingh.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id q17sm516480wro.36.2020.12.03.11.14.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 11:14:40 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v4 2/4] selftests/bpf: Ensure securityfs mount before writing ima policy Date: Thu, 3 Dec 2020 19:14:35 +0000 Message-Id: <20201203191437.666737-3-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203191437.666737-1-kpsingh@chromium.org> References: <20201203191437.666737-1-kpsingh@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: KP Singh SecurityFS may not be mounted even if it is enabled in the kernel config. So, check if the mount exists in /proc/mounts by parsing the file and, if not, mount it on /sys/kernel/security. Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash") Reported-by: Andrii Nakryiko Acked-by: Andrii Nakryiko Signed-off-by: KP Singh --- tools/testing/selftests/bpf/ima_setup.sh | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh index 137f2d32598f..b1ee4bf06996 100755 --- a/tools/testing/selftests/bpf/ima_setup.sh +++ b/tools/testing/selftests/bpf/ima_setup.sh @@ -14,6 +14,20 @@ usage() exit 1 } +ensure_mount_securityfs() +{ + local securityfs_dir=$(grep "securityfs" /proc/mounts | awk '{print $2}') + + if [ -z "${securityfs_dir}" ]; then + securityfs_dir=/sys/kernel/security + mount -t securityfs security "${securityfs_dir}" + fi + + if [ ! -d "${securityfs_dir}" ]; then + echo "${securityfs_dir}: securityfs is not mounted" && exit 1 + fi +} + setup() { local tmp_dir="$1" @@ -33,6 +47,7 @@ setup() cp "${TEST_BINARY}" "${mount_dir}" local mount_uuid="$(blkid ${loop_device} | sed 's/.*UUID="\([^"]*\)".*/\1/')" + ensure_mount_securityfs echo "measure func=BPRM_CHECK fsuuid=${mount_uuid}" > ${IMA_POLICY_FILE} } From patchwork Thu Dec 3 19:14:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11949439 X-Patchwork-Delegate: bpf@iogearbox.net 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 35E28C4361A for ; Thu, 3 Dec 2020 19:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D5570221ED for ; Thu, 3 Dec 2020 19:15:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728355AbgLCTPY (ORCPT ); Thu, 3 Dec 2020 14:15:24 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgLCTPX (ORCPT ); Thu, 3 Dec 2020 14:15:23 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 59E2BC061A52 for ; Thu, 3 Dec 2020 11:14:43 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id a3so4983767wmb.5 for ; Thu, 03 Dec 2020 11:14:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=ghTVsKbpZtfvZg6e/7iBLzacUWdh3E9D77gh2ZJibOg=; b=BDBaOL8JjCil4947zzS2FpfPmY2/Z6W3FN8b7fFNQqzKjfMCgvrnw0krFdO8wZceEl JA7KbU3VEXOhSIDDvB3GvEdvSTSwelDgKNimGTVheSQstTyPRBDCmUqhanMLo1HA5H0n hDzV6BwEAaCx+cev39/Pyeip5uyjUAA/T3bzk= 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=ghTVsKbpZtfvZg6e/7iBLzacUWdh3E9D77gh2ZJibOg=; b=apgjW1FwbX7ZqODYXVlUGouDkU77Bjkeo3neqdPZApEWQRhfxW3pkaIvxdEM34oA7E Gh2jO47/iI7zkSQ8Pe51+07ZZqs0QuKAQux4NeOX26PmphMU2nyTgXVfD9wm58f/sEaf duGbuhCo1L7rjLpjfdwwaFs7pXZhlrJv6SNQC2nPcZem4eymi9SLPpQkOKWwW6eC7Use g8Q7RWXa5t/9zoYGQXr5SVSBg+MmmgtWQM+yx3bM8IgKwJ8x+TRgCNsoARSvb1f6uJXH U6DNm0UKX4lGSHvSsna45iHGXCBQTAvmL8496UKbl+4J+1qucTwD5Z7vzsQ5etN3qwoF yG3w== X-Gm-Message-State: AOAM531T970j+5gQR2A1CZDSXbeyTxPdvJKpvgKgORLCZFvZKVJp6iDZ ZFbLYi8nk9n/dLWKstXaMB01tyuRcM04M0NY X-Google-Smtp-Source: ABdhPJwN7DbOSyngEKjpLH4FJqcOKZ8BwUMgzQT8Dqczado7MMsshe0Nu33lEQ+bn1k26XZm1Y83Iw== X-Received: by 2002:a1c:bc02:: with SMTP id m2mr308167wmf.59.1607022881894; Thu, 03 Dec 2020 11:14:41 -0800 (PST) Received: from kpsingh.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id q17sm516480wro.36.2020.12.03.11.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 11:14:41 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v4 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP Date: Thu, 3 Dec 2020 19:14:36 +0000 Message-Id: <20201203191437.666737-4-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203191437.666737-1-kpsingh@chromium.org> References: <20201203191437.666737-1-kpsingh@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: KP Singh The ima selftest restricts its scope to a test filesystem image mounted on a loop device and prevents permanent ima policy changes for the whole system. Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash") Reported-by: Andrii Nakryiko Signed-off-by: KP Singh --- tools/testing/selftests/bpf/config | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/testing/selftests/bpf/config b/tools/testing/selftests/bpf/config index 365bf9771b07..37e1f303fc11 100644 --- a/tools/testing/selftests/bpf/config +++ b/tools/testing/selftests/bpf/config @@ -43,3 +43,4 @@ CONFIG_IMA=y CONFIG_SECURITYFS=y CONFIG_IMA_WRITE_POLICY=y CONFIG_IMA_READ_POLICY=y +CONFIG_BLK_DEV_LOOP=y From patchwork Thu Dec 3 19:14:37 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11949441 X-Patchwork-Delegate: bpf@iogearbox.net 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=-20.2 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,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 8E4F1C4361B for ; Thu, 3 Dec 2020 19:15:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E26E221E7 for ; Thu, 3 Dec 2020 19:15:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728381AbgLCTPb (ORCPT ); Thu, 3 Dec 2020 14:15:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56342 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbgLCTPa (ORCPT ); Thu, 3 Dec 2020 14:15:30 -0500 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 56483C061A53 for ; Thu, 3 Dec 2020 11:14:44 -0800 (PST) Received: by mail-wm1-x342.google.com with SMTP id g185so5002208wmf.3 for ; Thu, 03 Dec 2020 11:14:44 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aSXphco9+xOvc4UUX2/2ViapN7bQcE+sIVhx/aA3cgs=; b=apOXbKawCT3vVsxlvdF1L8qxkel2NB7jxnmRpxOziywoG6f6dTGdL8jD2mMFVNAvsA bO7sX5JbFYbM7OgDZjHa/tHjlRNXz5nqlW50fM0saXNWn/s11TKajoiOPeOrTnF9ngyL Td+fmpoafwomJhegrWbUhMLhaflIQU5Izy+mY= 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=aSXphco9+xOvc4UUX2/2ViapN7bQcE+sIVhx/aA3cgs=; b=SA+iDpjh6SDtm0odt6sW5aZ7WyU1rCqc/iyClQd2cFRMPW8lSs1PbXvMUtS0yEYH4r HM8t4R6+PeyfcREe8BRRQUswXmhbtNHaqNM32rO9PCurvskcHDOaYVV6Vziprc6Qo8om nqNr9QCznKJLk1EEb9XS+yvp8O2xtA8Jjiy8dW1zHg7JdlK15Dnq3S+7aRSkE89h7v8u kI80vOizxySPhpjrbjLvYJy2YTK5NBav6bAPYOjwj93+7AW0ZeAvaoMDLo+uPrmnC6Bo 3+VHYTl59DOo0ZAzOHvGcob0cf4GBSyEPAA/sCEUk8iJHmYePxFWW2J/nQwWwrmG5YXr l3DQ== X-Gm-Message-State: AOAM532wVuEuJQRVCgGW0NCvlPZbFkDGFRXEYapzQYeujNHuNn3N2KZH ymgu2fl1JAt5lQF1U43u3DPqXgVW9zL1T8rl X-Google-Smtp-Source: ABdhPJyOYA8NUARcVT/aJ+xKLNVNrnMB/cPJFX/hiavpwVO/PjNJiUu+tJjfUbxE+8vXsrf5tBtAXA== X-Received: by 2002:a7b:c34a:: with SMTP id l10mr295893wmj.125.1607022882785; Thu, 03 Dec 2020 11:14:42 -0800 (PST) Received: from kpsingh.c.googlers.com.com (203.75.199.104.bc.googleusercontent.com. [104.199.75.203]) by smtp.gmail.com with ESMTPSA id q17sm516480wro.36.2020.12.03.11.14.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Dec 2020 11:14:42 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Subject: [PATCH bpf-next v4 4/4] selftests/bpf: Indent ima_setup.sh with tabs. Date: Thu, 3 Dec 2020 19:14:37 +0000 Message-Id: <20201203191437.666737-5-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203191437.666737-1-kpsingh@chromium.org> References: <20201203191437.666737-1-kpsingh@chromium.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: bpf@vger.kernel.org X-Patchwork-Delegate: bpf@iogearbox.net From: KP Singh The file was formatted with spaces instead of tabs and went unnoticed as checkpatch.pl did not complain (probably because this is a shell script). Re-indent it with tabs to be consistent with other scripts. Signed-off-by: KP Singh --- tools/testing/selftests/bpf/ima_setup.sh | 108 +++++++++++------------ 1 file changed, 54 insertions(+), 54 deletions(-) diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh index b1ee4bf06996..2bfc646bc230 100755 --- a/tools/testing/selftests/bpf/ima_setup.sh +++ b/tools/testing/selftests/bpf/ima_setup.sh @@ -10,90 +10,90 @@ TEST_BINARY="/bin/true" usage() { - echo "Usage: $0 " - exit 1 + echo "Usage: $0 " + exit 1 } ensure_mount_securityfs() { - local securityfs_dir=$(grep "securityfs" /proc/mounts | awk '{print $2}') + local securityfs_dir=$(grep "securityfs" /proc/mounts | awk '{print $2}') - if [ -z "${securityfs_dir}" ]; then - securityfs_dir=/sys/kernel/security - mount -t securityfs security "${securityfs_dir}" - fi + if [ -z "${securityfs_dir}" ]; then + securityfs_dir=/sys/kernel/security + mount -t securityfs security "${securityfs_dir}" + fi - if [ ! -d "${securityfs_dir}" ]; then - echo "${securityfs_dir}: securityfs is not mounted" && exit 1 - fi + if [ ! -d "${securityfs_dir}" ]; then + echo "${securityfs_dir}: securityfs is not mounted" && exit 1 + fi } setup() { - local tmp_dir="$1" - local mount_img="${tmp_dir}/test.img" - local mount_dir="${tmp_dir}/mnt" - local copied_bin_path="${mount_dir}/$(basename ${TEST_BINARY})" - mkdir -p ${mount_dir} + local tmp_dir="$1" + local mount_img="${tmp_dir}/test.img" + local mount_dir="${tmp_dir}/mnt" + local copied_bin_path="${mount_dir}/$(basename ${TEST_BINARY})" + mkdir -p ${mount_dir} - dd if=/dev/zero of="${mount_img}" bs=1M count=10 + dd if=/dev/zero of="${mount_img}" bs=1M count=10 - losetup -f "${mount_img}" - local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) + losetup -f "${mount_img}" + local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) - mkfs.ext2 "${loop_device:?}" - mount "${loop_device}" "${mount_dir}" + mkfs.ext2 "${loop_device:?}" + mount "${loop_device}" "${mount_dir}" - cp "${TEST_BINARY}" "${mount_dir}" - local mount_uuid="$(blkid ${loop_device} | sed 's/.*UUID="\([^"]*\)".*/\1/')" + cp "${TEST_BINARY}" "${mount_dir}" + local mount_uuid="$(blkid ${loop_device} | sed 's/.*UUID="\([^"]*\)".*/\1/')" - ensure_mount_securityfs - echo "measure func=BPRM_CHECK fsuuid=${mount_uuid}" > ${IMA_POLICY_FILE} + ensure_mount_securityfs + echo "measure func=BPRM_CHECK fsuuid=${mount_uuid}" > ${IMA_POLICY_FILE} } cleanup() { - local tmp_dir="$1" - local mount_img="${tmp_dir}/test.img" - local mount_dir="${tmp_dir}/mnt" + local tmp_dir="$1" + local mount_img="${tmp_dir}/test.img" + local mount_dir="${tmp_dir}/mnt" - local loop_devices=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) + local loop_devices=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1) - for loop_dev in "${loop_devices}"; do - losetup -d $loop_dev - done + for loop_dev in "${loop_devices}"; do + losetup -d $loop_dev + done - umount ${mount_dir} - rm -rf ${tmp_dir} + umount ${mount_dir} + rm -rf ${tmp_dir} } run() { - local tmp_dir="$1" - local mount_dir="${tmp_dir}/mnt" - local copied_bin_path="${mount_dir}/$(basename ${TEST_BINARY})" + local tmp_dir="$1" + local mount_dir="${tmp_dir}/mnt" + local copied_bin_path="${mount_dir}/$(basename ${TEST_BINARY})" - exec "${copied_bin_path}" + exec "${copied_bin_path}" } main() { - [[ $# -ne 2 ]] && usage - - local action="$1" - local tmp_dir="$2" - - [[ ! -d "${tmp_dir}" ]] && echo "Directory ${tmp_dir} doesn't exist" && exit 1 - - if [[ "${action}" == "setup" ]]; then - setup "${tmp_dir}" - elif [[ "${action}" == "cleanup" ]]; then - cleanup "${tmp_dir}" - elif [[ "${action}" == "run" ]]; then - run "${tmp_dir}" - else - echo "Unknown action: ${action}" - exit 1 - fi + [[ $# -ne 2 ]] && usage + + local action="$1" + local tmp_dir="$2" + + [[ ! -d "${tmp_dir}" ]] && echo "Directory ${tmp_dir} doesn't exist" && exit 1 + + if [[ "${action}" == "setup" ]]; then + setup "${tmp_dir}" + elif [[ "${action}" == "cleanup" ]]; then + cleanup "${tmp_dir}" + elif [[ "${action}" == "run" ]]; then + run "${tmp_dir}" + else + echo "Unknown action: ${action}" + exit 1 + fi } main "$@"