[OpenWrt-Devel] [PATCH] fstools: fix mount_root overlay comments

sean-m-miller seanmmiller.business at gmail.com
Wed May 20 13:49:21 EDT 2020


Sysupgrades that preserve volatile files ('sysupgrade -c ...') replace
the 0xDEADCODE marker at the rootfs/rootfs_data boundary with the tar
bundle of preserved files. The 0xDEADCODE marker is moved to the start
of the next erase block.

Upon the subsequent first boot, the mount_root utility reads a valid
jffs2 file in the first block of rootfs_data, concludes that the
partition has already been formatted, and summons the jffs2 driver.
The jffs2 driver finds the 0xDEADCODE marker after the tar file
and assumes that now is a safe time to format the rootfs_data
partition and launch the jffs2 overlay.

This is a bug, since preinit_main hangs while the jffs2 driver
formats the partition, which can cause fatal soft lockups on systems
with weak cpu and large rootfs_data partitions. The intended behavior
for a first boot is to have mount_root kick off an intermediate tmpfs
overlay, deferring the jffs2 switch until the /etc/init.d/done call.

Patching this bug would lead to the preserved files being lost
during upgrades or downgrades to or from the fixed build, so it is
probably best to leave it as is. Fortunately, the preinit_main hang
is survivable on most current systems. This bug should be described in
comments for the sake of maintaining accurate descriptions of the system.

Signed-off-by: Sean Miller <seanmmiller.business at gmail.com>
---
 .../patches/010-mount_root-overlay-bug.patch     | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
 create mode 100644 package/system/fstools/patches/010-mount_root-overlay-bug.patch

diff --git a/package/system/fstools/patches/010-mount_root-overlay-bug.patch b/package/system/fstools/patches/010-mount_root-overlay-bug.patch
new file mode 100644
index 0000000000..c2d72e3d9b
--- /dev/null
+++ b/package/system/fstools/patches/010-mount_root-overlay-bug.patch
@@ -0,0 +1,16 @@
+--- a/mount_root.c
++++ b/mount_root.c
+@@ -75,6 +75,13 @@ start(int argc, char *argv[1])
+ 	case FS_F2FS:
+ 	case FS_JFFS2:
+ 	case FS_UBIFS:
++		/*
++		 * Filesystem is in a valid state so we can go ahead and mount
++		 * the target overlay, or this is the first boot after an upgrade
++		 * that preserved files, so we hang preinit_main while we format
++		 * the partition (oops... this is undesired) and then launch the
++		 * target overlay (skip the intermediate tmpfs step).
++		 */
+ 		mount_overlay(data);
+ 		break;
+ 
-- 
2.20.1 (Apple Git-117)


_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list