<feed xmlns='http://www.w3.org/2005/Atom'>
<title>computeranim.git/targets/agent_pkey.c, branch main</title>
<subtitle>Tracing debugger and animations of running programs (ztrace, canim)</subtitle>
<id>https://git.0x4200.cafe/computeranim.git/atom?h=main</id>
<link rel='self' href='https://git.0x4200.cafe/computeranim.git/atom?h=main'/>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/computeranim.git/'/>
<updated>2026-11-10T16:00:24Z</updated>
<entry>
<title>agent: its handlers act with the thread's protection keys and float modes, not a handler's</title>
<updated>2026-11-10T16:00:24Z</updated>
<author>
<name>Gabriel Schneider</name>
<email>gbrls@0x4200.cafe</email>
</author>
<published>2026-11-10T15:52:12Z</published>
<link rel='alternate' type='text/html' href='https://git.0x4200.cafe/computeranim.git/commit/?id=8b28a0a5101a62fd55c2d55433e0fa899d4623f9'/>
<id>urn:sha1:8b28a0a5101a62fd55c2d55433e0fa899d4623f9</id>
<content type='text'>
The kernel starts a signal handler with default PKRU (key 0 only) and
default MXCSR and x87 control word, the thread's own saved in the frame.
The SIGSYS handler makes the thread's syscalls and clones its threads
from there, so under --syscalls:
- a pkey_alloc's new rights were undone when the handler returned;
- a thread was born with no right to keyed memory (V8's compiler
  threads fault reading the code space: d8 died of SEGV_PKUERR, and the
  35 seconds were its core dump, not a spin);
- a buffer in keyed memory was EFAULT to the kernel, and a fault to the
  agent reading it for the event;
- a thread started without its maker's float modes (flush-to-zero).
Both handlers now take the thread's PKRU and control words from the frame
first (signal.adopt), and the SIGSYS one writes PKRU back to the frame
after the syscall. Watched memory is read, and hooked code patched, with
every key open, so a key the thread itself cannot use hides nothing.

test-agent: agent_pkey (a keyed page read, given to syscalls, watched,
read by a later thread; skips itself without keys), and agent_sys's
thread checks its MXCSR. README: --alloc and programs with their own
malloc; the core dump.

Co-Authored-By: Claude Fable 5.2 &lt;noreply@anthropic.com&gt;
</content>
</entry>
</feed>
