diff -Nru initramfs-tools-0.130ubuntu3.10/debian/changelog initramfs-tools-0.130ubuntu3.11/debian/changelog --- initramfs-tools-0.130ubuntu3.10/debian/changelog 2020-09-02 14:53:41.000000000 +0000 +++ initramfs-tools-0.130ubuntu3.11/debian/changelog 2020-08-12 20:12:11.000000000 +0000 @@ -1,3 +1,40 @@ +initramfs-tools (0.130ubuntu3.11) bionic; urgency=medium + + [ Guilherme G. Piccoli ] + * scripts/functions: Prevent printf error carry over if the wrong + console is set. (LP: #1879987) + The function _log_msg() is "void" typed, returning whatever its + last command returns. This function is the basic building block + for all error/warning messages in initramfs-tools. If a bad console + is provided to kernel on command-line, printf returns error, and so + this error is carried over in _log_msg(). Happens that checkfs() + function has a loop that runs forever in this scenario (*if* fsck + is not present in initramfs and "quiet" is not passed in the + command-line). If that happens, boot is stuck and cannot progress. + The simple fix hereby merged is to return zero on _log_msg(). + + * scripts/local: Re-execute cryptroot local-block script. (LP: #1879980) + Currently, if an encrypted rootfs is configured on top of a MD RAID1 + array and such array gets degraded (like a member is removed/failed), + initramfs-tools cannot mount the rootfs and the boot fails. We fix + that issue here by allowing cryptroot script to re-run on local-block + stage, given that mdadm is able to activate a degraded array in that + point. There is a cryptsetup counter-part for this fix, but alone the + initramfs-tools portion is innocuous. + + [ Jay Vosburgh ] + * scripts/functions: Change netplan render for net_failover master + devices. (LP: #1820929) + Modify the _render_netplan function to check for network interfaces + that are net_failover master devices. When found, such devices are + matched only by name, not by MAC address, as the MAC is not a unique + identifier for the net_failover case. In the net_failover architecture, + the MAC address is used to manage the membership of the net_failover + interface set, thus multiple interfaces will be assigned the same MAC + address. + + -- Guilherme G. Piccoli Wed, 12 Aug 2020 17:12:11 -0300 + initramfs-tools (0.130ubuntu3.10) bionic; urgency=medium * Cherrypick upstream commit to copy libgcc_s, as a dependency of diff -Nru initramfs-tools-0.130ubuntu3.10/scripts/functions initramfs-tools-0.130ubuntu3.11/scripts/functions --- initramfs-tools-0.130ubuntu3.10/scripts/functions 2020-09-02 14:40:52.000000000 +0000 +++ initramfs-tools-0.130ubuntu3.11/scripts/functions 2020-08-12 20:12:11.000000000 +0000 @@ -4,6 +4,7 @@ { if [ "$quiet" = "y" ]; then return; fi printf "$@" + return 0 # Prevents error carry over in case of unavailable console } log_success_msg() @@ -509,19 +510,64 @@ fi } +# If the following are all true, this device is a net_failover master: +# 1 /sys/class/net/[ifname]/device links to a virtio device; note that +# the master's actual device driver (ethtool -i) is net_failover +# 2 device does NOT have the 'master' sysfs attribute (master is +# a link to the device's master, so it's a slave if it has this) +# 3 device has 'standby' virtio feature bit set (bit 62 counting from 0 +# in /sys/class/net/[ifname]/device/features). net_failover master +# and virtio_net slaves both get this as sysfs device attribute +# +# As of kernel 5.3, net_failover is only implemented for virtio_net +# +is_net_failover_master() { + local ifname="$1" driver + local sysfspath="/sys/class/net/${ifname}" + local virtio_features virtio_standby + + if [ ! -e "${sysfspath}" -o ! -e "${sysfspath}/device" ]; then + return 1 + fi + + driver="$(basename $(readlink ${sysfspath}/device/driver))" + if [ "${driver}" != "virtio_net" ]; then + return 1 + fi + + if [ -e "${sysfspath}/master" ]; then + return 1 + fi + + virtio_features=$(cat "${sysfspath}/device/features") + virtio_standby="$(expr substr $virtio_features 63 1)" + if [ "${virtio_standby}" = "0" ]; then + return 1 + fi + return 0 +} + _render_netplan() { # write a netplan stanza for the given device. local name="$1" mac="$2" dhcp4="$3" dhcp6="$4" addrs="$5" \ gateway4="$6" gateway6="$7" ns_addrs="$8" ns_search="$9" local n found="" + local nfm=0 echo "network:" echo " version: 2" echo " renderer: networkd" echo " ethernets:" echo " $name:" + # if $name is a net_failover master, do not use match: macaddress + if is_net_failover_master "$name"; then + nfm=1 + fi + if [ -n "$mac" ]; then - echo " match:" - echo " macaddress: \"$mac\"" + if [ "$nfm" -ne 1 ]; then + echo " match:" + echo " macaddress: \"$mac\"" + fi echo " set-name: $name" fi if [ -n "$dhcp4" ]; then diff -Nru initramfs-tools-0.130ubuntu3.10/scripts/local initramfs-tools-0.130ubuntu3.11/scripts/local --- initramfs-tools-0.130ubuntu3.10/scripts/local 2020-09-02 14:40:52.000000000 +0000 +++ initramfs-tools-0.130ubuntu3.11/scripts/local 2020-08-12 20:12:11.000000000 +0000 @@ -124,6 +124,7 @@ # If mdadm's local-block script counts the # number of times it is run, make sure to # run it the expected number of times. + mdadm_exec=0 while true; do if [ -f /run/count.mdadm.initrd ]; then count="$(cat /run/count.mdadm.initrd)" @@ -137,9 +138,32 @@ if [ ${count} -ge ${time_elapsed} ]; then break; fi + + # Track that mdadm was executed to force + # cryptroot execution after the loop, see + # LP #1879980. + mdadm_exec=1 /scripts/local-block/mdadm "${dev_id}" + + # Cryptroot must run here, see LP #1879980. + # The counter is inc/dec on cryptroot script! + if [ -f /run/cryptroot.initrd.cnt ]; then + crypt_cnt=$(cat /run/cryptroot.initrd.cnt) + if [ "${crypt_cnt}" -gt 0 ]; then + /scripts/local-block/cryptroot "${dev_id}" + fi + fi done + # Extra cryptroot run after mdadm loop in order to + # start encrypted volumes on top of RAID arrays. + if [ -f /run/cryptroot.initrd.cnt ]; then + crypt_cnt=$(cat /run/cryptroot.initrd.cnt) + if [ "${crypt_cnt}" -gt 0 ] || [ ${mdadm_exec} -ne 0 ]; then + /scripts/local-block/cryptroot "${dev_id}" + fi + fi + if real_dev=$(resolve_device "${dev_id}") && get_fstype "${real_dev}" >/dev/null; then wait_for_udev 10