Skip to content
Race condition Disclosed report Advanced

sys_fsc2h_ctrl kernel stack free

A race condition in the sys_fsc2h_ctrl syscall lets one thread free a pointer that actually points to another thread's kernel stack buffer. An attacker could use this to escalate privileges.

Andy Nguyen Follow

Originally disclosed on HackerOne

Bounty$10,000 High View original
  • Disclosed after 4 months

Summary by the program

Summary

It is possible to cause a kernel stack free in the syscall sys_fsc2h_ctrl.

Consider 4 threads: Thread 1: The command CMD_WAIT (0x10001) in sys_fsc2h_ctrl waits for path 1. Thread 2: The command CMD_WAIT (0x10001) in sys_fsc2h_ctrl waits for path 2. Thread 3: The command CMD_RESOLVE (0x20005) in sys_fsc2h_ctrl sets the pointer of path 2 to a local stack buffer and sleeps. Thread 4: The command CMD_COMPLETE (0x20003) in sys_fsc2h_ctrl writes data into that local stack buffer and wakes up the thread 3. Thread 2: This thread wakes up before thread 3 and it will free path 2. However, that is not a malloc() allocation, but it is actually a pointer to kernel stack.

Impact

Privilege escalation.

The original report as published on HackerOne, by theflow0. Images and videos are our own copies; raw HTML is shown as text. View it on HackerOne.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 5 min read.

What the report shows

The target is the PlayStation 5, and the feature under examination is the system call sys_fsc2h_ctrl. The researcher found that this syscall can be driven into freeing a buffer that lives on the kernel stack, a use-after-free condition that the report classifies as a kernel stack free. The program rated the issue high severity, paid a bounty of 10,000 USD, and disclosed the report on 18 April 2025.

The report describes the bug through the interaction of four threads issuing commands to the same syscall. The commands and their values are given as follows:

Text
CMD_WAIT (0x10001)
CMD_RESOLVE (0x20005)
CMD_COMPLETE (0x20003)

The sequence the researcher lays out is:

  1. Thread 1 issues CMD_WAIT (0x10001) in sys_fsc2h_ctrl and waits for path 1.
  2. Thread 2 issues CMD_WAIT (0x10001) in sys_fsc2h_ctrl and waits for path 2.
  3. Thread 3 issues CMD_RESOLVE (0x20005) in sys_fsc2h_ctrl, which sets the pointer of path 2 to a local stack buffer, and then sleeps.
  4. Thread 4 issues CMD_COMPLETE (0x20003) in sys_fsc2h_ctrl, which writes data into that local stack buffer and wakes up thread 3.
  5. Thread 2 wakes up before thread 3 and frees path 2. That pointer is not a malloc() allocation; it points into the kernel stack.

The report does not describe the fix, and it does not give the exact data written by CMD_COMPLETE or the size of the stack buffer.

Root cause

The mistake the report points to is a lifetime and ownership confusion around the path 2 pointer. CMD_RESOLVE stores a pointer to a local stack buffer in the shared path 2 state, and CMD_COMPLETE writes into that buffer. Because the pointer is published to a structure that other threads can act on, a second waiter (thread 2) can reach it and free it while the resolving thread (thread 3) is still asleep. The report states that the pointer is not a malloc() allocation but a pointer to kernel stack. The report states this directly: the pointer is not a malloc() allocation but a pointer to kernel stack.

Impact

The report states the impact as privilege escalation. The report does not spell out a full exploit chain, so the practical reach of the primitive beyond the stated privilege escalation is not described.

How this kind of bug works

A use-after-free happens when memory is released while a reference to it still exists, and that reference is then used. Here the variation is that the released memory is not heap memory at all: it is a stack frame belonging to a kernel thread. Stack memory has a fixed lifetime tied to the function call that owns it, so freeing it through a heap free routine is a category error. Two things make it reachable: a shared object (the path state) that can hold a pointer to a short-lived buffer, and concurrency that lets one thread act on that object while another thread is between publishing the pointer and finishing with it. Wake-up ordering is the lever: if a waiter can be scheduled before the thread that owns the buffer, the waiter can free the pointer first. Defences that matter for this class are clear ownership rules (a pointer is either heap-owned or borrowed, never both), reference counting or generation counters on shared objects, and locking that covers the whole publish, use and release sequence rather than individual steps.

How to test for it

This class of bug is found by looking for shared state that can hold pointers to temporary buffers, then trying to make two threads race around it.

  1. Identify syscalls or ioctls that take a command plus an identifier (a path, handle or slot number) and that have separate wait, resolve and complete style operations.
  2. Look for commands that store a pointer into shared state and then block or sleep, and commands that write through that pointer from another thread.
  3. Build a harness with several threads: one waiting on object A, one waiting on object B, one resolving B, and one completing B. Vary the timing with sleeps and CPU pinning to change which waiter wakes first.
  4. A positive result is a crash, a kernel warning about a bad free or stack corruption, or observable corruption of the resolving thread's stack. Repeat runs to confirm the race is reproducible rather than a one-off.
  5. Common false positives are ordinary heap use-after-free reports where the pointer really was allocated, crashes caused by invalid user input rather than a lifetime bug, and races that only produce a benign error return. Confirm the freed address lies in a kernel stack before claiming a stack free.

How it is fixed

The standard fixes are to stop publishing stack pointers into shared state, for example by copying the buffer into a heap allocation owned by the path object, or by keeping the buffer private to the resolving thread and having other threads signal it rather than write into it. The free path should check ownership before releasing anything, and the publish, use and release sequence should be covered by a single lock or by reference counting so a waiter cannot free an object that another thread still holds. Wake-up ordering should be made explicit so that the owner finishes before any waiter can release the object.

Hunting notes

Bugs of this shape tend to hide in kernel interfaces with multi-step, stateful command protocols: wait and complete pairs, resolve and release pairs, and anything where a handle is registered by one thread and consumed by another. Recon signals include syscalls with large command switches, identifiers that look like slots or paths, and code paths that sleep while holding a reference. To make a report land, show a minimal, repeatable trigger, identify the exact pointer and where it was allocated, and demonstrate the consequence (a crash with a clear kernel message, or controlled corruption) rather than only a theoretical race.

The original is short, so this covers everything it reports, then explains this kind of bug in general: how it works, how to test for it and how it is fixed. The general sections are about the bug class, not this target. Written with AI and checked against the original; the original is the record. 6 min read.

What happened, in plain words

This report is about the PlayStation 5. The researcher found a bug in a system call, which is a function that a program can ask the operating system's kernel to perform. The system call is called sys_fsc2h_ctrl. The bug is a use-after-free: memory is released while something still holds a reference to it, and that reference is then used. In this case the memory is not ordinary heap memory but a buffer on the kernel stack, so the report calls it a kernel stack free. The program rated it high severity, paid a bounty of 10,000 USD, and disclosed the report on 18 April 2025.

The report describes the bug through four threads that all issue commands to the same system call. A thread is a sequence of instructions that the operating system can run independently; several threads can run at the same time. The commands and their values are:

Text
CMD_WAIT (0x10001)
CMD_RESOLVE (0x20005)
CMD_COMPLETE (0x20003)

The sequence the researcher lays out is:

  1. Thread 1 issues CMD_WAIT (0x10001) in sys_fsc2h_ctrl and waits for path 1.
  2. Thread 2 issues CMD_WAIT (0x10001) in sys_fsc2h_ctrl and waits for path 2.
  3. Thread 3 issues CMD_RESOLVE (0x20005) in sys_fsc2h_ctrl, which sets the pointer of path 2 to a local stack buffer, and then sleeps.
  4. Thread 4 issues CMD_COMPLETE (0x20003) in sys_fsc2h_ctrl, which writes data into that local stack buffer and wakes up thread 3.
  5. Thread 2 wakes up before thread 3 and frees path 2. That pointer is not a malloc() allocation; it points into the kernel stack.

A pointer is a value that says where a piece of memory is. A local stack buffer is a small area of memory that belongs to a function while it runs; it is created automatically and disappears when the function returns. malloc() is the usual way to ask for heap memory, which stays allocated until it is explicitly freed. The mistake is that thread 2 frees path 2, which is not a malloc() allocation but a pointer to kernel stack. Thread 2 frees memory that was never heap allocated. The report does not describe the fix, and it does not give the exact data written by CMD_COMPLETE or the size of the stack buffer.

The report states the impact as privilege escalation. The report does not spell out a full exploit chain.

In general, how this kind of bug works

A use-after-free happens when memory is released while a reference to it still exists, and that reference is then used. Here the variation is that the released memory is not heap memory at all: it is a stack frame belonging to a kernel thread. Stack memory has a fixed lifetime tied to the function call that owns it, so freeing it through a heap free routine is a category error, like returning a borrowed book to a shop as if you had bought it.

Two things make the bug reachable: a shared object (the path state) that can hold a pointer to a short-lived buffer, and concurrency that lets one thread act on that object while another thread is between publishing the pointer and finishing with it. Wake-up ordering is the lever: if a waiter can be scheduled before the thread that owns the buffer, the waiter can free the pointer first. Defences that matter for this class are clear ownership rules (a pointer is either heap-owned or borrowed, never both), reference counting or generation counters on shared objects, and locking that covers the whole publish, use and release sequence rather than individual steps.

How to test for it

This class of bug is found by looking for shared state that can hold pointers to temporary buffers, then trying to make two threads race around it.

  1. Identify system calls or ioctls that take a command plus an identifier (a path, handle or slot number) and that have separate wait, resolve and complete style operations. An ioctl is a system call used to send device-specific commands.
  2. Look for commands that store a pointer into shared state and then block or sleep, and commands that write through that pointer from another thread.
  3. Build a harness with several threads: one waiting on object A, one waiting on object B, one resolving B, and one completing B. Vary the timing with sleeps and CPU pinning to change which waiter wakes first. CPU pinning means forcing a thread to run on a particular processor core.
  4. A positive result is a crash, a kernel warning about a bad free or stack corruption, or observable corruption of the resolving thread's stack. Repeat runs to confirm the race is reproducible rather than a one-off.
  5. Common false positives are ordinary heap use-after-free reports where the pointer really was allocated, crashes caused by invalid user input rather than a lifetime bug, and races that only produce a benign error return. Confirm the freed address lies in a kernel stack before claiming a stack free.

How it is fixed

The standard fixes are to stop publishing stack pointers into shared state, for example by copying the buffer into a heap allocation owned by the path object, or by keeping the buffer private to the resolving thread and having other threads signal it rather than write into it. The free path should check ownership before releasing anything, and the publish, use and release sequence should be covered by a single lock or by reference counting so a waiter cannot free an object that another thread still holds. Wake-up ordering should be made explicit so that the owner finishes before any waiter can release the object.

Hunting notes

Bugs of this shape tend to hide in kernel interfaces with multi-step, stateful command protocols: wait and complete pairs, resolve and release pairs, and anything where a handle is registered by one thread and consumed by another. Recon signals include system calls with large command switches, identifiers that look like slots or paths, and code paths that sleep while holding a reference. To make a report land, show a minimal, repeatable trigger, identify the exact pointer and where it was allocated, and demonstrate the consequence (a crash with a clear kernel message, or controlled corruption) rather than only a theoretical race.

Glossary

  • System call: a function that a program asks the operating system kernel to perform on its behalf.
  • Kernel: the core part of the operating system that manages memory, processes and hardware.
  • Thread: a sequence of instructions that the operating system can run independently; several threads can run at the same time.
  • Use-after-free: a bug where memory is released while a reference to it still exists, and that reference is then used.
  • Kernel stack: a region of memory used by the kernel to store temporary data for a running thread.
  • Stack buffer: a small area of memory that belongs to a function while it runs and disappears when the function returns.
  • Pointer: a value that says where a piece of memory is.
  • Heap: memory that a program requests explicitly and that stays allocated until it is freed.
  • malloc(): the usual function for requesting heap memory.
  • Privilege escalation: gaining more rights than an attacker should have.
  • Race condition: a bug that depends on the timing of two or more threads acting on shared state.
  • Shared state: data that more than one thread can read or change.
  • Reference counting: keeping a count of how many references exist to an object, and freeing it only when the count reaches zero.
  • Lock: a mechanism that lets only one thread at a time enter a section of code.
  • ioctl: a system call used to send device-specific commands.
  • CPU pinning: forcing a thread to run on a particular processor core.
  • False positive: a test result that looks like a bug but is not one.

More by Andy Nguyen

View all

7 more disclosed reports, best first.

More from PlayStation

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Race conditions

The lesson behind this report.

Parallel requests reach a state the code assumed could not happen: a coupon used twice, a limit overrun, a check skipped.