portal_sysctl: don't panic creating sysctls under non-existent dirs (old kernels)#76
Merged
Conversation
handle_op_sysctl_create_file() called register_sysctl() for every new entry. On pre-5.0 kernels, when register_sysctl() has to create a new directory hierarchy and an intermediate component cannot be created (e.g. anything under the filesystem-backed /proc/sys/fs/binfmt_misc node, which returns -EROFS), the kernel faults in its cleanup path (drop_sysctl_table -> rb_erase) and panics, killing init. Newer kernels return NULL and are already handled by the !entry->header path. This reliably crashed aarch64 guests (4.10 kernel) ~5s into boot when Penguin modeled bogus /proc/sys entries scraped from binaries. Guard the creation path: - Reject malformed paths up front (empty leaf name, embedded "//"). - On kernels < 5.0, refuse to create an entry whose parent sysctl directory does not already exist -- verified by walking the live sysctl tree with the existing safe accessors (igloo_sysctl_dir_exists) -- instead of handing the kernel a doomed registration. Scoped to affected versions so newer kernels keep creating new dirs as before. Companion to rehosting/penguin, which also filters these paths upstream.
lacraig2
added a commit
to rehosting/penguin
that referenced
this pull request
Jun 9, 2026
0.0.78 includes the portal_sysctl create-guard (rehosting/igloo_driver#76), the kernel-side backstop for the bogus-sysctl boot panic this PR also guards against from the Python side.
lacraig2
added a commit
to rehosting/penguin
that referenced
this pull request
Jun 9, 2026
0.0.78 includes the portal_sysctl create-guard (rehosting/igloo_driver#76), the kernel-side backstop for the bogus-sysctl boot panic this PR also guards against from the Python side.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
handle_op_sysctl_create_file()callsregister_sysctl()for every new sysctl entry Penguin asks the guest to create. On pre-5.0 guest kernels this can panic the guest:When
register_sysctl()has to create a new directory hierarchy and an intermediate component can't be created — e.g. anything under the filesystem-backed/proc/sys/fs/binfmt_miscnode, which returns-EROFS— the 4.10 kernel faults in its cleanup path (drop_sysctl_table→rb_erase) instead of returning an error. That killsinitand panics the box. Newer kernels (5.x) returnNULLfromregister_sysctl()and are already handled by the existing!entry->headerpath, so only old kernels are affected.This reliably crashed aarch64 guests (4.10 kernel) ~5s into boot whenever Penguin modeled bogus
/proc/sys/*entries (these come from auto-generated pseudofile models that scrape binary strings, e.g./proc/sys/fs/binfmt_misc/WSLInteropos/signal).Fix
Guard the creation path in
handle_op_sysctl_create_file()://).igloo_sysctl_dir_exists(), walks the live sysctl tree using the same safe accessors as the existingigloo_find_sysctl_leaf(). If the parent dir isn't real, we log and returnHYPER_RESP_WRITE_FAILinstead of handing the kernel a doomed registration. Scoped viaLINUX_VERSION_CODEso 5.x+ keeps creating new directories exactly as before (no behavior change on modern kernels).Mutating an existing sysctl leaf is unchanged.
Testing
Built
igloo.koforarm64/4.10with this change and ran the GL.iNet Beryl AX (GL-MT3000) firmware under Penguin with stock pyplugins (so the bogusbinfmt_miscsysctl is still sent to the guest):Attempted to kill init!), 99-line console, no services.igloo.kochanged.x86-64 (5.15) is unaffected (guard is version-scoped).
Companion
rehosting/penguin filters the same unregisterable paths upstream (defense in depth) — see its
fix/sysctl-create-guardPR. Either change alone prevents the panic; together they stop bogus models from being emitted and make the driver robust against any that slip through.