From patchwork Thu Dec 3 00:58:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11947389 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 83857C64E7C for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 23D21221F7 for ; Thu, 3 Dec 2020 00:59:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726931AbgLCA65 (ORCPT ); Wed, 2 Dec 2020 19:58:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55892 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgLCA65 (ORCPT ); Wed, 2 Dec 2020 19:58:57 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A53ABC0617A7 for ; Wed, 2 Dec 2020 16:58:16 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id 3so1506916wmg.4 for ; Wed, 02 Dec 2020 16:58:16 -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=9ZYCT9jq3ErnM4xxNvbt1lypE7V52HO8UFemG7ypah0=; b=dwvKht+ral/LB39DWR/3WAJOMSBv9z3KmQAikuVPHVzHluk/RxExMPgywwvmCBpF9A 7thrJU5Wq+jN9933Qn4pUILZla7zVPKRYp+SYxv9HkN70OghkR1HdWe1uYGFrUIOP1Yd UD8piVLECOC/lKSs509fMexvd2LjT84hMp5So= 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=9ZYCT9jq3ErnM4xxNvbt1lypE7V52HO8UFemG7ypah0=; b=MjWgPpp+FhQZkHukmps4SE7DUmCoF20Qp+sokjgeAewLMEuEi0u6qtuUX3YiC7g91x HPLjnBjFpnodzgS9E1eWQffX6Z3WQewfacLfyuUWkDx/SBn/0N7y03pNXnpWgbUtLJCs +vYynRxxtbLBt2I5o4H2i79kLzm7REHhquvAY9cMvfZR2RnEr/w2KtjnId8pY7NLsvGu u6oVPu8o6vvkRFXPrru9q2RWBqknYKmrYDG4cYI+VZp8gTo3izVpsP044g5VBvrHyJyY S/5Iuh3JujVoEaw0fSi2ggtw6TT4JeJ5RwjcdogoxNerDqoHeEbCdnVhHndg/I9fHL3B dtbg== X-Gm-Message-State: AOAM5323HmPxTAI5sI+B56zteMOiScVrD/bhdD4veUWJ10LD/hiyxYNv oV/Cvq9zWBBLS/GyVu//VhgbECbKsNUySUyL X-Google-Smtp-Source: ABdhPJynkRsmJfZjY/FFgbpB47SwlS3PXEd+Isq2z6AGTd4ihuSTkWhDXFkwMZIQ3YLuy2cBP5SgFw== X-Received: by 2002:a1c:f715:: with SMTP id v21mr555338wmh.2.1606957094980; Wed, 02 Dec 2020 16:58:14 -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 m4sm217960wmi.41.2020.12.02.16.58.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 16:58:14 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v3 1/4] selftests/bpf: Update ima_setup.sh for busybox Date: Thu, 3 Dec 2020 00:58:04 +0000 Message-Id: <20201203005807.486320-2-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203005807.486320-1-kpsingh@chromium.org> References: <20201203005807.486320-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 dosn'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. * 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 00:58:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11947391 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 A6C21C6369E for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 531D3221FB for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727001AbgLCA65 (ORCPT ); Wed, 2 Dec 2020 19:58:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgLCA65 (ORCPT ); Wed, 2 Dec 2020 19:58:57 -0500 Received: from mail-wm1-x344.google.com (mail-wm1-x344.google.com [IPv6:2a00:1450:4864:20::344]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C4B6C061A04 for ; Wed, 2 Dec 2020 16:58:17 -0800 (PST) Received: by mail-wm1-x344.google.com with SMTP id a6so1063108wmc.2 for ; Wed, 02 Dec 2020 16:58:17 -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=wvYLzb/2awFSWopGgD9GTzNT2RYp2qPIFj0IFXraBdY=; b=E25QxQmDCkpJmSC1os7qKy1fMHCuQFApYmSE91srYNav6CBs+/YGCklvH3kCihVzHO jD12Wu4+Y7rOaPe32CaO4lub4xpDOWOxr5XiA6jvoWdgSFf26lH0Ez4XQh+7ELrPErom RlV+reWXgFJloZBGG3q2VCCrr+y+FhAJEBxuw= 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=wvYLzb/2awFSWopGgD9GTzNT2RYp2qPIFj0IFXraBdY=; b=UErwVve5lxO0/p+dJl0EGuX9bP2zvBDPKmY2MEzk9pHmFjc/+4FojbWfg0UHDvyGcT 11oNo9kngAFUDQWz0TY7Ye8X5HtvQxVE2s9gQDGTO7r18xBRp+hSZKAME8GGXYRDFy66 pNcLnQYdq2uDzTTTtXXEyHFHXVtC7ED61DHdWhBJeGJIg/7u8WAdkF7L2TdHVRTG51cN F1p3ATwffeg7+M4i5dW5V9VPwbWIzv6zW7AZgpzA0W0XpeuMPg4Vk6A6qxVOYJphOn9X Brn1FYZjk1ofvxHHn+SHUQ8B7bG701LlYpzb0Rq02S2DafXlFtAkW1EgRMkdYwwSxOor XMzA== X-Gm-Message-State: AOAM5338fh0dzFZCTx3Y1p9P+wheWVS845R+Ru8D1GU8mf5vcIEXsqHW fQOWig3Ai+8k71eXCufKBmzVrVi6L9+zYzX5 X-Google-Smtp-Source: ABdhPJyjXOSKoVz9HnG6lc2ZaPfk5ZWA2KK74qjKe0l1kWR9uDvIX3VngBVlZucFr2sqDuOnfBzjOg== X-Received: by 2002:a1c:9d8b:: with SMTP id g133mr494874wme.189.1606957095672; Wed, 02 Dec 2020 16:58:15 -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 m4sm217960wmi.41.2020.12.02.16.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 16:58:15 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v3 2/4] selftests/bpf: Ensure securityfs mount before writing ima policy Date: Thu, 3 Dec 2020 00:58:05 +0000 Message-Id: <20201203005807.486320-3-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203005807.486320-1-kpsingh@chromium.org> References: <20201203005807.486320-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. 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 | 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 00:58:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11947395 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 D4EB0C64E8A for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E28D22201 for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727127AbgLCA66 (ORCPT ); Wed, 2 Dec 2020 19:58:58 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgLCA66 (ORCPT ); Wed, 2 Dec 2020 19:58:58 -0500 Received: from mail-wr1-x443.google.com (mail-wr1-x443.google.com [IPv6:2a00:1450:4864:20::443]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C71DDC061A47 for ; Wed, 2 Dec 2020 16:58:17 -0800 (PST) Received: by mail-wr1-x443.google.com with SMTP id k14so167623wrn.1 for ; Wed, 02 Dec 2020 16:58:17 -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=UCcew2G12nQ35xouD2ydDuKmEOgtKkMgTK/ZJX/WvlGCFxzhchd0kPyuc2JYFxFdSx 3jf8Hy8wk3A75n3SUyp5tIxBmKgF5UZoAMKk32if1Uq6BfXdrIylu1rNHlS9eBi90i6/ XpcmHdTf3KZidnZCWd3YSiyXBMg8WBE85dgb0= 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=hURIMiManSE9CtaL6xSE52Jb0R3HQXUfjItGg6fXb9QBZ086y2z89Z0Mf/HuqRJK73 DkzQlI6B4RCDAAIvPN2OF8zIXPmEwFFjlkc6OFY8F8KB72pAY12dHB9/dSIyjh6+BLMe y3RQXqQgpWnZ+bWZNc0gI5ZfibMV2yG9tamiTbM83yFLPKGKnot+ZkOGzzhtM91/e38+ mMCyorWQDLp+hos1RBsA5FN+KmMsxcL+QC3yCj4TbOUtJRIhE6z79FG0m1LXOt1cNAQl ilbiQWL3CJ7Sp+5upIWqKrxZxycOj/YzllpvlryrCzN3T4DQdtYHatlgumamZcZqtXyr rjqw== X-Gm-Message-State: AOAM5333B9KZ5hz9DQJjftpCTrzt+Mj0/g+hHVUI9qwdki0/RZ82jKE3 6p+lPOCwmdJM1qWNlxO9FK3EL2314+DrkE5Y X-Google-Smtp-Source: ABdhPJy7tnVcrXSmK1e55LDlngGOTYYTYOL5TpVdJJyxCB9JfHxMPeW5K/IxkbTwLE/iicOj7JLEZw== X-Received: by 2002:adf:f347:: with SMTP id e7mr737105wrp.183.1606957096320; Wed, 02 Dec 2020 16:58:16 -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 m4sm217960wmi.41.2020.12.02.16.58.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 16:58:15 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Andrii Nakryiko , Alexei Starovoitov , Daniel Borkmann Subject: [PATCH bpf-next v3 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP Date: Thu, 3 Dec 2020 00:58:06 +0000 Message-Id: <20201203005807.486320-4-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203005807.486320-1-kpsingh@chromium.org> References: <20201203005807.486320-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 00:58:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: KP Singh X-Patchwork-Id: 11947397 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 144F0C71155 for ; Thu, 3 Dec 2020 00:59:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE92222206 for ; Thu, 3 Dec 2020 00:59:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729050AbgLCA7B (ORCPT ); Wed, 2 Dec 2020 19:59:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726851AbgLCA7B (ORCPT ); Wed, 2 Dec 2020 19:59:01 -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 97235C061A48 for ; Wed, 2 Dec 2020 16:58:18 -0800 (PST) Received: by mail-wm1-x343.google.com with SMTP id f190so1573436wme.1 for ; Wed, 02 Dec 2020 16:58:18 -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=sAj4CijO6YaK2Nh/ag2HPX9Fm7SDZZ1Y+XvbprTUDuk=; b=T6HgMPXL8eoNA8sMJQmWAkZmNXT4qzO3/C9lWx10pqKj41FX4yO6eTdd7ffoBfh32e p4yoOHb2rqo4ZObNzJcd+NCkODKmOikHEZdEOA9Qt/0KELj6ezQbljLhwmQ4yoCL5cIY 2kFsuVP1xxVBXkhBTD44lAGLpkDHmjBeG4ndc= 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=sAj4CijO6YaK2Nh/ag2HPX9Fm7SDZZ1Y+XvbprTUDuk=; b=Nzh3pt+XN04NCBdHBTbSR6WDdYHOF9rtyFeauZ91OzE6caE8+5UhuElAVB3yV7dl4S MuTJj5LpXiVGGXnwi4RiyUFGRSBtsQRO7qIY65HsPoF5I9/7xjltMYD5FBJMPywbewBX Dwd3C0fbMhrNg5OiRtrZ9yJq/YqrYQO/PVbjxr2IuRD3CA4dj1d7xA606BpZAQROgt5e Lj2ZjqFi8/IoF8uVnu/YPoSPXlUlL0ROsWuyKNxo6l6XoHhtwYSwCPdCSH48/ZlPltga 5AdSjjQ1OG+1twE3iXFV5stAYtqUdvBXu1bGgIVvmn4ZN6Bb+8gnZHau4QAmP2bxdc4V x2qA== X-Gm-Message-State: AOAM531PHUVi0rsuz2F8rxPgKjmnQpz29vemJbH6+lM0yLH5HW0utl2a ona2UmeZpZoK21pcsp+j5OsIklRCb2PPyH4z X-Google-Smtp-Source: ABdhPJzE/b7YBJH4ZyiiJ4IndE0U8AJjCDEU18S/JA3AhmnsS1nbtYPZncydsHcLGLVGZIQIkkwn/g== X-Received: by 2002:a05:600c:410d:: with SMTP id j13mr504329wmi.95.1606957097138; Wed, 02 Dec 2020 16:58:17 -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 m4sm217960wmi.41.2020.12.02.16.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 02 Dec 2020 16:58:16 -0800 (PST) From: KP Singh To: bpf@vger.kernel.org Cc: Alexei Starovoitov , Daniel Borkmann , Andrii Nakryiko Subject: [PATCH bpf-next v3 4/4] selftests/bpf: Indent ima_setup.sh with tabs. Date: Thu, 3 Dec 2020 00:58:07 +0000 Message-Id: <20201203005807.486320-5-kpsingh@chromium.org> X-Mailer: git-send-email 2.29.2.576.ga3fc446d84-goog In-Reply-To: <20201203005807.486320-1-kpsingh@chromium.org> References: <20201203005807.486320-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 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 "$@"