Magisk icon indicating copy to clipboard operation
Magisk copied to clipboard

/sys/fs/pstore is empty after kernel crash

Open powellnorma opened this issue 2 years ago • 16 comments

When I trigger a kernel crash via echo c > /proc/sysrq-trigger, normally /sys/fs/pstore gets filled with 3 files:

sunfish:/ # ls /sys/fs/pstore/                                                                                                                                                                
console-ramoops-0  dmesg-ramoops-0  pmsg-ramoops-0

But when Magisk is installed, this folder stays empty.

What I noticed is that normally only after pin unlock pstore gets mounted:

pstore on /sys/fs/pstore type pstore (rw,seclabel,relatime)

But with magisk, something pstore related is already mounted before that stage:

pstore on /debug_ramdisk/.magisk/mirror/sys/fs/pstore type pstore (rw,seclabel,nosuid,nodev,noexec,relatime)

And after unlock:

pstore on /debug_ramdisk/.magisk/mirror/sys/fs/pstore type pstore (rw,seclabel,nosuid,nodev,noexec,relatime)
pstore on /sys/fs/pstore type pstore (rw,seclabel,relatime)

magisk.log dmesg.log

Device: Pixel4a Android version: 13 Magisk version name: 26.3 Magisk version code: 26301

powellnorma avatar Sep 13 '23 14:09 powellnorma

Same issue here with Pixel 4a device. /sys/fs/pstore seems to always be empty even after a kernel crash.

Device: Pixel 4a Android Version: 10 Magisk version: 26.1

kaiyu92 avatar Sep 15 '23 07:09 kaiyu92

I don't think it has anything to do with magisk.

vvb2060 avatar Sep 16 '23 15:09 vvb2060

I don't think it has anything to do with magisk.

I tested several times: When not using magisk /sys/fs/pstore gets filled, when using it /sys/fs/pstore stays empty.

powellnorma avatar Sep 16 '23 19:09 powellnorma

How to panic the kernel without root?

vvb2060 avatar Sep 16 '23 19:09 vvb2060

In a debug build, one can use adb root

powellnorma avatar Sep 16 '23 19:09 powellnorma

After you install magisk, is adb root still available?

vvb2060 avatar Sep 16 '23 19:09 vvb2060

I think so, since afaik adb root has nothing to do with magisk. Why are you asking though? If adb root does not work for you, you probably have a -user build. LineageOS usually provides -userdebug builds.

powellnorma avatar Sep 16 '23 19:09 powellnorma

Have you tried it? If you have some magisk modules, adb root will not be available, kmsg may be for similar reasons. (You know, the device is user build now)

vvb2060 avatar Sep 16 '23 19:09 vvb2060

Have you tried it? If you have some magisk modules, adb root will not be available

Yes, adb root still works - I have just double checked it

powellnorma avatar Sep 16 '23 19:09 powellnorma

I have found a solution that works for my device:

Add umount("/sys/fs/pstore"); before the "mirror mounting" logic:

https://github.com/topjohnwu/Magisk/blob/15e13a8d8bb61ed896df94881d63903cbfcc516b/native/src/core/bootstages.cpp#L97-L98

My guess is that the system clears up the pstore of "two mounts before" it. Because I also tried to mount it again after the mirror logic (via mount("pstore", "/sys/fs/pstore", "pstore", 0, "");), and then pstore again stays empty.

I think the best solution would be to not use MS_REC, and instead always use the fallback logic, and then skip the mirror mount if info.type == "pstore".

powellnorma avatar Sep 23 '23 12:09 powellnorma

Not using MS_REC is not a good solution. Maybe you should try to move pstore into somewhere unbindable, then mount mirror MS_REC and move pstore back.

yujincheng08 avatar Sep 24 '23 02:09 yujincheng08

After investigation, I found that if umount pstore in boot_complete and then mount pstore after unlock screen, files will exist.

vvb2060 avatar Sep 25 '23 19:09 vvb2060

~~Can confirm that same thing happens on Xiaomi Mi 11 Lite 5G NE (lisa). What exactly is the cause here?~~ Edit: This seems to have been a fluke on this device. Disregard.

Ristovski avatar Oct 20 '23 18:10 Ristovski

https://android.googlesource.com/kernel/msm/+/b71d012395a42ae6b58f36f5eaf460a9ff29e31a%5E%21/

yujincheng08 avatar Oct 24 '23 15:10 yujincheng08

Try #7685

yujincheng08 avatar Jan 04 '24 17:01 yujincheng08

The pstore is decrypted when the user first unlocks device, at which point no pstore instance can exist. Decryption will fail if a pstore bind mount exists, or if a unshared process retains a pstore instance.

vvb2060 avatar Jan 07 '24 05:01 vvb2060