From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id 621F36C618 for ; Thu, 23 Sep 2021 10:43:21 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 559C722AB6 for ; Thu, 23 Sep 2021 10:43:21 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id C044A22AAD for ; Thu, 23 Sep 2021 10:43:20 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id 9470144A80 for ; Thu, 23 Sep 2021 10:43:20 +0200 (CEST) From: Stoiko Ivanov To: pve-devel@lists.proxmox.com Date: Thu, 23 Sep 2021 10:43:17 +0200 Message-Id: <20210923084317.3779388-1-s.ivanov@proxmox.com> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.396 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pve-devel] [PATCH pve-kernel-meta] proxmox-boot: fix #3632 copy kernel+initrd unconditionally X-BeenThere: pve-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox VE development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2021 08:43:21 -0000 do not use the -u (update) flag when copying kernel images and inird from /boot to the ESPs: * the ESPs are formatted with vfat, which has a 2 second precision for mtime (`linux/fs/fat/misc.c` - `fat_truncate_time`) * cp -u compares the mtimes of source (kernel image in /boot not on vfat) and destination - leading to the copy always being carried out, if the source files remain the same (and do not happen to have a mtime exactly happening on a even second) as laid out in the bug-report - the case where this leads to an unbootable system is when a kernel-version is shipped twice (built with different tool-chains) - e.g. currently the 5.11 kernels in PVE 6 and PVE 7. tested the behavior of `cp -u` by running opensnopp-bpfcc and copying a file twice onto ext4 (opened only once) and on vfat (opened twice). additionally reproduced the issue (by dist-upgrading a PVE 6 VM to 7 with the pve-no-subscription repo) and verified this patch fixes it. Signed-off-by: Stoiko Ivanov --- Initially considered using the output of `stat --format=%s:%Y` of both files as 'fingerprint' for comparison proxmox-boot/zz-proxmox-boot | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/proxmox-boot/zz-proxmox-boot b/proxmox-boot/zz-proxmox-boot index 244fe8e..4bd63a6 100755 --- a/proxmox-boot/zz-proxmox-boot +++ b/proxmox-boot/zz-proxmox-boot @@ -132,21 +132,21 @@ copy_and_config_kernels() { KERNEL_ESP_DIR="${PMX_ESP_DIR}/${kver}" KERNEL_LIVE_DIR="${esp}/${KERNEL_ESP_DIR}" mkdir -p "${KERNEL_LIVE_DIR}" - cp -u --preserve=timestamps "${linux_image}" "${KERNEL_LIVE_DIR}/" - cp -u --preserve=timestamps "${initrd}" "${KERNEL_LIVE_DIR}/" + cp --preserve=timestamps "${linux_image}" "${KERNEL_LIVE_DIR}/" + cp --preserve=timestamps "${initrd}" "${KERNEL_LIVE_DIR}/" # create loader entry cat > "${esp}/loader/entries/proxmox-${kver}.conf" <<- EOF title ${LOADER_TITLE} version ${kver} options ${CMDLINE} - linux /${KERNEL_ESP_DIR}/vmlinuz-${kver} - initrd /${KERNEL_ESP_DIR}/initrd.img-${kver} + linux /${KERNEL_ESP_DIR}/vmlinuz-${kver} + initrd /${KERNEL_ESP_DIR}/initrd.img-${kver} EOF else warn " Copying kernel ${kver}" - cp -u --preserve=timestamps "${linux_image}" "${esp}/" - cp -u --preserve=timestamps "${initrd}" "${esp}/" + cp --preserve=timestamps "${linux_image}" "${esp}/" + cp --preserve=timestamps "${initrd}" "${esp}/" fi done -- 2.30.2