
Temporary root exploit for vivo X Fold+ (CVE-2025-21479): GPU physical memory read/write, __do_sys_capset shellcode patch, seccomp/SELinux bypass and KernelSU activation.
In the previous article, I achieved a temporary root shell using the cred method (see my previous post https://www.coolapk.com/feed/73490425?s=NjQ3OWQwNDMxOWJmMzk4ZzZhZjk1ZGNhega1670). However, due to seccomp restrictions, ksu could not be activated. Since I had no suitable approach, activating ksu was put on hold for the time being. Later, @曉曉恒 published a method for the same CPU and same kernel scheme, and that method can clear seccomp.
(Link: https://www.coolapk.com/feed/73486895?s=YjRmZWY2ZmExOWJmMzk4ZzZhYTU1MmJlega1651)
It also references @TNTHe's method.
(Link: https://blog.kinser.top/archives/1787279031701)
However, both of these schemes require patching the global __do_sys_capset
(Community version patch method concept diagram)
patch __do_sys_capset(全局生效)
  ↓
zygote 孵化应用时 specialize → 调用 capset() 降权
  ↓
★ 中招:执行 shellcode → commit_creds(prepare_kernel_cred(0))
  ↓
zygote 被提权成 root + seccomp 被清 + cred 被换成 init_cred 拷贝
(Flowchart of patch causing zygote exceptions)
In other words, this method, as long as it patches the global syscall, has an unavoidable timing race + hardcoded offset risk. zygote will inevitably be caught in the crossfire. And over time it may cause a kernel panic, but compared with the cred method, it can clear seccomp; for this reason, I added a safer recovery mechanism based on the patch method.
GPU physical write task_struct->cred, modifying fields such as uid/gid/suid to escalate privileges. This path has always been successful.
To clear seccomp, you must write the mode/filter fields of task_struct (0x848/0x850).
| Data | Access Frequency | Description |
| --- | --- | --- |
| cred | cold data | read only during permission checks |
| task_struct | extremely hot | accessed on every system call/scheduling/signal |
current->flags is being read and written by the CPU on every system call, and this page has a dirty line resident in L1/L2. The GPU is a non-coherent bus master; after it writes into DRAM, the CPU's next normal write-back swallows the entire line (64 bytes).
mode@0x848 and filter@0x850 happen to be in the same cache line, so they are overwritten together — all 8 retries result in 0x100000002.
GPU writes occasionally take partial effect (the filter lands, but the mode does not), creating a self-contradictory state:
mode = 2 (FILTER) // 内核仍要走过滤器
filter = 坏值/NULL // 指针已被破坏
The next system call enters __seccomp_filter() and executes the broken BPF → returns KILL → "Bad system call"
Friendly reminder: some new content, such as save, exists in my iterative version and may differ from the community version
| Step | Action | Description |
| --- | --- | --- |
| 1 | GPU initialization | Gain physical address read/write capability |
| 2 | Disable SELinux | Physical write to selinux_state |
| 3 | kallsyms resolution | Read the 43MB kernel image and resolve symbols |
| 4 | Locate __do_sys_capset | VA → PA |
| 5 | Save the original code | Authoritative GPU read |
| 6 | Write gated shellcode | CPU window write + cache flush |
| 7 | Current process capset(NULL,NULL) | Trigger |
| 8 | Shellcode executes in kernel mode | prepare_kernel_cred(0) → commit_creds() |
| 9 | Restore the original code | CPU write + authoritative GPU verification |
| 10 | Tear down the fast_rw window | GPU write + verification |
| 11 | exec shell | — |
__do_sys_capset?Because this is the system call entry point, it can be precisely triggered from user space, and it is necessarily executed on every call
The physical address is predictable: 0xa8000000 + 0x16c7bc = 0xa816c7bc (the kernel physical base address is fixed; KASLR only changes the virtual base address, and most in the community use this, with plenty of examples)
uint64_t v = kernel_pread_u64(cheese, 0xa816c7bc);
if ((uint32_t)v == 0xd503233f) /* paciasp = __do_sys_capset 首指令 */
  /* 不需要 kallsyms 就能定位! */
Only when prepare_kernel_cred / commit_creds are called from within the shellcode is the KASLR virtual base address required.
zygote 在 specializeAppProcess 里
【每孵化一个 APP 都调 capset(&hdr,&data) 降权】
  ↓ 社区 shellcode 无条件执行
prepare_kernel_cred(0) → commit_creds()
  ↓ 每次命中
zygote 的 cred 被换掉 + cred_jar 泄漏一个 → 越用越崩 → 无法新开应用
"Anomalies increasing over time" is precisely the cumulative effect of the continuous cred_jar leak and the corrupted reference counting.
To address this, this version adds a gating mechanism (solving the zygote breakage): only capset(NULL,NULL) triggers privilege escalation; when zygote passes a non-NULL pointer, it takes the skip path. The community edition escalates unconditionally, causing zygote to be mistakenly escalated every time it spawns an APP plus leak one cred → the more it is used, the more it crashes.
| Comparison Item | Community Edition | This Version |
| --- | --- | --- |
| zygote calls capset(&hdr,&data) | Unconditional escalation | Takes skip, returns 0 |
| cred allocation | Leaks one per spawn | No allocation, zero leak |
| App uid/gid | Affected | Unaffected (set by setuid/setgid) |
When overwriting contiguously in place, non-target paths must replay all N overwritten instructions before jumping back, while the shellcode itself has only N slots, which cannot hold "replay N instructions + gating + payload" — mathematically impossible, so an in-kernel trampoline is required.
Therefore the skip path returns 0. This is consistent with the community edition's behavior toward zygote (both are "capset returns 0"), but removes the privilege escalation and cred allocation; the APP's uid/gid is set via setuid / setgid (not capset), so app permissions are unaffected.
This is the most tortuous part of the entire process, only closed after many failures. Because validation was added and the process fixed, the privilege escalation time was also extended to 3~4 minutes.
| No. | Failure | Symptom | Root Cause | Fix |
| --- | --- | --- | --- | --- |
| 1 | False success | Validation all green, DRAM untouched | CPU reads its own dirty cache line | Switched to authoritative GPU read |
| 2 | Wrong cache level | GPU cannot read new value | dc cvau only reaches PoU | Changed to dc cvac (reaches PoC) |
| 3 | No external validation | Cannot prove it has been written to disk | Missing GPU perspective | Added patch_verify_bytes_gpu() |
| 4 | fork breaks everything | restore inevitably fails | COW + GPU channel death | Privilege escalation no longer forks |
patch_verify_bytes() → fast_pread_u64() // CPU 通过窗口读
As soon as the write finishes, it is read back with the CPU, and what is read is the cache line that was just dirtied by the write itself, which always equals the expected value. The logs stay green the whole way, and DRAM is never touched.
Hard evidence: on the second run, save reads back the shellcode rather than the original code.
"dc cvau, %0" // clean by VA to PoU(本核 L2/统一点)
GPU is an external bus master and accesses the PoC (DRAM). cvau cannot clean to DRAM.
Fix: dc cvau → dc cvac (clean to PoC).