summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNaveen Saini <naveen.kumar.saini@intel.com>2020-10-02 10:53:50 +0800
committerArmin Kuster <akuster808@gmail.com>2020-10-16 07:19:30 -0700
commit4aab56bbca7162d9152436fd793dc1ed1d5bd798 (patch)
treea90911e5738e2a0fb72b128bca34ee5c0bb3f424
parentaa5a6f7d12aef90db0de84be05b2be76ecf88f90 (diff)
downloadmeta-security-4aab56bbca7162d9152436fd793dc1ed1d5bd798.tar.gz
initramfs-framework/dmverity: add retry loop for slow boot devices
Detection of USB devices by the kernel is slow enough. We need to keep trying for a while (default: 5s seconds, controlled by roottimeout=<seconds>) and sleep between each attempt (default: one second, rootdelay=<seconds>). Fix is based on https://git.yoctoproject.org/cgit.cgi/poky/commit/meta/recipes-core/initrdscripts/initramfs-framework/rootfs?id=ee6a6c3461694ce09789bf4d852cea2e22fc95e4 Signed-off-by: Naveen Saini <naveen.kumar.saini@intel.com> Signed-off-by: Armin Kuster <akuster808@gmail.com> (cherry picked from commit e23767fc72040cc58e638b08925ab467221c91f9)
-rw-r--r--recipes-core/initrdscripts/initramfs-framework/dmverity64
1 files changed, 37 insertions, 27 deletions
diff --git a/recipes-core/initrdscripts/initramfs-framework/dmverity b/recipes-core/initrdscripts/initramfs-framework/dmverity
index bb07aab..888052c 100644
--- a/recipes-core/initrdscripts/initramfs-framework/dmverity
+++ b/recipes-core/initrdscripts/initramfs-framework/dmverity
@@ -10,33 +10,43 @@ dmverity_run() {
10 10
11 . /usr/share/misc/dm-verity.env 11 . /usr/share/misc/dm-verity.env
12 12
13 case "${bootparam_root}" in 13 C=0
14 ID=*) 14 delay=${bootparam_rootdelay:-1}
15 RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})" 15 timeout=${bootparam_roottimeout:-5}
16 ;; 16 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
17 LABEL=*) 17 while [ ! -b "${RDEV}" ]; do
18 RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})" 18 if [ $(( $C * $delay )) -gt $timeout ]; then
19 ;; 19 fatal "Root device resolution failed"
20 PARTLABEL=*) 20 exit 1
21 RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})" 21 fi
22 ;; 22
23 PARTUUID=*) 23 case "${bootparam_root}" in
24 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})" 24 ID=*)
25 ;; 25 RDEV="$(realpath /dev/disk/by-id/${bootparam_root#ID=})"
26 PATH=*) 26 ;;
27 RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})" 27 LABEL=*)
28 ;; 28 RDEV="$(realpath /dev/disk/by-label/${bootparam_root#LABEL=})"
29 UUID=*) 29 ;;
30 RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})" 30 PARTLABEL=*)
31 ;; 31 RDEV="$(realpath /dev/disk/by-partlabel/${bootparam_root#PARTLABEL=})"
32 *) 32 ;;
33 RDEV="${bootparam_root}" 33 PARTUUID=*)
34 esac 34 RDEV="$(realpath /dev/disk/by-partuuid/${bootparam_root#PARTUUID=})"
35 35 ;;
36 if ! [ -b "${RDEV}" ]; then 36 PATH=*)
37 echo "Root device resolution failed" 37 RDEV="$(realpath /dev/disk/by-path/${bootparam_root#PATH=})"
38 exit 1 38 ;;
39 fi 39 UUID=*)
40 RDEV="$(realpath /dev/disk/by-uuid/${bootparam_root#UUID=})"
41 ;;
42 *)
43 RDEV="${bootparam_root}"
44 esac
45 debug "Sleeping for $delay second(s) to wait root to settle..."
46 sleep $delay
47 C=$(( $C + 1 ))
48
49 done
40 50
41 veritysetup \ 51 veritysetup \
42 --data-block-size=1024 \ 52 --data-block-size=1024 \