Skip to contentSkip to conversation

Fixes for ima selftest

PATCH Superseded KP Singh 3 participants 19 messages Dec 3, 2020

Subsystems (3)

v3 of 4 Superseded Latest is v4 →

lore
Share & tools
lore

KP Singh

author
#0 lore raw

v3 cover Fixes for ima selftest

From: KP Singh <[email protected]>

# v2 -> v3

* Added missing tags.
* Indentation fixes + some other fixes suggested by Andrii.
* Re-indent file to tabs.

# What?

* Fixes to work in busybox shell (tested on the one used by BPF CI).
* Ensure that securityfs is mounted before updating the ima policy
* Add missing config deps.

KP Singh (4):
selftests/bpf: Update ima_setup.sh for busybox selftests/bpf: Ensure securityfs mount before writing ima policy selftests/bpf: Add config dependency on BLK_DEV_LOOP selftests/bpf: Indent ima_setup.sh with tabs.

 tools/testing/selftests/bpf/config       |   1 +
 tools/testing/selftests/bpf/ima_setup.sh | 107 +++++++++++++----------
 2 files changed, 64 insertions(+), 44 deletions(-)
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
author
#1 lore raw

PATCH v3 1/4 selftests/bpf: Update ima_setup.sh for busybox

From: KP Singh <[email protected]>

* 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")
---
 tools/testing/selftests/bpf/ima_setup.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
tools/testing/selftests/bpf/ima_setup.sh +8 -4
index 15490ccc5e55..137f2d32598f 100755
@@ -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
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
Acked-by on v3 1/4
#2 lore raw

Re: [PATCH bpf-next v3 1/4] selftests/bpf: Update ima_setup.sh for busybox

Quoted 5 lines · KP Singh

From: KP Singh <[email protected]>

* 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

typo: doesn't

Quoted 3 lines

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 it from full blkid output.

Quoted 3 lines

* 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.

This one is great. It explains the problem, and what solution was implemented, from the high-level. I'd just drop the " *" marks, it makes it more pleasant to read as if it was written for humans, not machines.

Quoted 7 lines
Fixes 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
---
 tools/testing/selftests/bpf/ima_setup.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 6 lines
tools/testing/selftests/bpf/ima_setup.sh +0 -0
index 15490ccc5e55..137f2d32598f 100755
@@ -3,6 +3,7 @@
 

[...]

author
#3 lore raw

Re: [PATCH bpf-next v3 1/4] selftests/bpf: Update ima_setup.sh for busybox

Quoted 9 lines · Andrii Nakryiko
Quoted 5 lines · KP Singh

From: KP Singh <[email protected]>

* 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

typo: doesn't

Fixed.

Quoted 6 lines
Quoted 4 lines

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 it from full blkid output.

Done.

Quoted 9 lines
Quoted 4 lines

* 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.

This one is great. It explains the problem, and what solution was implemented, from the high-level. I'd just drop the " *" marks, it makes it more pleasant to read as if it was written for humans, not machines.

I tend to use "* " for bullet points from the markdown syntax (as we use it heavily internally) I can avoid if you prefer / don't like it.

Quoted 19 lines
Quoted 8 lines
Fixes 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
---
 tools/testing/selftests/bpf/ima_setup.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 6 lines
tools/testing/selftests/bpf/ima_setup.sh +0 -0
index 15490ccc5e55..137f2d32598f 100755
@@ -3,6 +3,7 @@
 

[...]

#4 lore raw

Re: [PATCH bpf-next v3 1/4] selftests/bpf: Update ima_setup.sh for busybox

Quoted 29 lines · KP Singh
Quoted 9 lines · Andrii Nakryiko
Quoted 5 lines · KP Singh

From: KP Singh <[email protected]>

* 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

typo: doesn't

Fixed.

Quoted 6 lines
Quoted 4 lines

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 it from full blkid output.

Done.

Quoted 5 lines
Quoted 4 lines

* 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.

Quoted 7 lines
Quoted 4 lines

This one is great. It explains the problem, and what solution was implemented, from the high-level. I'd just drop the " *" marks, it makes it more pleasant to read as if it was written for humans, not machines.

I tend to use "* " for bullet points from the markdown syntax (as we use it heavily internally) I can avoid if you prefer / don't like it.

A list of bullet points don't read as a coherent text. It's not the end of the world, but it's also not a common style here either.

Quoted 21 lines
Quoted 21 lines
Quoted 10 lines
Fixes 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
---
 tools/testing/selftests/bpf/ima_setup.sh | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
Quoted 6 lines
tools/testing/selftests/bpf/ima_setup.sh +0 -0
index 15490ccc5e55..137f2d32598f 100755
@@ -3,6 +3,7 @@
 

[...]

author
#5 lore raw

PATCH v3 2/4 selftests/bpf: Ensure securityfs mount before writing ima policy

In reply to KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/ima_setup.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/selftests/bpf/ima_setup.sh +15 -0
index 137f2d32598f..b1ee4bf06996 100755
@@ -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}
 }
 
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
Acked-by on v3 2/4
#6 lore raw

Re: [PATCH bpf-next v3 2/4] selftests/bpf: Ensure securityfs mount before writing ima policy

Quoted 10 lines · KP Singh

From: KP Singh <[email protected]>

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")

---

Quoted 39 lines
 tools/testing/selftests/bpf/ima_setup.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
tools/testing/selftests/bpf/ima_setup.sh +15 -1
index 137f2d32598f..b1ee4bf06996 100755
@@ -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}
 }
 
--

2.29.2.576.ga3fc446d84-goog

author
#7 lore raw

PATCH v3 3/4 selftests/bpf: Add config dependency on BLK_DEV_LOOP

In reply to KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/config | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/config +1 -0
index 365bf9771b07..37e1f303fc11 100644
@@ -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
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
#8 lore raw

Re: [PATCH bpf-next v3 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP

Quoted 19 lines · KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/config | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/bpf/config +0 -0
index 365bf9771b07..37e1f303fc11 100644

tools/testing/selftests/bpf/config CONFIG_IMA=y

Quoted 5 lines
tools/testing/selftests/bpf/config +1 -1
@@ -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
--

You mentioned also that CONFIG_LSM="selinux,bpf,integrity" is needed, no? Let's add that as well?

Quoted 2 lines

2.29.2.576.ga3fc446d84-goog

author
#9 lore raw

Re: [PATCH bpf-next v3 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP

Quoted 16 lines · Andrii Nakryiko
Quoted 14 lines · KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/config | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

tools/testing/selftests/bpf/config CONFIG_IMA=y

Quoted 10 lines
tools/testing/selftests/bpf/config +1 -1
index 365bf9771b07..37e1f303fc11 100644
@@ -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
--

You mentioned also that CONFIG_LSM="selinux,bpf,integrity" is needed, no? Let's add that as well?

I did not add it because we did not do it when we added "bpf" to the list and

I also don't think selinux is really required here which might be worse in some cases (e.g. when the required config options for
SELinux are not selected).

Also, when one selects CONFIG_BPF_LSM or CONFIG_IMA from make menuconfig / nconfig, we get "bpf" and "integrity" appended by default:

We can add a comment that says that says:

"Please ensure "bpf" and "integrity" are present in CONFIG_LSM"

Now, I was not sure if adding a comment would break any scripts that people have that parse this file, so I avoided it. But overriding the string completely
might not be a good idea.

Quoted 3 lines
Quoted 3 lines

2.29.2.576.ga3fc446d84-goog

author
#10 lore raw

Re: [PATCH bpf-next v3 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP

Quoted 43 lines · KP Singh
Quoted 16 lines · Andrii Nakryiko
Quoted 14 lines · KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/config | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

tools/testing/selftests/bpf/config CONFIG_IMA=y

Quoted 10 lines
tools/testing/selftests/bpf/config +1 -1
index 365bf9771b07..37e1f303fc11 100644
@@ -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
--

You mentioned also that CONFIG_LSM="selinux,bpf,integrity" is needed, no? Let's add that as well?

I did not add it because we did not do it when we added "bpf" to the list and

I also don't think selinux is really required here which might be worse in some cases (e.g. when the required config options for
SELinux are not selected).

Also, when one selects CONFIG_BPF_LSM or CONFIG_IMA from make menuconfig / nconfig, we get "bpf" and "integrity" appended by default:

Quoted 8 lines

We can add a comment that says that says:

"Please ensure "bpf" and "integrity" are present in CONFIG_LSM"

Now, I was not sure if adding a comment would break any scripts that people have that parse this file, so I avoided it. But overriding the string completely
might not be a good idea.

If it's okay, I can send the v4 out now and we can add the comment or CONFIG_LSM in a separate patch?

#11 lore raw

Re: [PATCH bpf-next v3 3/4] selftests/bpf: Add config dependency on BLK_DEV_LOOP

Quoted 42 lines · KP Singh
Quoted 40 lines · KP Singh
Quoted 16 lines · Andrii Nakryiko
Quoted 14 lines · KP Singh

From: KP Singh <[email protected]>

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")
---
 tools/testing/selftests/bpf/config | 1 +
 1 file changed, 1 insertion(+)
Quoted 14 lines

tools/testing/selftests/bpf/config CONFIG_IMA=y

Quoted 10 lines
tools/testing/selftests/bpf/config +1 -1
index 365bf9771b07..37e1f303fc11 100644
@@ -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
--

You mentioned also that CONFIG_LSM="selinux,bpf,integrity" is needed, no? Let's add that as well?

I did not add it because we did not do it when we added "bpf" to the list and

I also don't think selinux is really required here which might be worse in some cases (e.g. when the required config options for
SELinux are not selected).

Quoted 8 lines
Quoted 8 lines

Also, when one selects CONFIG_BPF_LSM or CONFIG_IMA from make menuconfig / nconfig, we get "bpf" and "integrity" appended by default:

We can add a comment that says that says:

"Please ensure "bpf" and "integrity" are present in CONFIG_LSM"

Now, I was not sure if adding a comment would break any scripts that people

Any infra I'm in charge of is not using this config in an automated fashion, so adding

# CONFIG_LSM="bpf,integrity"

would work just fine. But I can't know if anyone else relies on this. But # comments are part of Kconfig "spec", so probably is ok to add.

Quoted 6 lines
Quoted 3 lines

have that parse this file, so I avoided it. But overriding the string completely
might not be a good idea.

If it's okay, I can send the v4 out now and we can add the comment or CONFIG_LSM in a separate patch?

Sure.

author
#12 lore raw

PATCH v3 4/4 selftests/bpf: Indent ima_setup.sh with tabs.

In reply to KP Singh

From: KP Singh <[email protected]>

---
 tools/testing/selftests/bpf/ima_setup.sh | 108 +++++++++++------------
 1 file changed, 54 insertions(+), 54 deletions(-)
tools/testing/selftests/bpf/ima_setup.sh +54 -54
index b1ee4bf06996..2bfc646bc230 100755
@@ -10,90 +10,90 @@ TEST_BINARY="/bin/true"
 
 usage()
 {
-        echo "Usage: $0 <setup|cleanup|run> <existing_tmp_dir>"
-        exit 1
+	echo "Usage: $0 <setup|cleanup|run> <existing_tmp_dir>"
+	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 "$@"
Signature · 1 line
2.29.2.576.ga3fc446d84-goog
#13 lore raw

Re: [PATCH bpf-next v3 4/4] selftests/bpf: Indent ima_setup.sh with tabs.

Quoted 3 lines · KP Singh

From: KP Singh <[email protected]>

Commit message is missing completely.

Quoted 5 lines
---
 tools/testing/selftests/bpf/ima_setup.sh | 108 +++++++++++------------
 1 file changed, 54 insertions(+), 54 deletions(-)

[...]

author
#14 lore raw

Re: [PATCH bpf-next v3 4/4] selftests/bpf: Indent ima_setup.sh with tabs.

Quoted 7 lines · Andrii Nakryiko
Quoted 3 lines · KP Singh

From: KP Singh <[email protected]>

Commit message is missing completely.

I thought the subject is enough in this case to explain that we are re-indenting the file.

I can explain that this was missed because checkpatch.pl did not complain about shell
scripts and that we would like to be consistent with the other shells scripts.

Quoted 8 lines
Quoted 6 lines
---
 tools/testing/selftests/bpf/ima_setup.sh | 108 +++++++++++------------
 1 file changed, 54 insertions(+), 54 deletions(-)

[...]

#15 lore raw

Re: [PATCH bpf-next v3 4/4] selftests/bpf: Indent ima_setup.sh with tabs.

Quoted 6 lines · KP Singh
Quoted 3 lines · Andrii Nakryiko
Quoted 1 line · KP Singh
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

From: KP Singh <[email protected]>

Commit message is missing completely.

I thought the subject is enough in this case to explain that we are re-indenting the file.

If there is nothing to add just copy paste the subject into commit log.

Quoted 3 lines

I can explain that this was missed because checkpatch.pl did not complain about shell
scripts and that we would like to be consistent with the other shells scripts.

checkpatch is a guidance. It's not a must have requirement. It works both ways. Sometimes we ignore checkpatch complaints. Sometimes we ask for things that checkpatch doesn't know about.

Please respin at your earliest convenience. CI is suffering at the moment. It needs to be unbroken soon.

author
#16 lore raw

Re: [PATCH bpf-next v3 4/4] selftests/bpf: Indent ima_setup.sh with tabs.

Quoted 18 lines · Alexei Starovoitov
Quoted 6 lines · KP Singh
Quoted 3 lines · Andrii Nakryiko
Quoted 1 line · KP Singh
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines

From: KP Singh <[email protected]>

Commit message is missing completely.

I thought the subject is enough in this case to explain that we are re-indenting the file.

If there is nothing to add just copy paste the subject into commit log.

Quoted 7 lines
Quoted 3 lines

I can explain that this was missed because checkpatch.pl did not complain about shell
scripts and that we would like to be consistent with the other shells scripts.

checkpatch is a guidance. It's not a must have requirement. It works both ways. Sometimes we ignore checkpatch complaints. Sometimes we ask for things that checkpatch doesn't know about.

Agreed, I, personally, just missed it because my editor did a weird thing and I was relying too much on checkpatch.

Quoted 3 lines

Please respin at your earliest convenience. CI is suffering at the moment. It needs to be unbroken soon.

Done. I was aware of the CI being broken :) thus this shabby work on the cover letter and commit message (not really an excuse though).

Also, as mentioned previously, we will script and allow users to run the tests in a CI equivalent environment so that it spares us of this pain. That's next on my TODO list.

- KP

#17 lore raw
In reply to KP Singh
Quoted 9 lines · KP Singh

From: KP Singh <[email protected]>

# v2 -> v3

* Added missing tags.
* Indentation fixes + some other fixes suggested by Andrii.
* Re-indent file to tabs.

Quoted 6 lines

# What?

* Fixes to work in busybox shell (tested on the one used by BPF CI).
* Ensure that securityfs is mounted before updating the ima policy
* Add missing config deps.

KP, please take a look at other cover letters to get a better idea of how they usually look like. It has to be a human-readable overview of why the patch set was posted and what problem it is solving. List of action items without any context is not the best format.

Quoted 14 lines

KP Singh (4):
selftests/bpf: Update ima_setup.sh for busybox selftests/bpf: Ensure securityfs mount before writing ima policy selftests/bpf: Add config dependency on BLK_DEV_LOOP selftests/bpf: Indent ima_setup.sh with tabs.

 tools/testing/selftests/bpf/config       |   1 +
 tools/testing/selftests/bpf/ima_setup.sh | 107 +++++++++++++----------
 2 files changed, 64 insertions(+), 44 deletions(-)

--
2.29.2.576.ga3fc446d84-goog

author
#18 lore raw
Quoted 18 lines · Andrii Nakryiko
Quoted 9 lines · KP Singh

From: KP Singh <[email protected]>

# v2 -> v3

* Added missing tags.
* Indentation fixes + some other fixes suggested by Andrii.
* Re-indent file to tabs.

Quoted 6 lines

# What?

* Fixes to work in busybox shell (tested on the one used by BPF CI).
* Ensure that securityfs is mounted before updating the ima policy
* Add missing config deps.

Quoted 4 lines

KP, please take a look at other cover letters to get a better idea of how they usually look like. It has to be a human-readable overview of why the patch set was posted and what problem it is solving. List of action items without any context is not the best format.

Sure, I thought the individual commit messages were sufficient context but I can add a better one here.

Quoted 15 lines
Quoted 15 lines

KP Singh (4):
selftests/bpf: Update ima_setup.sh for busybox selftests/bpf: Ensure securityfs mount before writing ima policy selftests/bpf: Add config dependency on BLK_DEV_LOOP selftests/bpf: Indent ima_setup.sh with tabs.

 tools/testing/selftests/bpf/config       |   1 +
 tools/testing/selftests/bpf/ima_setup.sh | 107 +++++++++++++----------
 2 files changed, 64 insertions(+), 44 deletions(-)

--
2.29.2.576.ga3fc446d84-goog