Message ID | 20201201143924.2908241-2-kpsingh@chromium.org (mailing list archive) |
---|---|
State | Changes Requested |
Delegated to: | BPF |
Headers | show |
Series | [bpf-next,1/2] selftests/bpf: Update ima test helper's losetup commands | expand |
Context | Check | Description |
---|---|---|
netdev/cover_letter | success | Link |
netdev/fixes_present | success | Link |
netdev/patch_count | success | Link |
netdev/tree_selection | success | Clearly marked for bpf-next |
netdev/subject_prefix | success | Link |
netdev/source_inline | success | Was 0 now: 0 |
netdev/verify_signedoff | success | Link |
netdev/module_param | success | Was 0 now: 0 |
netdev/build_32bit | success | Errors and warnings before: 0 this patch: 0 |
netdev/kdoc | success | Errors and warnings before: 0 this patch: 0 |
netdev/verify_fixes | success | Link |
netdev/checkpatch | warning | WARNING: line length of 82 exceeds 80 columns |
netdev/build_allmodconfig_warn | success | Errors and warnings before: 0 this patch: 0 |
netdev/header_inline | success | Link |
netdev/stable | success | Stable not CCed |
diff --git a/tools/testing/selftests/bpf/ima_setup.sh b/tools/testing/selftests/bpf/ima_setup.sh index ed29bde26a12..7b8615c30c09 100755 --- a/tools/testing/selftests/bpf/ima_setup.sh +++ b/tools/testing/selftests/bpf/ima_setup.sh @@ -31,8 +31,24 @@ setup() mount "${loop_device}" "${mount_dir}" cp "${TEST_BINARY}" "${mount_dir}" - local mount_uuid="$(blkid -s UUID -o value ${loop_device})" - echo "measure func=BPRM_CHECK fsuuid=${mount_uuid}" > ${IMA_POLICY_FILE} + local mount_uuid="" + # This can be done with blkid -s UUID -o value ${loop_device} but + # blkid might not be available everywhere, especially in busybox + # environments. + for uuid in $(ls /dev/disk/by-uuid); do + local link_target="$(readlink -f /dev/disk/by-uuid/${uuid})" + if [[ "${loop_device}" == "${link_target}" ]]; then + mount_uuid="${uuid}" + break; + fi + done + + if [[ -z "${mount_uuid}" ]]; then + echo "Could not find mount_uuid for ${loop_device}" + exit 1; + fi + + echo "measure func=BPRM_CHECK fsuuid=${mount_uuid:?}" > ${IMA_POLICY_FILE} } cleanup() {