Skip to content

[SUBISSUE #1] Implement Extended Futex Ops, Robust List Cleanup, rseq, and clone3 #285

Todo

Description

@marcobuschini

Parent Issue / Epic

#279 (Epic #265)

Prerequisite Sub-Issue

None

Atomic Deliverable & Implementation Details

Extend Milo's userspace threading and futex subsystem built in #264:

  • kernel/sync/Futex.hpp & kernel/sync/Futex.cpp: Add FUTEX_REQUEUE, FUTEX_CMP_REQUEUE, FUTEX_WAIT_BITSET, and FUTEX_WAKE_BITSET (FUTEX_BITSET_MATCH_ANY = 0xFFFFFFFFU) with CLOCK_REALTIME / CLOCK_MONOTONIC absolute timeout support.
  • kernel/uapi/sys.hpp: Define extern "C" standard-layout linux_clone_args (88 bytes) and linux_robust_list_head (24 bytes) with static_assert size/offset checks, plus FUTEX_* op constants.
  • kernel/process/Process.hpp & kernel/process/Process.cpp: Store per-thread robust list pointer/length, implement sys_get_robust_list (100), and walk/wake abandoned robust futexes on thread exit (exit_current_thread / exit_current_process).
  • kernel/syscalls/ProcessSyscalls.cpp & kernel/syscalls/SyscallDispatcher.cpp: Dispatch sys_get_robust_list (100), sys_rseq (293, documented -ENOSYS or minimal ABI registration), and sys_clone3 (435, delegating to existing fork/thread creation paths).
  • tests/host/: Add Snitch ASan/UBSan tests covering all new futex ops, robust-list readback/cleanup, and clone3 validation.

Out of scope: alternate signal stacks and rt_sig* syscalls ([SUBISSUE #2]), signalfd4 (Phase 2).

Acceptance Criteria & Edge Cases

  • FUTEX_CMP_REQUEUE returns -EAGAIN on mismatch and requeues waiters atomically under IrqGuard without losing wakeups
  • FUTEX_WAIT_BITSET / FUTEX_WAKE_BITSET reject bitset 0 with -EINVAL and selectively wake matching bitmasks
  • clone3 validates size (>= 64, <= page_size), rejects unknown flags / invalid exit_signal with -EINVAL, and cleans up cleanly on OOM/fault with zero PFA leaks
  • get_robust_list / set_robust_list enforce len == sizeof(linux_robust_list_head) (-EINVAL) and handle bad user pointers (-EFAULT) safely
  • make format && make clean-tests && make -j"$(nproc)" all && make -j"$(nproc)" quality passes with zero warnings

Metadata

Metadata

Assignees

Labels

subissue

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions