Skip to content

kernel,ksud: support module-provided init.rc injection#3478

Open
YuKongA wants to merge 10 commits into
mainfrom
injectrc
Open

kernel,ksud: support module-provided init.rc injection#3478
YuKongA wants to merge 10 commits into
mainfrom
injectrc

Conversation

@YuKongA
Copy link
Copy Markdown
Collaborator

@YuKongA YuKongA commented May 20, 2026

No description provided.

Comment thread kernel/runtime/ksud_integration.c Outdated
@5ec1cff 5ec1cff marked this pull request as ready for review May 21, 2026 08:16
@5ec1cff 5ec1cff requested a review from Copilot May 21, 2026 08:17
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds end-to-end support for module-provided init.rc injection by generating a consolidated modules.rc file in /metadata[/watchdog]/ksu/ from enabled modules and having the kernel’s init.rc read hook append that file at boot.

Changes:

  • Userspace: generate and refresh /metadata[/watchdog]/ksu/modules.rc by concatenating *.rc from enabled modules (and a common initrc.d directory), with refresh triggered on module state changes and post-fs-data.
  • CLI: add ksud initrc refresh to manually regenerate the preinit rc file.
  • Kernel: extend the init.rc read/stat hook to append modules.rc (loaded once into a bounded buffer) after the built-in KERNEL_SU_RC.

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 8 comments.

Show a summary per file
File Description
userspace/ksud/src/utils.rs Uninstall cleanup now removes the new preinit rc directories.
userspace/ksud/src/module.rs Implements modules.rc regeneration and hooks it into module install/enable/disable/remove flows.
userspace/ksud/src/init_event.rs Regenerates modules.rc during post-fs-data as a safety net.
userspace/ksud/src/defs.rs Adds constants for preinit directories and rc file naming.
userspace/ksud/src/cli.rs Adds initrc refresh subcommand to regenerate modules.rc.
kernel/runtime/ksud_integration.c Appends module-provided rc content to init.rc via the existing read/stat hook.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread userspace/ksud/src/module.rs Outdated
Comment thread userspace/ksud/src/module.rs Outdated
Comment thread userspace/ksud/src/module.rs
Comment thread kernel/runtime/ksud_integration.c
Comment thread kernel/runtime/ksud_integration.c
Comment thread kernel/runtime/ksud_integration.c
Comment thread userspace/ksud/src/module.rs
Comment thread userspace/ksud/src/module.rs
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.

Comment thread userspace/ksud/src/module.rs Outdated
Comment on lines +456 to +463
let mut out_file = File::create(&out_path)?;
out_file.write_all(&tmp)?;
}

// SELinux label so the kernel's filp_open in init context can read it.
if let Err(e) = crate::restorecon::lsetfilecon(&out_path, METADATA_FILE_CON) {
debug!("set context on {} failed: {e}", out_path.display());
}
Comment thread kernel/runtime/ksud_integration.c
Comment thread kernel/runtime/ksud_integration.c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants