yashsingh1/xdaforums huggingface dataset:
[Magisk] pndwal:
New sepolicy injection "hack"

www.twitter.com/topjohnwu/status/1503651835571175425

I note John says this will actually support Pierre-Hugues Husson's users, ie users of his GSIs, treble_experimentations (tinkering with Android Project Treble).

Technical overview:

Introduce new sepolicy injection mechanism …

In the current implementation, Magisk will either have to recreate all early mount implementation (for legacy SAR and rootfs devices) or delegate early mount to first stage init (for 2SI devices) to access required partitions for loading sepolicy. It then has to recreate the split sepolicy loading implementation in-house, apply patches, then dump the compiled + patched policies into monolithic format somewhere. Finally, it patches the original init to force it to load the sepolicy file we just created.

With the increasing complexity involved in early mount and split sepolicy (there is even APEX module involved in the future!), it is about time to rethink Magisk's sepolicy strategy as rebuilding init's functionality is not scalable and easy to maintain.

In this commit, instead of building sepolicy ourselves, we mock selinuxfs with FIFO files connected to a pre-init daemon, waiting for the actual init process to directly write the sepolicy file into MagiskInit. We then patch the file and load it into the kernel. Some FIFO tricks has to be used to hijack the original init process's control flow and prevent race conditions, details are directly in the comments in code.

At the moment, only system-as-root (read-only root) support is added. Support for legacy rootfs devices will come with a follow up commit.

Add hijack sepolicy support for rootfs devices …

On older Android versions, pre-mounting selinuxfs will lead to errors, so we have to use a different method to block init's control flow. Since all devices that falls in this catagory must both:

1. Be Android 8.0 - 9.0

2. Have early mount fstab in its device tree

We can actually use the same FIFO trick, but this time not on selinuxfs, but on the read-only device tree nodes in sysfs or procfs. By mocking the fstab/compatible node in the device tree, we can block init when it attempts to do early mount; at that point, we can then mock selinuxfs as we normally would, successfully hijack and inject patched sepolicy.

🤠 PW
[Magisk] Jerreth:
I have installed the latest 24303 on my pixel 6 pro and it will no longer boot and states that the software is corrupt. is this known issue? i have already factory wiped my phone and am setting it up again but do not want to run in to this issue again.
[Magisk] V0latyle:
Updated to 24303 on my Pixel 5, no issues. Stock kernel, 3 modules: Systemless hosts, USNF, MHPC
[Magisk] Lughnasadh:
I got stuck in bootloader mode as well when updating to Canary 24303 (via direct install) on my Pixel 6 Pro running QPR3 Beta 1, but didn't get the corrupt message. Flashed the stock boot image and it still didn't boot. Finally dirty flashed the factory image (QPR3 Beta 1) and patched the boot image (using 24303) and all was well.

All modules and Substratum overlays continue to work so that was not likely the culprit.

EDIT: Think I figured it out. Forgot I had Kirisakura kernel installed (that's why just flashing the stock boot image didn't work). Just flashed Kirisakura again and wouldn't boot (stuck in bootloader mode again). So it appears, at least for me, that Kirisakura (12L 1.8.9) is the culprit.
[Magisk] Jerreth:
interesting so patching that particular kernel is causing it?
[Magisk] garfield03:
Hello everyone

I have a pixel 2xl and i've installed lineage 0S 18.1. Everything was great. Yesterday I updated my rom through OTA with the last release.

Unfortunately since that day magisk doesn't work anymore. I tried to reinstall magisk serveral time with the 24.3 apk and the 23.1 but it doesn't work. Everytime i tried to get a patched boot.img it failed.

I think the problem is the magisk installer but I don't know how to solve the problem.

I think maybe my mistake was when i updated my rom i didn't uninstalled safetynet . Anyway anyone have an idea?

Thanks
[Magisk] Lughnasadh:
Appears so. Just flashed the stock boot.img, dtbo.img, vendor_boot.img and vendor_dlkm.img and it booted again. Then patched the boot image again with 24303 and all is good.

I'll go over to that thread and let Freak07 know.
[Magisk] J.Michael:
Have you found a description of a procedure to take an OTA update without losing Magisk?

In the absence of someone claiming otherwise, I would assume you need to uninstall Magisk before taking an OTA update. Having modules in /data/adb should not be an issue. Having the boot partition look exactly like the update expects it to look would be an issue.
[Magisk] pndwal:
Here:

https://github.com/topjohnwu/Magisk/blob/master/docs/ota.md

This is all true as a general rule, and of all A-only devices.

However there was a working feature for A/B devices introduced some time ago, Install to Inactive Slot, where "out-of-the-box OTA installation works seamlessly and Magisk can be preserved after the installation" as long as John's instructions are followed carefully.

Further, this feature was disabled in Magisk builds since September 2020 due to Google changes to OTA pushing through GMS bootlooping Pixels.

This is apparently fixed since 'Enable installation to inactive slot on Pixel devices #5204' was merged in January this year. Updating / removing temporary notes & reinstating ota.md link in Magisk Documentation is still pending. I noted this last week and provided links here:

https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-86558985

😛 PW
[Magisk] m0han:
another device, another rom; so, just an fyi:

updated to 24302 and soon thereafter to 24303 on my karna (poco x3) running crDroid A12 rom of 13 march. stock kernel, many modules ;) no issues.
[Magisk] angry_goldfish:
I'm here confirming that .zip installations are broken after 24.1. Tested on three different devices all with updated TWRP.
[Magisk] traversone:
..and maybe "file observe error" given by Shamiko is worth to be investigated
[Magisk] garfield03:
Thanks for your reply. My issue was doing the update with magisk installed. I did a clean install of the rom again and then magisks and everythings works fine.

ok so now i know that before taking an OTA i have to uninstall magisk and all his module but i have one question.

To make magisk work i have to install a patched boot.img so before an OTA what i have to do? Do i have to uninstall the patched boot.img and put back my ROM boot.img or can i process the update directly?
[Magisk] zgfg:
You always have to patch up-to-date boot.img - from the same firmware you have installed

System will not boot being it patched by Magisk or not, if boot.img is from the wrong firmware - it has nothing to do with Magisk but with the firmware

Usually, with the OTA update, boot.img is also updated, hence you must use then and patch that new boot.img
[Magisk] traversone:
Canary 24.303 is not able to patch correctly LOS 18.1 boot.

I mean: manager completes patching successfully but, after reboot, Magisk is not installed. Mobile is Samsung S4.

Stable 24.3 was OK.

edit: Canary 24.301 is fine too
[Magisk] garfield03:
Well i think there is a misunderstood. (I know that the boot.img i use must match the ROM update.)

Let's say i've installed the last OTA (let's name it "mars"). I took the boot.img of that last update and patched it with magisks.

In two weeks i suppose there will be a new OTA with a new boot.img ( let's name it "april" ).

Do i have to uninstall the "mars"patched boot.img ( the one i made with magisk) and put back the boot.img provided with "mars" OTA before the "april" update or can i install the april OTA directly meaning the "april" boot.img will replace the mars patched boot.img without generating issue.

Sorry it looks awful hope you understand :/
[Magisk] kramer04:
Samsung Note9

Android 10

Stock Rom, stock kernel

last update Canary 24303(27) causes bootloop.

I had to re install boot.img and magisk from rcovery to boot again .
[Magisk] pndwal:
Looks like Canyie's fixed this one already; this issue?:

https://github.com/topjohnwu/Magisk/issues/5609

Seems to be a regression w/ sepolicy after John's big sepolicy injection "hack".

Fix

https://github.com/topjohnwu/Magisk/pull/5615

is still downstream, but you can try test actions run build from artifacts here while you wait for next official Magisk build:

Device using split policy can still have monolithic sepolicy file

Other sepolicy fixes have also been made since...

👀 PW
[Magisk] pndwal:
Like this?:

https://github.com/topjohnwu/Magisk/issues/5607

Test runs linked there...

Or could be another (selinux change, other) regression... There a already several ducks in a row for imminent shooting season... PW
[Magisk] kramer04:
Not sure my device booloop on samsung logo

Wait next update
[Magisk] traversone:
this test build works fine ! many thanks PW

edit: again after 4-5 minutes from complete boot, "file observer error" is given in the Shamiko status but MOMO is still happy (with Xposed switched off, of course)

edit#2: it is confirmed that mobile tries to boot normally, then reboots after some seconds (still on splash screen) and second boot is ok - under investigation, not 100% confirmed
[Magisk] pndwal:
Issue is you need to restore all original images (boot, vbmeta, recovery... other...) to stock before taking stock rom OTAs as these are generally 'delta' incremental updates, meaning they are very small as they only patch image files... They require any partitions in update (you don't know what is included, but boot.img often is as it contains kernel which gets much attention/ many fixed) to be an expected bit-perfect match for a prior ROM or patching will fail or corrupt the image.

So you need original images restored, not next April's, or next pancake Tuesday's...

Some 'OTA' updates including custom LineageOS weekly updates are not delta (they're full images / very large) and can be flashed without restoring images... Of course Magisk root will be lost...

Uninstall Magisk app function offers 2 options; you don't need Complete Uninstall or to remove modules. Modules and other settings are stored in /data partition... Be aware that some modules can bootloop device after an update, especially if update changes Android version and modules become incompatible...

You can choose Restore Images (only) option generally... After Update obtain new (updated) boot image and patch / flash... Nb. Prior images will often allow booting, but generally comms, bt, other hardware and more will have issues or be broken...

As I mentioned above

https://xdaforums.com/t/magisk-general-support-discussion.3432382/post-86600573

There is a recently fixed solution for for A/B devices, Install to Inactive Slot, where "out-of-the-box OTA installation works seamlessly and Magisk can be preserved after the installation" as long as John's instructions are followed carefully. As I believe Pixel 2 / 2XL were Google's flagship SAR devices (Initial SAR devices were a A/B), I believe you may be able to use this and avoid Uninstalling Magisk w/ OTA updates going forward... Please read / understand my post above and John's ota.md document...

😜 PW
[Magisk] zgfg:
I don't see anything unclear/misunderstanding

Boot img (originally extracted or already patched by Magisk) contains important info that must match your booting firmware

Before April OTA, you are still on March firmware. Hence if you have to flash back your original boot.img (if your phone fails OTA when it finds Magisk), it has to be the March boot.img

Five minutes later, upon you upgraded to April OTA, when patching and flashing the boot.img, it must be the April boot.img

March firmware (still before OTA) will not boot with the boot.img extracted from the newer April firmware

April firmware will not boot if you patched and flashed the old March boot.img

Because the March boot.img does not match April firmware or vice versa

----

But the following IS misunderstanding;:

- Maybe I overlooked but you didn't provide info about your phone, model, etc

--This is general Magisk thread and not a thread about OTA updates on Pixel, OTA updates on XPeria or who knows

Eg, on my Xiaomi, I do not need to go back to the original boot.img before OTA. I can do OTA update with the boot.img that was patched by Magisk. I only need to have the original Recovery (not TWRP) for OTA

But on some One Plus, Samsung, things might be different:

- is it required to use unpatched boot.img before going to OTA (since for you, OTA would otherwise fail)

- how, where from would you obtain/extract boot.img for your firmware, etc
[Magisk] garfield03:
Thank you both for your answers

Now i understand what to do before taking OTA to avoid issue with magisk.

For the record i ask my question on this thread because i had an issue with magik which didn't work anymore after i install an OTA. it failed each time i tried to pach my new boot.img.

I didn't know where was the issue but then i realised that the only thing that could explain that was the update.

I fix the problem with a clean install. The fact was i wanted to know how to proceed to keep magisk working when a firmware update is coming.

The way you proceed with your xiaomi is interesting. For now as fas as i'm concerned i will get back to the original boot.img of my firmware before OTA but asap i will ask the question if i can skip that step on lineage thead for pixel .

Maybe it is the same as your xiaomi

Thanks
[Magisk] badabing2003:
Seeing all this trouble people are experiencing when applying OTA and attempting to retain root (not to mention the specific order of steps to follow and not miss), I'm curious as to why even go to that trouble, isn't it easier / cleaner to just do it through full factory image?

Or is it a matter of being able to do it all on the phone without the need to hook it to a computer?
[Magisk] tramp20:
I too have problems with flashing Magisk 24.303:

The last good build is 24.301.

All 3 flashing/updating methods show installed N/A:

updating with Magisk app (dircet method),

installing the zip with TWRP,

installing the zip to a original boot.img.

My smartphone is +8 years old with RAMDisk yes.
[Magisk] zgfg:
Stock Recovery is needed for stock ROMs OTA upgrades, because the phone reboots to the stock Recovery to perform the upgrade, taking the OTA package that was already (automatically) downloaded by Updater

And in that case, if it is full OTA, and if OTA doesn't check the checksum of the Boot img it finds in the place, Magisk patch in Boot won't cause a trouble because the Recovery will simply flash over the new Boot (like it does for System, Vendor, etc)

However, custom ROMs usually require TWRP to flash/install and in that case you need to stay with TWRP before rebooting to flash the downloaded ROM update zip

Theoretically, TWRP can just overwrite the Boot with the new boot.img (in which case Magisk patch present in the okd Boot should not cause a trouble), but if the ROM's update procedure checks whether a proper/clean Boot is present or if it wants to differentially update the Boot instead of overwriting, then OTA may report an error or in the worst case, cause a bootloop if you didn't provide a clean Boot
[Magisk] kk100:
Banking Apps Not working after Magisk update 24.3

Hello Everyone,

I am using Realme x50 pro 5g RMX2076 11_A_41 Build (Android 10 version).

Recently a Indian banking app was working but in its latest update they have blocked it saying that my device is rooted and will not work.

I am really fed up with all the maintaining my phone. I just want to use my phone and have a little features which I want for Privacy and Security. I don't trust Google For my data. I avoid Google the best I can. I am not an developer or advanced user who can play with custom roms (FYI there is no custom rom for realme x50 pro 5g as per my knowledge)

Titanium backup is now abandoned.

Why can't companies include backup of app and app data?

I am attaching a some screen shots. Please someone see it provide some solution.

Everything is in video the latest Magisk number etc. I can't use banking and credit card app. I have renamed Magisk as Rainbows. After all the process only My Jio (Indian Telecom app) is working which also requires root free device.

I hope someone will see this and provide with some solutions which are user friendly. I am not a developer.

Kindly Help.

Best Wishes
[Magisk] kk100:
Facing the same problem of banking apps in Realme x50 pro.
[Magisk] pndwal:
Well, mismatched boot images will often allow system to boot, but generally with comms (sim, wifi, bt) and many other issues...

For good reason John says this regarding taking stock (delta incremental) OTA updates:

https://github.com/topjohnwu/Magisk/blob/master/docs/ota.md

Nb. This applies whether you have an A/B device and use Install to Inactive Slot (recently fixed) to install Magisk onto OTA updated partitions seamlessly, (preserving it through the update) or not!

... This may have worked for you, but how do you know when parts of the boot image will be updated?

Also, if the average user doesn't use the 'Restore Images' function (and restore partitions altered by other custom mods additionally, eg stock recovery if using TWRP) before taking OTAs, can they (or you) be confident that other partitions (vendor, vbmeta, odm, nvdata, dtbo...) have been properly restored so that a delta update won't fail to update these, or possibly corrupt them?

As I've explained, stock OTA's are invariably 'delta' type and require predicted bit-perfect prior images to update. Further, they are not designed for modders who may have altered any read-only partitions.

They do have protections against modifications, but it seems these checks are largely performed after the update completes in newer A/B block based OTA with streaming support (these are not downloaded, but pushed directly to inactive partition).

https://android.stackexchange.com/q...ifferential-update-image-with-dm-verity-enabl

Really, not restoring images to 'stock' before delta OTAs is risky at best...

😝 PW
[Magisk] pndwal:
FYI:

Basic changes Magisk makes to read-only partitions on your device (Technical):

Magisk always installs to a Ramdisk in a boot image. For Legacy ramdisk devices, boot ramdisk /init is simply replaced with magiskinit as first program to be executed by the kernel. Ie, only ramdisk was changed.

With the first Pixels and System As Root, to quote John, "ramdisk is now stored along with the system partition, and a kernel modification is inevitable." This is to bring back the ramdisk to the boot image, and still do modifications in ramdisk (rootfs). This requires both custom init binary (magiskinit) and a binary patch directly to the kernel. Further, additional dtb patch may be required either to kernel where device tree blob is appended, or separately at end of boot.img and sometimes to separate dtbo or odm partitions...

For newer 2SI devices Magisk installs to (alters) a hybrid ramdisk in boot partition using initramfs as rootdir and executes magiskinit as /init like pre SAR devices. I'm not sure what binary patching of the kernel is needed w/ 2SI, but I'm fairly sure dtb or other patches will be done... Further, fstab (moved out of ramdisk since Oreo) in /vendor /odm or /nvdata (depending on OEM) is also patched w/ 2SI...

👀 PW
[Magisk] pndwal:
Shamiko module and / or Hide My Applist XPosed module + LSPosed may (possibly) help... + check @Didgeridoohan's wiki, 'Hiding' section...

Welcome to the "already lost cat and mouse game"... PW
[Magisk] VD171:
I love this game.

I wrote a guide about how to bypass the detection for unlocked bootloader.

Enjoy

https://xdaforums.com/t/guide-how-to-bypass-detection-for-unlocked-bootloader.4419159/
[Magisk] VD171:
Hiding applist will be deprecated soon.

After Android 12, no one app can read applist.
[Magisk] kk100:
Thanks very much for replying. As mentioned in post I am not a developer. Even rooting the phone was a big issue as there was decryption keys used to do rooting. Some very senior member was kind enough to decrypt my phone build number.

I will look into your suggestions and see what is possible for me.

Thanks again.

Best Wishes
[Magisk] pndwal:
In fact HMA LSPosed module is already suspended; ver 2.3.2 from January was supposedly the last Final Version!

Google Play requires all apps updated after Nov 2021 to adapt Android 11, after which apps should not able to acquire the app list. However apps are still able to do this in Android 11 by using Intent Queries instead of API requests and other tricks... This may well be fixed in Android 12 as you say. PW
[Magisk] pndwal:
Latest Official TJW debug Canary Magisk:​

Magisk (3dc7d77e) (24304)​

Fixed several compatibility issues with magiskinit

Diffs to v24.3​

[MagiskInit] Update 2SI implementation, significantly increase device compatibility (e.g. Sony Xperia devices)

[MagiskInit] Introduce new sepolicy injection mechanism

https://github.com/topjohnwu/magisk-files/blob/a17271415ec0b3b34fbb5715d92893a1f8c529d0/notes.md

👍 PW
[Magisk] m0han:
feedback: updating the usual way (manager) and recommended way (magisk) does not work this time for me. manager installed fine. bootloop after updating magisk. had to go back to 24301 (had only that at hand).
[Magisk] Rokcy98:
I got bootloop too after updating like you did.

For me, bootloop happens when both "Fullscreen/Immersive Gestures (Q-S)" and "Quickswitch" modules are enabled. This did not happen in the previous builds.

Already reported that to GitHub
[Magisk] macoloco:
Me too....having issues with updating to 24.1 to 24.3 (unable detect image...)

i've tried to install canary and latest update.....auto-update through app doesnt work

I've tried to patch boot image (LOS) and save image patched on internal storage, reboot in TWRP , flash boot img (patched one)....reboot normally

open magisk app and then ask me to do an aditional update and reboot.....

once deviced is rebooted, magisk shows installed but asking again this aditional update.....seems not working fine

al my modules dissapered from magisk tab....v4androidfx doesnt work...
[Magisk] macoloco:
Back to 24.1 (latest magisk working) stable
[Magisk] zgfg:
Similarly, on Xiaomi Mi 9T, MIUI 12.5.2, A11

Tried both by patching and later Direct install (update from Canary 24303)

When I reboot with the new Canary 24304, it stays for me forever with the splash screen Redmi, never proceeding to the next screen MIUI

I had to flash my old boot img patched by 24303, to get it booting and working

Since no.uspecial use of the new app 24304, I reinstalled the old app 24303 (to be in sync with the running Canary 24303)

Due to the problem on my Mi 9T and reported bootloop issues by other users, I'm not going to update Canary 24304 on my daily driver Xiaomi 11Lite 5G NE
[Magisk] martyfender:
I have been on Magisk alpha for a while but am considering switching to canary since it now seems to be updated more frequently. Is there any advantage to stay on alpha?
[Magisk] asripath:
Same issue of stuck on redmi logo on 24304 on Raphael ...had to revert to 24301 magisk ...but app still on 24304
[Magisk] zgfg:
I messed up the version numbers in my post - corrected now

Of course, I have also that issue when trying to update from Canary 24303 to 24304
[Magisk] VD171:
People, if you are not sure if you need canary/alpha version, certainly you do NOT need it.

I suggest you to keep on stable version only.

Except if you know exactly what you are doing.
[Magisk] VD171:
topjohnwu is not the only developer on the planet.

If we need something, we build it.

If we need new hiding methods, we will build it.

You need to have more faith, my sheep.

Root is God.

Nothing can overlap root.
[Magisk] Lughnasadh:
Just a heads up for everyone. Aside from the other mods mentioned above, AML also seems to cause bootloops on Canary 24304. Have reported in the AML thread.
[Magisk] VD171:
Canary version is for testing only.
[Magisk] Lughnasadh:
Yes, I know.