diff --git a/Documentation/admin-guide/installation.rst b/Documentation/admin-guide/installation.rst index 2fea1c7a..137b1f94 100644 --- a/Documentation/admin-guide/installation.rst +++ b/Documentation/admin-guide/installation.rst @@ -205,7 +205,9 @@ CLI,需要明确的 ``--disk``、``--boot-directory`` 和根分区身份; TTY 入口使用相同的后端,并在显示摘要和引导选项后通过 ``y/N`` 确认。 检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 -软件包归档以及离线依赖。确认后的执行会再次核对磁盘、分区 UUID、索引和 +软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` +tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 +确认后的执行会再次核对磁盘、分区 UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 ESP,以及早于已安装系统的介质会在写入前被拒绝。 diff --git a/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po b/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po index 1113d9e7..7370e9eb 100644 --- a/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po +++ b/Documentation/locale/en/LC_MESSAGES/admin-guide/installation.po @@ -456,13 +456,17 @@ msgstr "" " and boot options." msgid "" -"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。确认后的执行会再次核对磁盘、分区 " +"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` " +"tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 确认后的执行会再次核对磁盘、分区 " "UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 " "ESP,以及早于已安装系统的介质会在写入前被拒绝。" msgstr "" "Checks use a private APK database and the installed system's trusted keys" " to verify signed indexes, complete package archives, and offline " -"dependencies. Execution after confirmation rechecks disks, partition " +"dependencies. The private database and archives are stored temporarily in " +"the ``/run`` tmpfs mounted at boot and removed when the operation finishes, " +"so they do not fill the installation medium's fixed-size runtime root " +"filesystem. Execution after confirmation rechecks disks, partition " "UUIDs, indexes, the installed package database, and world selections; " "changed targets require a fresh check. Partitions already mounted " "elsewhere, roots or ESPs that cannot be uniquely identified, and media " diff --git a/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po b/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po index 9e7a0803..15865c36 100644 --- a/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po +++ b/Documentation/locale/ja/LC_MESSAGES/admin-guide/installation.po @@ -360,12 +360,15 @@ msgstr "" "パスへのコピー操作は受け付けません。TTY 入口も同じバックエンドを使い、概要と起動オプションの表示後に ``y/N`` で確認します。" msgid "" -"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。确认后的执行会再次核对磁盘、分区 " +"检查过程使用私有 APK 数据库和已安装系统的信任密钥,验证签名索引、完整 软件包归档以及离线依赖。私有数据库和归档临时存放在启动时挂载的 ``/run`` " +"tmpfs 中,结束后清理,避免占满安装介质的固定大小运行时根文件系统。 确认后的执行会再次核对磁盘、分区 " "UUID、索引和 已安装包数据库及 world 选择;目标已经变化时需要重新检查。已被其他路径挂载的分区、 无法唯一识别的根分区或 " "ESP,以及早于已安装系统的介质会在写入前被拒绝。" msgstr "" "確認処理は専用の APK " -"データベースとインストール済みシステムの信頼鍵を使用し、署名済みインデックス、パッケージアーカイブ全体、オフライン依存関係を検証します。確定後の実行時にもディスク、パーティション" +"データベースとインストール済みシステムの信頼鍵を使用し、署名済みインデックス、パッケージアーカイブ全体、オフライン依存関係を検証します。" +"専用データベースとアーカイブは、起動時にマウントされる ``/run`` の tmpfs に一時保存し、処理の終了後に削除します。" +"これにより、インストールメディアの固定サイズの実行用ルートファイルシステムを使い切ることを防ぎます。確定後の実行時にもディスク、パーティション" " UUID、インデックス、既存パッケージデータベース、world " "の選択を再確認し、対象が変化していれば再検査が必要です。他の場所にマウント済みのパーティション、一意に識別できないルートや " "ESP、既存システムより古いメディアは書き込み前に拒否します。" diff --git a/kernel/reliefnt b/kernel/reliefnt index 8cf925a2..ff2df8af 160000 --- a/kernel/reliefnt +++ b/kernel/reliefnt @@ -1 +1 @@ -Subproject commit 8cf925a2c1bd1ed4279c1223a253ab1569dbaf68 +Subproject commit ff2df8af1b0eca7a1ac0521c53c9d4e217f9cbeb diff --git a/tools/test_installer_update_packages.py b/tools/test_installer_update_packages.py index 1e82c480..5227bb29 100644 --- a/tools/test_installer_update_packages.py +++ b/tools/test_installer_update_packages.py @@ -30,7 +30,7 @@ def setUpClass(cls): check=True, capture_output=True) cls.key.chmod(0o600) cls.base = cls.work / "base" - for name in ("bin", "usr/sbin", "usr/lib/reliefos", "usr/libexec/reliefos", "sbin", "tmp", "dev", "proc", "oldrepo", "newrepo", + for name in ("bin", "usr/sbin", "usr/lib/reliefos", "usr/libexec/reliefos", "sbin", "tmp", "run", "dev", "proc", "oldrepo", "newrepo", "target/etc/apk/keys", "target/lib/apk/db", "target/etc/reliefos", "target/home/test", "target/usr/share/external", "target/bin", "target/usr/lib/reliefos", "target/var/lib/reliefos"): @@ -124,13 +124,16 @@ def target_snapshot(self): return {str(path.relative_to(target)): hashlib.sha256(path.read_bytes()).hexdigest() for path in target.rglob("*") if path.is_file() and not path.is_symlink()} - def transaction(self, mode="--check", expected=None, cache_readonly=False): + def transaction(self, mode="--check", expected=None, cache_readonly=False, readonly_tmp=False): readonly = ('mount --bind "$1/target" "$1/target"; ' 'mount -o remount,bind,ro "$1/target"; ') if mode == "--check" else "" if cache_readonly: readonly += ('mount --bind "$1/target/usr/share/reliefos/apk/repository" ' '"$1/target/usr/share/reliefos/apk/repository"; ' 'mount -o remount,bind,ro "$1/target/usr/share/reliefos/apk/repository"; ') + if readonly_tmp: + readonly += ('mount --bind "$1/tmp" "$1/tmp"; ' + 'mount -o remount,bind,ro "$1/tmp"; ') result = subprocess.run([ "unshare", "-Urmp", "--fork", "sh", "-eu", "-c", 'mount --make-rprivate /; mount --bind "$1" "$1"; ' @@ -156,6 +159,13 @@ def test_signed_preflight_succeeds_with_readonly_target(self): self.assertEqual(result.returncode, 0, result.stdout + result.stderr) self.assertIn("reliefos-fixture", result.stdout) + def test_preflight_does_not_require_writable_runtime_tmp(self): + before = self.target_snapshot() + result = self.transaction(readonly_tmp=True) + self.assertEqual(result.returncode, 0, result.stdout + result.stderr) + self.assertEqual(self.target_snapshot(), before) + self.assertFalse(list((self.runner / "run").glob("reliefos-update.*"))) + def test_unsigned_index_is_rejected_before_target_changes(self): self.index(self.runner / "newrepo", signed=False) result = self.check() diff --git a/tools/test_installer_update_qemu.py b/tools/test_installer_update_qemu.py index 01623d53..45429aea 100644 --- a/tools/test_installer_update_qemu.py +++ b/tools/test_installer_update_qemu.py @@ -16,6 +16,12 @@ ROOT = Path(__file__).resolve().parents[1] +def assert_no_user_faults(serial): + faults = [line for line in serial.read_text(errors="replace").splitlines() + if "user page fault signal=" in line] + assert not faults, "User processes faulted during the installer update:\n" + "\n".join(faults) + + def installed_state(disk, directory): table = json.loads(subprocess.check_output(["sfdisk", "--json", str(disk)], text=True))["partitiontable"] partition = next(part for part in table["partitions"] @@ -108,12 +114,14 @@ def main(): try: probe.click(*probe.footer_point()) wait_page(probe, process, "Review update", args.timeout) + assert_no_user_faults(serial) assert probe.visible_page(probe.frame("inspection-complete")) == 4 next_page(probe, 8) wait_page(probe, process, "Review system update", args.timeout) probe.frame("confirmation") next_page(probe) wait_page(probe, process, "was updated on the selected disk", args.timeout) + assert_no_user_faults(serial) probe.frame("updated") finally: (output / "installer.log").write_text(installer_finish_log( diff --git a/userland/storage/reliefos-apk-update b/userland/storage/reliefos-apk-update index 8eeca85a..7b516dde 100755 --- a/userland/storage/reliefos-apk-update +++ b/userland/storage/reliefos-apk-update @@ -29,7 +29,9 @@ index_sha=$(/bin/busybox sha256sum "$repository/packages.adb") index_sha=${index_sha%% *} [ -z "$expected_index" ] || [ "$index_sha" = "$expected_index" ] || die 'installation media changed after inspection; check the update again' -temporary=$(/bin/busybox mktemp -d /tmp/reliefos-update.XXXXXX) +# Early init mounts /run as tmpfs. The private database and verified archives +# must not consume the installation medium's fixed-size runtime root. +temporary=$(/bin/busybox mktemp -d /run/reliefos-update.XXXXXX) update_step=repository update_action=step update_package=- update_status=0 files_done=0 files_total=0 bytes_done=0 bytes_total=0 bytes_reused=0 cache_temporary=