ElderDrivers / EdXposed

Elder driver Xposed Framework.
https://edxp.meowcat.org/
GNU General Public License v3.0
5.43k stars 625 forks source link

[BUG] mmap Permission Denied & modules.list | Latest version of: Magisk, Riru (v21.3), EdXposed #627

Closed mundicristal closed 3 years ago

mundicristal commented 3 years ago

Magisk Version: Magisk: Latest dc5e78e1 (21006) Canary Magisk Manager: Latest 2739d3cb (313) (13)

Magisk Modules: Riru - Core v21.3 Riru - EdXposed Latest v0.5.0.6 (4564) YAHFA Canary SELinux Permissive v2 (Tested with enabled and disabled) Busybox for Android NDK (Tested with enabled and disabled) Systemless Hosts (Tested with enabled and disabled)

EdXposed Manager: Version: Latest v4.5.7 (45700)

EdXposed Modules: HiddenCore Module (Removed for test) NFC Catch-All-Routing

Android 10 Q API 29

Module Error Log:

EdXposed version: v0.5.0.6-android_r (4564) (YAHFA)
EdXposed api: 91.0
Riru version: v21.3 (36)
Riru api: 7
Magisk: dc5e78e1 (21006)
--------- beginning of main
--------- beginning of system
11-11 09:41:01.745  5474  5474 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 09:41:05.984  6102  6102 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 09:42:19.649  6103  6103 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found

Verbose Error Log:

EdXposed version: v0.5.0.6-android_r (4564) (YAHFA)
EdXposed api: 91.0
Riru version: v21.3 (36)
Riru api: 7
Magisk: dc5e78e1 (21006)
--------- beginning of main
--------- beginning of system
11-11 09:41:00.506  5474  5474 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 09:41:00.506  5474  5474 I EdXposed: Start to install inline hooks
11-11 09:41:00.506  5474  5474 I EdXposed: Using api level 29
11-11 09:41:00.506  5474  5474 I EdXposed: Start to install Riru hook
11-11 09:41:00.520  5474  5474 I EdXposed: Riru hooks installed
11-11 09:41:00.534  5474  5474 I EdXposed: dlopen hooked
11-11 09:41:00.578  5474  5474 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 09:41:00.578  5474  5474 I EdXposed: data path prefix: /data/user_de/0/
11-11 09:41:00.578  5474  5474 I EdXposed:   application list mode: false
11-11 09:41:00.578  5474  5474 I EdXposed:     using whitelist: false
11-11 09:41:00.578  5474  5474 I EdXposed:   dynamic modules mode: false
11-11 09:41:00.578  5474  5474 I EdXposed:   resources hook: false
11-11 09:41:00.578  5474  5474 I EdXposed:   deopt boot image: false
11-11 09:41:00.578  5474  5474 I EdXposed:   no module log: false
11-11 09:41:00.578  5474  5474 I EdXposed:   hidden api bypass: true
11-11 09:41:00.585  5474  5474 I EdXposed: ART hooks installed
11-11 09:41:00.585  5474  5474 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 09:41:00.585  5474  5474 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 09:41:00.602  5475  5475 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 09:41:00.602  5475  5475 I EdXposed: Start to install inline hooks
11-11 09:41:00.602  5475  5475 I EdXposed: Using api level 29
11-11 09:41:00.602  5475  5475 I EdXposed: Start to install Riru hook
11-11 09:41:00.621  5475  5475 I EdXposed: Riru hooks installed
11-11 09:41:00.629  5475  5475 I EdXposed: dlopen hooked
11-11 09:41:00.664  5475  5475 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 09:41:00.664  5475  5475 I EdXposed: data path prefix: /data/user_de/0/
11-11 09:41:00.664  5475  5475 I EdXposed:   application list mode: false
11-11 09:41:00.664  5475  5475 I EdXposed:     using whitelist: false
11-11 09:41:00.664  5475  5475 I EdXposed:   dynamic modules mode: false
11-11 09:41:00.664  5475  5475 I EdXposed:   resources hook: false
11-11 09:41:00.664  5475  5475 I EdXposed:   deopt boot image: false
11-11 09:41:00.664  5475  5475 I EdXposed:   no module log: false
11-11 09:41:00.664  5475  5475 I EdXposed:   hidden api bypass: true
11-11 09:41:00.666  5475  5475 I EdXposed: ART hooks installed
11-11 09:41:00.666  5475  5475 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 09:41:00.666  5475  5475 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 09:41:01.745  5474  5474 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 09:41:02.054  5947  5947 E EdXposed: mmap failed, errno = Permission denied
11-11 09:41:02.054  5947  5947 E EdXposed: cannot hook method
11-11 09:41:02.055  5947  5947 E EdXposed: error when hooking com.elderdrivers.riru.edxp._hooker.yahfa.StartBootstrapServicesHooker
11-11 09:41:02.055  5947  5947 E EdXposed: java.lang.RuntimeException: Failed to hook private void com.android.server.SystemServer.startBootstrapServices() with public static void com.elderdrivers.riru.edxp._hooker.yahfa.StartBootstrapServicesHooker.hook(java.lang.Object) throws java.lang.Throwable
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.elderdrivers.riru.edxp.core.yahfa.HookMain.backupAndHook(HookMain.java:138)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.elderdrivers.riru.edxp.core.yahfa.HookMain.doHookDefault(HookMain.java:3097)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.elderdrivers.riru.edxp.proxy.BaseRouter.startSystemServerHook(BaseRouter.java:142)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.elderdrivers.riru.edxp._hooker.impl.SystemMain.afterHookedMethod(SystemMain.java:27)
11-11 09:41:02.055  5947  5947 E EdXposed:  at de.robv.android.xposed.XC_MethodHook.callAfterHookedMethod(XC_MethodHook.java:68)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.elderdrivers.riru.edxp._hooker.yahfa.SystemMainHooker.hook(SystemMainHooker.java:28)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.android.server.SystemServer.createSystemContext(SystemServer.java:1011)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.android.server.SystemServer.run(SystemServer.java:877)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.android.server.SystemServer.main(SystemServer.java:725)
11-11 09:41:02.055  5947  5947 E EdXposed:  at java.lang.reflect.Method.invoke(Native Method)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:496)
11-11 09:41:02.055  5947  5947 E EdXposed:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1078)
mundicristal commented 3 years ago

Is there a specific version that must be used for EdXposed to work?

incapdns commented 3 years ago

Here is also the same problem, I'm using virtual machine (Emulator)

kotori2 commented 3 years ago

That's a SELinux issue, which should be fixed here. Make sure you are using canary Magisk.

kotori2 commented 3 years ago

@kotori2 *canary Magisk=There was a bug which you should reboot twice to make SELinux applied

mundicristal commented 3 years ago

That's a SELinux issue, which should be fixed here. Make sure you are using canary Magisk.

As I am already using the latest version, I checked the patch you provided and found only a few changes to the selinux policy (sepolicy.rule).

In this case I must uninstall EdXposed-YAHFA-v0.5.0.6 and change sepolicy.rule and add the lines:

Allow system_server system_server process execmem
allow system_server system_server memprotect mmap_zero
allow coredomain coredomain process execmem

?

mundicristal commented 3 years ago

I will do the test now.

mundicristal commented 3 years ago

@kotori2 *canary Magisk=There was a bug which you should reboot twice to make SELinux applied

I updated the files (according to the patch you sent "sepolicy.rule" | "update-binary"). But the problem has not been solved

  1. I uninstalled EdXposed (Latest canary version)
  2. Restart your phone
  3. I edited the .zip and applied the patch
  4. I installed the modified .zip and restarted (Bixby + Up + Power)
  5. After restarting I cleared the EdXposed logs
  6. Restarted again (Bixby + Up + Power)
  7. The error remains
kotori2 commented 3 years ago

Bixby

I've heard that sepolicy or even switch to permissive mode won't work on Samsung phone. Check your logs to see if sepolicy loaded correctly.

mundicristal commented 3 years ago

I can't set it to "permissive" (setenforce 0 not works), but how do I check if the supolicy --live has been applied?

kotori2 commented 3 years ago

@mundicristal It should not be applied as supolicy --live because it is a fallback. You can’t set it to permissive because Samsung restricted it.

mundicristal commented 3 years ago

Update: After editing the file "post-fs-data.sh" I configured lines 49 to 54 (supolicy) to be the same as sepolicy.rule and the "mmap permission denied" error disappeared (apparently resolved)

But now I keep getting the error: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found

kotori2 commented 3 years ago

ALL LOGS SINCE BOOT PLEASE

mundicristal commented 3 years ago

After update: [Verbose Log]

--------- beginning of head
EdXposed Log
Powered by Log Catcher
QQ support group: 855219808
Telegram support group: @Code_Of_MeowCat
Telegram channel: @EdXposed
--------- beginning of information
Manufacturer: samsung
Brand: samsung
Device: beyond2
Product: beyond2lte
Model: SM-G975F
Fingerprint: samsung/beyond2ltexx/beyond2:10/QP1A.190711.020/G975FXXS9DTI8:user/release-keys
ROM description: beyond2ltexx-user 10 QP1A.190711.020 G975FXXS9DTI8 release-keys
Architecture: arm64-v8a
Android build: QP1A.190711.020
Android version: 10
Android sdk: 29
EdXposed version: v0.5.0.6-android_r (4564) (YAHFA)
EdXposed api: 91.0
Riru version: v21.3 (36)
Riru api: 7
Magisk: dc5e78e1 (21006)
--------- beginning of main
--------- beginning of system
11-11 11:13:39.691  5475  5475 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 11:13:39.692  5475  5475 I EdXposed: Start to install inline hooks
11-11 11:13:39.692  5475  5475 I EdXposed: Using api level 29
11-11 11:13:39.692  5475  5475 I EdXposed: Start to install Riru hook
11-11 11:13:39.709  5475  5475 I EdXposed: Riru hooks installed
11-11 11:13:39.724  5475  5475 I EdXposed: dlopen hooked
11-11 11:13:39.763  5476  5476 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 11:13:39.763  5476  5476 I EdXposed: Start to install inline hooks
11-11 11:13:39.763  5476  5476 I EdXposed: Using api level 29
11-11 11:13:39.763  5476  5476 I EdXposed: Start to install Riru hook
11-11 11:13:39.772  5475  5475 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 11:13:39.773  5475  5475 I EdXposed: data path prefix: /data/user_de/0/
11-11 11:13:39.773  5475  5475 I EdXposed:   application list mode: false
11-11 11:13:39.773  5475  5475 I EdXposed:     using whitelist: false
11-11 11:13:39.773  5475  5475 I EdXposed:   dynamic modules mode: false
11-11 11:13:39.773  5475  5475 I EdXposed:   resources hook: false
11-11 11:13:39.773  5475  5475 I EdXposed:   deopt boot image: false
11-11 11:13:39.773  5475  5475 I EdXposed:   no module log: false
11-11 11:13:39.773  5475  5475 I EdXposed:   hidden api bypass: true
11-11 11:13:39.776  5475  5475 I EdXposed: ART hooks installed
11-11 11:13:39.777  5475  5475 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 11:13:39.777  5475  5475 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 11:13:39.781  5476  5476 I EdXposed: Riru hooks installed
11-11 11:13:39.792  5476  5476 I EdXposed: dlopen hooked
11-11 11:13:39.838  5476  5476 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 11:13:39.838  5476  5476 I EdXposed: data path prefix: /data/user_de/0/
11-11 11:13:39.838  5476  5476 I EdXposed:   application list mode: false
11-11 11:13:39.838  5476  5476 I EdXposed:     using whitelist: false
11-11 11:13:39.838  5476  5476 I EdXposed:   dynamic modules mode: false
11-11 11:13:39.838  5476  5476 I EdXposed:   resources hook: false
11-11 11:13:39.838  5476  5476 I EdXposed:   deopt boot image: false
11-11 11:13:39.838  5476  5476 I EdXposed:   no module log: false
11-11 11:13:39.838  5476  5476 I EdXposed:   hidden api bypass: true
11-11 11:13:39.841  5476  5476 I EdXposed: ART hooks installed
11-11 11:13:39.841  5476  5476 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 11:13:39.842  5476  5476 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 11:13:41.157  5475  5475 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 11:13:44.467  6152  6152 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 11:13:44.467  6152  6152 I EdXposed: Start to install inline hooks
11-11 11:13:44.467  6152  6152 I EdXposed: Using api level 29
11-11 11:13:44.467  6152  6152 I EdXposed: Start to install Riru hook
11-11 11:13:44.481  6152  6152 I EdXposed: Riru hooks installed
11-11 11:13:44.484  6152  6152 I EdXposed: dlopen hooked
11-11 11:13:44.490  6152  6152 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 11:13:44.490  6152  6152 I EdXposed: data path prefix: /data/user_de/0/
11-11 11:13:44.490  6152  6152 I EdXposed:   application list mode: false
11-11 11:13:44.490  6152  6152 I EdXposed:     using whitelist: false
11-11 11:13:44.490  6152  6152 I EdXposed:   dynamic modules mode: false
11-11 11:13:44.490  6152  6152 I EdXposed:   resources hook: false
11-11 11:13:44.490  6152  6152 I EdXposed:   deopt boot image: false
11-11 11:13:44.490  6152  6152 I EdXposed:   no module log: false
11-11 11:13:44.490  6152  6152 I EdXposed:   hidden api bypass: true
11-11 11:13:44.490  6152  6152 I EdXposed: ART hooks installed
11-11 11:13:44.491  6152  6152 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 11:13:44.491  6152  6152 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 11:13:44.523  6153  6153 I EdXposed: onModuleLoaded: welcome to EdXposed!
11-11 11:13:44.523  6153  6153 I EdXposed: Start to install inline hooks
11-11 11:13:44.523  6153  6153 I EdXposed: Using api level 29
11-11 11:13:44.523  6153  6153 I EdXposed: Start to install Riru hook
11-11 11:13:44.537  6153  6153 I EdXposed: Riru hooks installed
11-11 11:13:44.540  6153  6153 I EdXposed: dlopen hooked
11-11 11:13:44.546  6153  6153 I EdXposed: using installer org.meowcat.edxposed.manager
11-11 11:13:44.546  6153  6153 I EdXposed: data path prefix: /data/user_de/0/
11-11 11:13:44.546  6153  6153 I EdXposed:   application list mode: false
11-11 11:13:44.546  6153  6153 I EdXposed:     using whitelist: false
11-11 11:13:44.546  6153  6153 I EdXposed:   dynamic modules mode: false
11-11 11:13:44.546  6153  6153 I EdXposed:   resources hook: false
11-11 11:13:44.546  6153  6153 I EdXposed:   deopt boot image: false
11-11 11:13:44.546  6153  6153 I EdXposed:   no module log: false
11-11 11:13:44.546  6153  6153 I EdXposed:   hidden api bypass: true
11-11 11:13:44.547  6153  6153 I EdXposed: ART hooks installed
11-11 11:13:44.547  6153  6153 I EdXposed: system_property_get: dalvik.vm.dex2oat-filter -> 
11-11 11:13:44.547  6153  6153 I EdXposed: system_property_get: dalvik.vm.dex2oat-flags -> --inline-max-code-units=0
11-11 11:13:45.154  6152  6152 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 11:14:09.501  6153  6153 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 11:14:27.677  6837  6837 D EdXposedManager: ApplicationList: Force add modules to list
11-11 11:18:58.771  6837 13043 D EdXposedManager: ApplicationList -> generateCheckedList: generate done
11-11 11:19:14.150  6837  6837 I EdXposedManager: ModuleUtil -> updating modules.list
--------- beginning of crash
kotori2 commented 3 years ago

That doesn't work. Get logs with adb and USB cable. I strongly suspect it's a Magisk bug, so I need Magisk's log.

mundicristal commented 3 years ago

That doesn't work. Get logs with adb and USB cable. I strongly suspect it's a Magisk bug, so I need Magisk's log.

One second plz, i will put USB (adb logcat -f)

mundicristal commented 3 years ago

Logcat.txt: https://drive.google.com/file/d/1vixNu4Q9I26TyjJCor8xThX3mQUftDfv/view?usp=sharing Magisk.log: https://drive.google.com/file/d/1Hf5K-JuyjJBZ_tlGdaFl_QYSzjOttf1Z/view?usp=sharing

kotori2 commented 3 years ago

Yes, sepolicy is not loaded. Please file a bug report to Magisk.

mundicristal commented 3 years ago

Yes, sepolicy is not loaded. Please file a bug report to Magisk.

Ok thanks, I will forward the logs to Magisk.

mundicristal commented 3 years ago

Sorry, it looks like I sent the full logcat, after updating the EdXposed module I didn't clear the logs (adb logcat -c), now I cleared the logs and ran EdXposed and generated an updated logcat, and also generated the updated Magisk.log

I searched these logs for selinux errors and couldn't find them (I'm not very good at linux, but I believe there is no permission error in this updated log). You can check the updated logs again just in case of doubt, I'm afraid the error is in EdXposed.

Procedures performed (There was no reinstallation, just restarted to check):

  1. adb locat -c
  2. I restarted the phone
  3. I reopened EdXposed (and confirmed that "modules.list" is still inaccessible)
  4. I generated the magisk & logcat

Logcat.txt: https://drive.google.com/file/d/1KhBDA_rjWasosh5EmoQAr6eRqdzjnW02/view?usp=sharing Magisk.log: https://drive.google.com/file/d/17osteU-EpUb4fDyB8JD7MNtE7qjnXHWG/view?usp=sharing

kotori2 commented 3 years ago
11-11 12:21:47.648  5401  5401 E EdXposed-Bridge: Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found
11-11 12:21:47.648  5261  5261 E audit   : type=1400 audit(1605108107.643:3910): avc:  denied  { search } for  pid=5401 comm="main" name="org.meowcat.edxposed.manager" dev="sda31" ino=3342841 scontext=u:r:zygote:s0 tcontext=u:object_r:app_data_file:s0:c512,c768 tclass=dir permissive=0 SEPF_SM-G975F_10_0020 audit_filtered
mundicristal commented 3 years ago

Hmm, I understand. Thanks for showing the line, it already makes opening of the issue Magisk a lot easier Thanks again for your time, and I'm sorry for my english.

sn-o-w commented 3 years ago

I think I have this problem too, at least "mmap Permission Denied" and I'm not sure if Magisk is responsible for this (I use latest canary version).

I followed these instructions https://github.com/ElderDrivers/EdXposed/issues/627#issuecomment-725447828 and it seems like I got rid of this error:

Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found

But I still get "mmap failed, errno = Permission denied" with sepolicy set to enforcing.

Perhaps these logs are useful: magisk_log_20201112_201630---selinux_enforcing.log logcat-2020-11-12_201349---selinux_enforcing.txt edxposed-verbose---selinux_enforcing.log

What is interesting is that everything seems fine with EdXposed if I set sepolicy to permissive: edxposed-verbose---selinux_permissive.log

But switching sepolicy to permissive is a terrible idea for the long term, so I hope things can get fixed.

kotori2 commented 3 years ago

But switching sepolicy to permissive is a terrible idea for the long term, so I hope things can get fixed.

It simply won't work because permissive script always comes too late. So we (or Magisk) smh have to fix this.

mundicristal commented 3 years ago

I think I have this problem too, at least "mmap Permission Denied" and I'm not sure if Magisk is responsible for this (I use latest canary version).

I followed these instructions #627 (comment) and it seems like I got rid of this error:

Cannot load any modules because /data/user_de/0/org.meowcat.edxposed.manager/conf/modules.list was not found

But I still get "mmap failed, errno = Permission denied" with sepolicy set to enforcing.

Perhaps these logs are useful: magisk_log_20201112_201630---selinux_enforcing.log logcat-2020-11-12_201349---selinux_enforcing.txt edxposed-verbose---selinux_enforcing.log

What is interesting is that everything seems fine with EdXposed if I set sepolicy to permissive: edxposed-verbose---selinux_permissive.log

But switching sepolicy to permissive is a terrible idea for the long term, so I hope things can get fixed.

I installed the LineageOS ROM and activated selinux (Enforcing), the "magiskpolicy" policies worked correctly on the LineageOS ROM, I also tested on other AOPS also successfully.

I'm afraid it's something in the S10 + Exynos kernel [SM-G975F] (something in the latest firmware update)

I already knew the restriction of not being able to set "permissive" on the S10 + Exynos (SM-G975F) by Samsung Kernel, but I didn't think it would affect the use of Magisk (magiskpolicy / supolicy)

sn-o-w commented 3 years ago

I installed the LineageOS ROM and activated selinux (Enforcing), the "magiskpolicy" policies worked correctly on the LineageOS ROM, I also tested on other AOPS also successfully.

I'm afraid it's something in the S10 + Exynos kernel [SM-G975F] (something in the latest firmware update)

I already knew the restriction of not being able to set "permissive" on the S10 + Exynos (SM-G975F) by Samsung Kernel, but I didn't think it would affect the use of Magisk (magiskpolicy / supolicy)

Have you checked your EdXposed logs? Do you see "mmap failed, errno = Permission denied" in your logs? I don't own SAMSUNG device and I still get error "mmap failed, errno = Permission denied".

Logs I attached are from a Nexus 5 device.