# sys_fsc2h_ctrl kernel stack free

Race in PS5 syscall sys_fsc2h_ctrl lets a waiter free a pointer that actually references another thread's kernel stack, enabling use-after-free and privilege escalation.

- Payout: $10,000
- Severity: high
- Program: PlayStation
- Found by: theflow0
- Disclosed: 2025-04-18
- Write-up quality: 8/10
- Original: https://hackerone.com/reports/2900606
- Library page: https://bugbountylibrary.com/r/h1%3A2900606
- Tags: area:oss domain:oss impact:integrity impact:privesc kind:bounty platform:hackerone sev:high technique:race-window technique:source-review vuln:memory-corruption vuln:privilege-escalation vuln:race-condition

**Target:** PS5 kernel syscall sys_fsc2h_ctrl
**Root cause:** CMD_RESOLVE stores a pointer to a local stack buffer into the shared path object; a concurrent CMD_WAIT frees that path before CMD_RESOLVE finishes, so free() is applied to a kernel stack address rather than a heap allocation.
**Steps:**
1. Thread 1: call `sys_fsc2h_ctrl(CMD_WAIT=0x10001)` waiting on path 1
2. Thread 2: call `sys_fsc2h_ctrl(CMD_WAIT=0x10001)` waiting on path 2
3. Thread 3: call `sys_fsc2h_ctrl(CMD_RESOLVE=0x20005)` on path 2, which sets path 2's pointer to a local stack buffer and sleeps
4. Thread 4: call `sys_fsc2h_ctrl(CMD_COMPLETE=0x20003)` writing data into that stack buffer and waking thread 3
5. Arrange thread 2 to wake before thread 3 so it frees path 2 (a kernel stack pointer)
**How found:** Reasoned about the shared path object across four concurrent syscall commands: CMD_RESOLVE temporarily aliases a stack buffer into the path, and a racing CMD_WAIT frees it, revealing the stack-pointer-as-heap-pointer confusion.
**Exploitation:** Race ordering between CMD_COMPLETE waking thread 3 and thread 2's waiter causes free() of a kernel stack address, producing a use-after-free of kernel stack memory that can be leveraged for privilege escalation.
**Insight:** When a syscall stores a pointer to a local stack buffer into a shared/global object, check whether any concurrent path can free or replace that object before the stack frame is done using it.

