summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChristian Marangi2025-10-22 00:17:25 +0000
committerChristian Marangi2025-10-23 16:16:33 +0000
commitbdb89ee6dff4742f2d7bcf101077ee6f9f8031f7 (patch)
tree5edf31e421f77d6ec27f8d0ab7f3d1840f2fea4f
parentdebc420622f9ed56fd2f23d455f831a22cf5a256 (diff)
downloadopenwrt-bdb89ee6dff4742f2d7bcf101077ee6f9f8031f7.tar.gz
image: fix race between mkits.sh and mkimage in .itb squashfs generation
With further investigation it was found a race in generating .itb images that include a RootFS caused by the mkits.sh and the mkimage. Due to the fact that mkits.sh generates a .pagesync image of the passed rootfs, it can happen that, concurrently, mkimage can be called at the same time mkits.sh is creating another .pagesync for the same rootfs. This cause mkimage to use an half made rootfs.pagesync creating a corrupted image. To address this, also protect the mkimage with the same lock used for mkits.sh preventing any kind of concurrent usage/generation of the rootfs.pagesync blob Fixes: 52cc9d82f113 ("kernel: rework Initramfs locking logic") Link: https://github.com/openwrt/openwrt/pull/20492 Signed-off-by: Christian Marangi <ansuelsmth@gmail.com> (cherry picked from commit 3de1bbd5aeb542de9a4b20eff0f6bbf1767fd6b9)
-rw-r--r--include/image-commands.mk5
1 files changed, 3 insertions, 2 deletions
diff --git a/include/image-commands.mk b/include/image-commands.mk
index a627ffc202..0833650ade 100644
--- a/include/image-commands.mk
+++ b/include/image-commands.mk
@@ -391,8 +391,9 @@ define Build/fit
$(if $(DEVICE_DTS_OVERLAY),$(foreach dtso,$(DEVICE_DTS_OVERLAY), -O $(dtso):$(KERNEL_BUILD_DIR)/image-$(dtso).dtbo)) \
-c $(if $(DEVICE_DTS_CONFIG),$(DEVICE_DTS_CONFIG),"config-1") \
-A $(LINUX_KARCH) -v $(LINUX_VERSION), gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))))
- PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\
- -E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new
+ $(call locked,PATH=$(LINUX_DIR)/scripts/dtc:$(PATH) mkimage $(if $(findstring external,$(word 3,$(1))),\
+ -E -B 0x1000 $(if $(findstring static,$(word 3,$(1))),-p 0x1000)) -f $@.its $@.new, \
+ gen-cpio$(if $(TARGET_PER_DEVICE_ROOTFS),.$(ROOTFS_ID/$(DEVICE_NAME))))
@mv $@.new $@
endef