Skip to content

kernel: append to init.rc instead of prepending to atrace.rc#3107

Merged
5ec1cff merged 2 commits into
mainfrom
append
Dec 26, 2025
Merged

kernel: append to init.rc instead of prepending to atrace.rc#3107
5ec1cff merged 2 commits into
mainfrom
append

Conversation

@5ec1cff

@5ec1cff 5ec1cff commented Dec 25, 2025

Copy link
Copy Markdown
Collaborator

Even though they are all triggered in post-fs-data stage, init.rc get parsed and triggered first. This will make module scripts run eariler and help prevent race condition between module rc executes and service starts. This also aligns behavior with Magisk.

@5ec1cff 5ec1cff marked this pull request as ready for review December 25, 2025 15:22
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 25, 2025
libra:/ $ su
root@localhost:[~]:# dmesg | grep KernelSU
[    3.987310] KernelSU: Initialized on: 3.10.108-libra/6cb879d (arm64) with ksuver: 32238 +path_umount
[    3.987315] KernelSU: feature: feature management initialized
[    3.987318] KernelSU: KernelSU IOCTL Commands:
[    3.987321] KernelSU:   GRANT_ROOT         = 0x00004b01
[    3.987323] KernelSU:   GET_INFO           = 0x80004b02
[    3.987326] KernelSU:   REPORT_EVENT       = 0x40004b03
[    3.987329] KernelSU:   SET_SEPOLICY       = 0xc0004b04
[    3.987331] KernelSU:   CHECK_SAFEMODE     = 0x80004b05
[    3.987334] KernelSU:   GET_ALLOW_LIST     = 0xc0004b06
[    3.987336] KernelSU:   GET_DENY_LIST      = 0xc0004b07
[    3.987339] KernelSU:   UID_GRANTED_ROOT   = 0xc0004b08
[    3.987341] KernelSU:   UID_SHOULD_UMOUNT  = 0xc0004b09
[    3.987344] KernelSU:   GET_MANAGER_APPID  = 0x80004b0a
[    3.987346] KernelSU:   GET_APP_PROFILE    = 0xc0004b0b
[    3.987349] KernelSU:   SET_APP_PROFILE    = 0x40004b0c
[    3.987351] KernelSU:   GET_FEATURE        = 0xc0004b0d
[    3.987354] KernelSU:   SET_FEATURE        = 0x40004b0e
[    3.987356] KernelSU:   GET_WRAPPER_FD     = 0x40004b0f
[    3.987359] KernelSU:   MANAGE_MARK        = 0xc0004b10
[    3.987362] KernelSU:   NUKE_EXT4_SYSFS    = 0x40004b11
[    3.987364] KernelSU:   ADD_TRY_UMOUNT     = 0x40004b12
[    3.987368] KernelSU: sulog_init: allocated 2000 bytes on 0xffffffc002bd3800
[    3.987372] KernelSU: feature: registered handler for su_compat (id=0)
[    3.987374] KernelSU: feature: registered handler for kernel_umount (id=1)
[    3.987377] KernelSU: feature: registered handler for enhanced_security (id=2)
[    4.406982] KernelSU: ksu_handle_bprm_ksud: filename: /system/bin/init argv1: norandmaps envp_len: 36
[    4.630656] KernelSU: ksu_handle_bprm_ksud: filename: /system/bin/init argv1: selinux_setup envp_len: 183
[    4.790463] KernelSU: is_ksu_transition: got init sid: 49
[    4.790558] KernelSU: is_ksu_transition: got su sid: 295
[    4.790656] KernelSU: ksu_grab_init_session_keyring: init_session_keyring: 0xffffffc066f4e180
[    4.790662] KernelSU: ksu_handle_bprm_ksud: filename: /system/bin/init argv1: second_stage envp_len: 213
[    4.790665] KernelSU: ksu_handle_bprm_ksud: /system/bin/init second_stage executed
[    4.790668] KernelSU: SELinux permissive or disabled, apply rules!
[    4.791816] KernelSU: vfs_read: /system/etc/init/hw/init.rc, comm: init, count: 1024, rc_count: 351
[    4.792531] KernelSU: stop vfs_read_hook
[    4.793341] KernelSU: read_proxy: orig read finished (ret 0), start append rc
[    4.793350] KernelSU: read_proxy: append 351
[    4.793352] KernelSU: read_proxy: append done
[   13.060010] KernelSU: is_ksu_transition: allowing init (49) -> su (295)
[   13.097580] KernelSU: sys_reboot: intercepted call! magic: 0xdeadbeef id: -889275714
[   13.097598] KernelSU: ksu fd installed: 4 for pid 392
[   13.097601] KernelSU: [392] install ksu fd: 4
@5ec1cff 5ec1cff merged commit 4217515 into main Dec 26, 2025
17 checks passed
@5ec1cff 5ec1cff deleted the append branch December 26, 2025 05:20
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 26, 2025
just to make sure this transition is smooth

for: tiann#3107

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
KOWX712 pushed a commit to KOWX712/KernelSU that referenced this pull request Dec 26, 2025
)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.
Admirepowered added a commit to Admirepowered/KernelPatch that referenced this pull request Dec 26, 2025
Admirepowered added a commit to bmax121/KernelPatch that referenced this pull request Dec 26, 2025
pershoot pushed a commit to pershoot/KernelSU-Next that referenced this pull request Dec 26, 2025
…ernelSU#3107)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 26, 2025
just to make sure this transition is smooth

for: tiann#3107

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
@5ec1cff

5ec1cff commented Dec 26, 2025

Copy link
Copy Markdown
Collaborator Author

@backslashxx To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

@backslashxx

backslashxx commented Dec 26, 2025

Copy link
Copy Markdown
Contributor

I will update, but yeah I noticed this earlier so I added atrace as another option.

Details image

all good on A10

Details image

backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 26, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
rifsxd pushed a commit to KernelSU-Next/KernelSU-Next that referenced this pull request Dec 26, 2025
…ernelSU#3107) (#1017)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
maxsteeel pushed a commit to maxsteeel/KernelSU-Next that referenced this pull request Dec 27, 2025
…ernelSU#3107) (KernelSU-Next#1017)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
maxsteeel pushed a commit to maxsteeel/KernelSU-Next that referenced this pull request Dec 27, 2025
…ernelSU#3107) (KernelSU-Next#1017)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
rifsxd pushed a commit to KernelSU-Next/KernelSU-Next that referenced this pull request Dec 27, 2025
* kernel: fix manager crowning (or maybe not)

* sulogv2

* kernel: Update build setup (#1010)

* kernel: append to init.rc instead of prepending to atrace.rc (tiann/KernelSU#3107) (#1017)

Even though they are all triggered in post-fs-data stage, init.rc get
parsed and triggered first. This will make module scripts run eariler
and help prevent race condition between module rc executes and service
starts. This also aligns behavior with Magisk.

Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>

* kernel: create helper for checking init.rc compat

* Using for loop is a meme.
* Ref:
https://github.com/topjohnwu/Magisk/blob/01cb75eaefbd14c2d10772ded3942660ebf0285f/native/src/init/rootdir.cpp#L317

Signed-off-by: rsuntk <rissu.ntk@gmail.com>

* kernel: Make Kbuild a little bit more readable

---------

Signed-off-by: rsuntk <rissu.ntk@gmail.com>
Co-authored-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
Co-authored-by: pershoot <190600+pershoot@users.noreply.github.com>
Co-authored-by: 5ec1cff <56485584+5ec1cff@users.noreply.github.com>
Co-authored-by: rsuntk <rissu.ntk@gmail.com>
Admirepowered added a commit to bmax121/APatch that referenced this pull request Dec 27, 2025
Allow patches even when verification fails.
It may fix some device patch failed

To support certain devices that replace /system/etc/init/atrace.rc with /system/etc/init/hw/init.rc too early during post-data-fs, and to maintain compatibility with older devices below Android 12 that lack /system/etc/init/hw/init.rc, the openat RC redirection logic has been improved: it now matches multiple RC paths and applies the replacement on the first hit, while ensuring the restored RC strictly corresponds to the originally matched path to prevent cross-path corruption. Behavior on Android 12+ devices remains unchanged.
More information Ref: tiann/KernelSU#3107
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 27, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 29, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 30, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
selfmusing pushed a commit to selfmusing/USlenreK that referenced this pull request Dec 31, 2025
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
backslashxx added a commit to backslashxx/KernelSU that referenced this pull request Jan 1, 2026
5ec1cff said:
To support Android versions below 11, it might be necessary to inject the /init.rc file, just like Magisk does.

ref: tiann#3107 (comment)

Signed-off-by: backslashxx <118538522+backslashxx@users.noreply.github.com>
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.

2 participants