Commit Graph

5088 Commits

Author SHA1 Message Date
Red Bear OS dd2cd44368 relibc: epoll_pwait must not panic on EVENT_TIMEOUT_ID
The kernel can inject a synthetic event with id == EVENT_TIMEOUT_ID
when the requested timeout fires. The previous loop iterated the raw
event buffer with events.add(i) (in epoll_event strides) and then
interpreted the result as a syscall::Event, which produced out-of-bounds
reads when the kernel interleaved timeout events with real events.

Two changes:

1. Cast events to Event* first, then add i in Event strides so the
   pointer arithmetic matches the buffer the kernel filled.
2. Filter out entries with id == EVENT_TIMEOUT_ID before copying them
   into the user-visible epoll_event array.

Adds a regression test that builds a synthetic Event buffer with a
timeout entry interleaved and verifies that the timeout entry is
dropped while siblings are preserved.
2026-07-26 16:27:01 +09:00
Red Bear OS e8cee8b85c header: add utmpx.h, linux/kd.h, linux/vt.h, X11/Xauth.h 2026-07-26 06:52:39 +09:00
Red Bear OS 27397a8ca1 Merge upstream/master into submodule/relibc
Sync the relibc fork with 50 upstream commits (socket layer rework,
exec/signal/ptrace/path/timer updates, pthread cleanup, ld_so lifecycle
work bringing mark_ready/run_fini into the tree, dynamically-linked
init support, start.rs allocator-model rewrite, test harness updates).
Satisfies the verify-fork-functions gate (2 previously-missing ld_so
functions now present).

Conflicts resolved (4 files; 46 auto-merged):

- src/start.rs: took upstream's version wholesale. Upstream moved
  allocator/linker initialization into ld_so's new lifecycle (the
  mark_ready/run_fini work this merge brings in), superseding the RB
  alloc_init cluster; the old model's function was already merged out
  and its lone call would not compile.

- redox-rt/src/sys.rs: kept the RB refresh flow with the non-fatal
  lseek fallback (upstream adopted the refresh as a fatal '?' —
  RB's conservative fallback protects spawn for uid-dropped /
  namespace-restricted exec where the kernel cannot refresh).

- src/platform/redox/exec.rs: kept the RB root exec-permission bypass
  (ruid/euid != 0 gate, Linux-matching behavior).

- Cargo.lock: syn 2.0.118 -> 2.0.119 (upstream).

Verified: repo cook relibc --force-rebuild successful;
verify-fork-functions.sh --no-fetch relibc passes;
all 9 forks now pass the gate.
2026-07-19 07:12:56 +09:00
Red Bear OS c6f8a2c208 Remove temporary spawn/execve diagnostics 2026-07-18 23:07:56 +09:00
Red Bear OS 20d4e8746f DIAG(execve): trace exec::execve (real fork+exec path, not posix_spawn) - log exe open + interp(ld.so) open, the two ENOENT-masking points 2026-07-18 20:45:18 +09:00
Red Bear OS e64c914319 DIAG(spawn): emit trace to fd2 (+/scheme/debug); debug: scheme path was wrong 2026-07-18 20:33:03 +09:00
Red Bear OS e532daf4d5 DIAG(spawn): trace Sys::spawn steps to debug: (new_child/cwd/filetable/exe/interp) to locate the login-shell ENOENT 2026-07-18 20:25:21 +09:00
Red Bear OS 01d229fa5c redox-rt: make filetable refresh non-fatal (fall back to lseek)
The dup2('refresh') added for O_CLOEXEC/stale-fd correctness fails for some
exec'd children (observed: a uid-dropped, namespace-restricted login shell)
and propagated as a spawn ENOENT. Fall back to the plain lseek when the
refresh syscall errors so process startup always succeeds; the refresh
still applies wherever the kernel permits it. Prevents any spawn
regression while the refresh path is stabilized for restricted children.
2026-07-18 16:34:43 +09:00
Red Bear OS dd9ae256a9 redox-rt: refresh inherited filetable before rebuilding fd table
Backport of upstream relibc 580eab8b ('Refresh filetable data before
filetable creation'). FdTbl::from_binary_fd reconstructs an exec'd
process's fd table from the inherited filetable fd. A plain lseek(0) did
not force the backing scheme to re-materialize the current descriptor
set, so an exec'd child (e.g. a login shell) could read a STALE snapshot
and end up with a desynchronized fd -- observed as an interactive shell
whose pty-slave stdin (fd 0) returns nothing while writes to fd 1/2 work.
Issue a SYS_DUP2 'refresh' on the filetable fd before reading it.
2026-07-18 14:53:07 +09:00
Jeremy Soller 9867c155aa Merge branch 'malloc-test' into 'master'
Enable malloc_usable_size test

See merge request redox-os/relibc!1555
2026-07-17 19:53:54 -06:00
Jeremy Soller fcd2c2e6c6 Merge branch 'clippy-green5' into 'master'
work around triggering some clippy lints

See merge request redox-os/relibc!1554
2026-07-17 19:53:22 -06:00
Jeremy Soller acccc99c2c Merge branch 'merge-ld-libc' into 'master'
misc: symlink ld.so -> libc.so

See merge request redox-os/relibc!1553
2026-07-17 19:52:06 -06:00
Jeremy Soller 97df74e839 Merge branch 'build-order' into 'master'
Build headers after librelibc

See merge request redox-os/relibc!1552
2026-07-17 19:51:25 -06:00
Jeremy Soller f13ded32ee Merge branch 'fix-o-cloexec' into 'master'
fix: Refresh filetable data before filetable creation

See merge request redox-os/relibc!1551
2026-07-17 19:49:39 -06:00
Red Bear OS 029064baeb fix(timerfd): actually compile the sys_timerfd module (export timerfd_* symbols)
The sys_timerfd module (timerfd_create/settime/gettime) existed on disk but was
never declared in header/mod.rs, so its code was NOT compiled and the symbols
were absent from libc — timerfd was entirely non-functional. The generated
header still declared the functions, so C programs compiled but failed to LINK
with 'undefined reference to timerfd_create/timerfd_settime' (e.g. libwayland's
event-loop.c, blocking the whole Wayland stack). Declare the module so the
implementation is built and the symbols exported.
2026-07-18 02:51:31 +09:00
Red Bear OS 3b40cc8e9c fix(headers): sys/timerfd.h must compile in plain C (unblocks Wayland/glib)
cbindgen auto-generated the timerfd_* prototypes from the Rust signatures,
emitting a bare 'itimerspec' (not 'struct itimerspec') and a 'clockid_t'
parameter with no <time.h> in scope, so any C program that #includes
<sys/timerfd.h> failed to compile. That made meson's TFD_CLOEXEC feature probe
report NO and aborted the whole Wayland stack (libwayland) and glib. Exclude the
auto-generated prototypes (the hand-written, correct ones are emitted from the
trailer) and add <time.h> to the sys_includes.
2026-07-18 01:57:13 +09:00
Red Bear OS 733da06876 fix(redox): translate POSIX F_DUPFD_CLOEXEC (1030) to Redox syscall ABI (5)
fcntl(F_DUPFD_CLOEXEC) reached redox_rt/kernel with the POSIX/C value 1030
instead of the Redox syscall value (syscall::F_DUPFD_CLOEXEC=5). redox_rt did
not recognize it as a dup, forwarded the raw command to the kernel, and the
kernel's fcntl fell through to its EINVAL catch-all. That made
OwnedFd::try_clone() return EINVAL, which broke tokio Runtime::build() (its I/O
reactor try_clones the epoll fd) for every tokio user on Redox: all the zbus
system daemons (sessiond/polkit/udisks/upower) and the login shell. F_DUPFD and
plain dup worked because they share the same value in both namespaces;
F_DUPFD_CLOEXEC was the sole untranslated command.

Also drop the ineffective epoll_ctl EINVAL/EBADF retry loop: it was based on a
disproven 'transient scheme churn' theory; epoll registrations always succeed
immediately. The real dup failure is fixed above.
2026-07-17 22:59:55 +09:00
auronandace f1e905dcb5 eliminate 2 expects 2026-07-17 11:04:15 +01:00
auronandace eed996c612 work around triggering some clippy lints 2026-07-17 08:32:49 +01:00
Anhad Singh aa2e2a8e1f misc: symlink ld.so -> libc.so
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-17 17:26:26 +10:00
Ibuki.O 580eab8ba5 fix: Refresh filetable data before filetable creation 2026-07-17 10:37:35 +09:00
Wildan M 2331c338a3 Enable malloc_usable_size test 2026-07-17 02:40:04 +07:00
Wildan M 645e4f7c87 Build headers after librelibc 2026-07-17 01:13:13 +07:00
Red Bear OS 415fa3c8c2 epoll: retry EPOLL_CTL_ADD/MOD on transient EINVAL/EBADF (Redox)
Registering an fd with /scheme/event can transiently fail with
EINVAL/EBADF while the scheme backing the fd is still starting up or the
fd table is churning during early boot (e.g. a tokio/mio reactor built by
a daemon that races ahead of ipcd's uds_stream scheme). Without recovery,
tokio's Runtime::build aborts the whole runtime with "Invalid argument
(os error 22)", killing every zbus daemon (sessiond, polkit, udisks,
upower) and any tokio program including the login shell.

Retry the /scheme/event registration write with a 5ms backoff, up to ~2s,
on EINVAL/EBADF; a genuinely permanent failure still surfaces after the
bounded window. Redox-only. This is the registration-site counterpart to
the existing park-path recovery in the P0-epoll-redox-recovery tokio patch.
2026-07-17 00:31:27 +09:00
Jeremy Soller 9c8169da2f Merge branch 'clippy-green4' into 'master'
tackle more clippy lints

See merge request redox-os/relibc!1550
2026-07-16 07:48:18 -06:00
Red Bear OS ab699eaa50 sys_wait: drop unnecessary unsafe around Out::from_mut in waitid 2026-07-16 22:08:17 +09:00
Red Bear OS 3ed376e153 sys_wait: implement waitid (idtype_t/id_t/P_*/CLD_*, siginfo population)
Adapted from the archived local P3-waitid.patch. Fills a POSIX gap needed by
job-control-capable shells (brush/nix). waitid() maps (idtype,id)->waitpid pid,
translates WEXITED/WSTOPPED/WCONTINUED/WNOWAIT options, and populates siginfo_t
(si_pid/si_signo/si_code/si_status) from the wait status.
2026-07-16 21:28:52 +09:00
auronandace 7375a196c6 add annotations and safety notes for timer functions 2026-07-16 10:00:19 +01:00
auronandace feebedbd55 import ToString 2026-07-16 09:11:52 +01:00
auronandace f3c0b52846 tackle more clippy lints 2026-07-16 08:59:10 +01:00
Red Bear OS a7663b3adf redox: drop now-unused EPERM import after setrlimit rewrite 2026-07-16 06:52:23 +09:00
Red Bear OS 323b95416b redox: implement getrlimit/setrlimit with a per-process limits table (finite RLIMIT_NOFILE) 2026-07-16 06:39:43 +09:00
Jeremy Soller 7fcce3822c Merge branch 'clippy-green3' into 'master'
tackle more clippy lints for redox

See merge request redox-os/relibc!1549
2026-07-15 10:27:40 -06:00
Jeremy Soller 4a6f7854a9 Merge branch 'merge-ld-libc' into 'master'
feat(ld.so): merge with libc.so

Closes #284

See merge request redox-os/relibc!1547
2026-07-15 10:25:12 -06:00
Anhad Singh ee98a2b09c fix(dso): sysv hash table
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 22:55:39 +10:00
Anhad Singh 260bccbd3c fix(ld): make environ preemptable
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 22:40:29 +10:00
Anhad Singh a6cda1cdb6 fix(dynlst): cleanup
We provide these through a C-macro.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 22:39:11 +10:00
Red Bear OS 9c106e3cea remove temporary RB_OPEN_DIAG open-failure trace 2026-07-15 21:38:38 +09:00
Anhad Singh bf2455ea2e misc(ld.so): cleanup
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 22:38:37 +10:00
auronandace ce28b8786a follow-up eliminating more as casts 2026-07-15 10:54:26 +01:00
auronandace 6671339ec3 revert cfg and remove unused import 2026-07-15 10:44:50 +01:00
auronandace e320c755ff tackle more clippy lints for redox 2026-07-15 10:30:48 +01:00
Anhad Singh 6697881222 feat(alloc): cleanup
* Storing a pointer to the allocator in TCB is no longer necessary.
* `AtomicPtr` to store the allocator is no longer required as the
  allocator is not swapped on init if the program was dynamically
  linked.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 18:26:27 +10:00
Anhad Singh f45e6096d1 misc: fix riscv build
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-15 18:24:56 +10:00
Red Bear OS f46e2a31a7 fix: import upstream relibc fdtbl sync fix 2026-07-14 22:26:47 +09:00
Anhad Singh ebd4dfb195 misc: update dlmalloc-rs
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-14 21:56:57 +10:00
Jeremy Soller 92c77db45a Merge branch 'clippy-green2' into 'master'
address some clippy lints in redox

See merge request redox-os/relibc!1548
2026-07-14 05:54:33 -06:00
Anhad Singh 0b474cfc78 feat(dynlst): add more symbols
These are taken from musl's dynlst.txt.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-14 21:32:46 +10:00
Anhad Singh 46968c7d29 fix(tests): specify target for test runner
Fixes the issue where `relibc-tests-runner` fails to run on Redox.

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-14 21:23:04 +10:00
Anhad Singh 134ec45ceb fix(tests/alarm_fn): zero out sa_flags
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-07-14 21:22:25 +10:00