Re: [PATCH bpf-next 1/2] selftests/bpf: Update ima test helper's losetup commands

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Dec 1, 2020 at 6:39 AM KP Singh <kpsingh@xxxxxxxxxxxx> wrote:
>
> From: KP Singh <kpsingh@xxxxxxxxxx>
>
> Update the commands to use the bare minimum options so that it works
> in busybox environments.
>
> Fixes: 34b82d3ac105 ("bpf: Add a selftest for bpf_ima_inode_hash")
> Reported-by: Andrii Nakryiko <andrii@xxxxxxxxxx>
> Signed-off-by: KP Singh <kpsingh@xxxxxxxxxx>
> ---
>  tools/testing/selftests/bpf/ima_setup.sh | 9 ++++++---
>  1 file changed, 6 insertions(+), 3 deletions(-)
>
> diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh
> index 15490ccc5e55..ed29bde26a12 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,9 +24,10 @@ setup()
>
>          dd if=/dev/zero of="${mount_img}" bs=1M count=10

This, and few more commands in this script, produce a bunch of output
directly to stdout and stderr. Can you please silence it? If you need
that output for debugging, than you can check verbosity mode in
test_progs and pass extra parameters, if necessary.


>
> -        local loop_device="$(losetup --find --show ${mount_img})"
> +        losetup -f "${mount_img}"

This doesn't work :(

[root@(none) selftests]# ./ima_setup.sh setup /tmp/ima_measurednsymal
+ set -e
+ set -u
+ set -o pipefail
+ IMA_POLICY_FILE=/sys/kernel/security/ima/policy
+ TEST_BINARY=/bin/true
+ main setup /tmp/ima_measurednsymal
+ [[ 2 -ne 2 ]]
+ local action=setup
+ local tmp_dir=/tmp/ima_measurednsymal
+ [[ ! -d /tmp/ima_measurednsymal ]]
+ [[ setup == \s\e\t\u\p ]]
+ setup /tmp/ima_measurednsymal
+ local tmp_dir=/tmp/ima_measurednsymal
+ local mount_img=/tmp/ima_measurednsymal/test.img
+ local mount_dir=/tmp/ima_measurednsymal/mnt
++ basename /bin/true
+ local copied_bin_path=/tmp/ima_measurednsymal/mnt/true
+ mkdir -p /tmp/ima_measurednsymal/mnt
+ dd if=/dev/zero of=/tmp/ima_measurednsymal/test.img bs=1M count=10
10+0 records in
10+0 records out
10485760 bytes (10.0MB) copied, 0.044713 seconds, 223.6MB/s
+ losetup -f /tmp/ima_measurednsymal/test.img
losetup: /tmp/ima_measurednsymal/test.img: No such file or directory
[root@(none) selftests]# ls -la /tmp/ima_measurednsymal/test.img
-rw-r--r--    1 root     root      10485760 Dec  1 19:13
/tmp/ima_measurednsymal/test.img
[root@(none) selftests]# losetup -f /tmp/ima_measurednsymal/test.img
losetup: /tmp/ima_measurednsymal/test.img: No such file or directory


I have zero context on what IMA is and know nothing about loop
devices, so can't really investigate much, sorry...

> +        local loop_device=$(losetup -a | grep ${mount_img:?} | cut -d ":" -f1)
>
> -        mkfs.ext4 "${loop_device}"
> +        mkfs.ext4 "${loop_device:?}"
>          mount "${loop_device}" "${mount_dir}"
>
>          cp "${TEST_BINARY}" "${mount_dir}"
> @@ -38,7 +40,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
> --
> 2.29.2.454.gaff20da3a2-goog
>



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux