Commit Graph

66 Commits

Author SHA1 Message Date
Ibuki Omatsu bd9c6f1440 refactor: Make processes have cwd as a capability 2026-02-26 06:09:27 -07:00
Anhad Singh 09f52fd163 fix(redox-rt): FIXED_NOREPLACE for ET_EXEC
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 12:00:29 +11:00
Anhad Singh 4c0d4c7963 fix(redox-rt): update min mmap address for ET_EXEC
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 11:58:28 +11:00
Anhad Singh 4fbb8ec338 fix(redox-rt): add base address to e_entry
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 11:56:28 +11:00
Anhad Singh 0430081f4a feat(redox-rt): preload the executable
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-16 12:29:19 +11:00
bjorn3 24aaf8fac9 redox-rt: Use Option rather than MaybeUninit + bool 2026-02-07 18:37:37 +01:00
Ibuki Omatsu 1bcb6dff78 Introduce namespace fd and related features 2026-01-20 20:43:05 -07:00
Ibuki Omatsu efa5b73015 refactor: Replace unlink and rmdir with unlinkat. Improve fork using ForkScratchPad. 2025-12-17 18:32:07 -07:00
Anhad Singh f7aa718596 fix(redox-rt/proc): min_mmap_addr being set too low
`cmp::min` -> `cmp::max` Want to make sure we set the `min_mmap_addr` to
the top of the executable.

`update_min_mmap_addr(STACK_TOP - STACK_SIZE, STACK_SIZE);` needs to be
removed since we cannot allocate above that.

Reverts to the old behaviour. In future may want to consider loading the
executeable here instead of the dynamic linker (and before the dynamic
linker) to avoid any further conflicts.

Fixes `gcc` crashing at "failed to map
/usr/libexec/gcc/x86_64-unknown-redox/13.2.0/cc1. errno: 17" (where 17
-> EEXIST).

Co-authored-by: @bjorn3
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2025-12-12 17:49:36 +11:00
bjorn3 dc77995b57 redox-rt: Remove unnecessary image_file field from FexecResult::Interp 2025-12-09 22:22:09 +01:00
bjorn3 c96aeea39f redox-rt: Get rid of BTreeMap usage in fexec_impl 2025-12-09 21:04:45 +01:00
bjorn3 0158b111e0 redox-rt: Use non-fixed and anonymous remote mmap 2025-12-09 21:04:40 +01:00
bjorn3 1ede79fe88 Move cloexec and deactivate_tcb handling into redox-rt 2025-12-08 22:19:57 +01:00
bjorn3 b607877c07 Move cloexec handling to happen right before the final exec
This way if the target can't be executed, cloexec fds remain open as
expected.
2025-12-08 20:39:55 +01:00
bjorn3 4dae665cbf Hard code the default scheme to file
Init no longer changes the default scheme to initfs at any point in
time. And for sandboxing you would be switching scheme namespace, not
default scheme.

It should be possible to mix and match relibc version from before and
after this change without breaking exec, though I haven't tested it.
2025-12-07 19:51:45 +01:00
bjorn3 45a58f1a9e Account for nul terminator in total_args_envs_auxvpointee_size 2025-12-07 19:38:14 +01:00
bjorn3 6021ece539 Calculate total_args_envs_size in redox_rt::proc::fexec_impl
Calculating it earlier is a micro-optimization that doesn't seem like it
matters at all compared to all other costs of spawning a process. But at
the same time it makes things more fragile. And in fact bootstrap
actually passed the wrong value. It passed the
total_args_envs_auxvpointee_size that it computed rather than the
total_args_envs_size. While over-approximation doesn't cause UB, it
unnecessarily increases the amount of memory used after exec.

In addition pass &[&[u8]] rather than iterators for args and envs to
enable precomputing the total arg and env size. This also prevents you
from forgetting to pass a reversed iterator.
2025-12-07 18:52:47 +01:00
Jeremy Soller 01f01d3bd4 Fix for F_DUPFD_CLOEXEC, add TODO for usage in upper table 2025-11-17 17:46:57 -07:00
Jeremy Soller 0844e6fc90 WIP: use upper fd table 2025-11-15 07:55:37 -07:00
Josh Megnauth e39b27664f unsafe_op_in_unsafe_fn: ld_so, generic/redox-rt
There are a few functions where I allowed the lint. The lower level and
FFI nature of relibc means that there are areas with a lot of unsafe.
Some functions are basically long blocks of unsafe or contain lots of
small blocks of unsafe. unsafe_op_in_unsafe_fn doesn't add clarity to
these functions. Instead, it reduces readability by adding an indent or
small "unsafe { .. }" clutter.
2025-10-04 21:36:51 -04:00
Jeremy Soller 7ed934a01d Fix compilation of redox-rt without proc feature 2025-10-04 08:05:46 -06:00
Jeremy Soller 82084440ad Support nightly-2025-10-03 2025-10-03 21:51:10 -06:00
elle e148be2296 redox-rt: remove unused code from proc 2025-09-08 21:03:28 +00:00
elle bd13557f98 lib: remove array_chunks nightly feature
Removes the nightly `array_chunks` feature, since it is marked as
unlikely to be merged.

Usage is trivially refactored using iterators.
2025-09-08 17:08:22 +00:00
4lDO2 696ae4eca1 Add DisableSetpgid call. 2025-04-20 16:24:46 +02:00
4lDO2 0e0246bc69 Let procmgr handle process names. 2025-04-19 19:27:03 +02:00
4lDO2 8cfc7e8fac Do not treat ppid as constant. 2025-04-19 19:27:03 +02:00
4lDO2 0083043736 Write and fix waitpid_multiple test. 2025-04-19 19:27:02 +02:00
4lDO2 403beeb9f6 Fix sigqueue test for aarch64. 2025-04-19 19:27:02 +02:00
4lDO2 d559450d69 Use abort() rather than unreachable! when exit fails. 2025-04-19 19:27:02 +02:00
4lDO2 05481b36a6 Fix IPC size on i686. 2025-04-19 19:27:01 +02:00
4lDO2 2fbbdcc1c9 Aarch64 fix, make i686 compile. 2025-04-19 19:27:01 +02:00
4lDO2 f813f5a222 Fix sigtimedwait realtime signals, almost handler too. 2025-04-19 19:27:01 +02:00
4lDO2 6d72048b13 Store proc_fd in MaybeUninit with external discriminant. 2025-04-19 19:27:01 +02:00
4lDO2 6e947a9b2f Simplify FdGuard. 2025-04-19 19:27:00 +02:00
4lDO2 cc6fadb8bb Only SyncSigTctl if there exists a proc fd. 2025-04-19 19:27:00 +02:00
4lDO2 dc2988968e Use SignalThread call and fix fork sighandler sync with procmgr. 2025-04-19 19:26:59 +02:00
4lDO2 93e88b0ce8 Reacquire thread fd as procmgr-owned in make_init. 2025-04-19 19:26:59 +02:00
4lDO2 b30ccb61fe Enforce procmgr errors, fix attrs path. 2025-04-19 19:26:59 +02:00
4lDO2 8bd510ff59 Simplify [res][ug]id getters and setters. 2025-04-19 19:26:59 +02:00
4lDO2 ad5efd0f11 Reach init fork 2025-04-19 19:26:57 +02:00
4lDO2 26399569de Reach init w/proc manager. 2025-04-19 19:26:57 +02:00
4lDO2 b851422214 WIP: use proc manager in non-init fork. 2025-04-19 19:26:57 +02:00
4lDO2 91e58e8568 WIP: dynamic and static proc info 2025-04-19 19:26:57 +02:00
4lDO2 422a32690d Replace removed syscalls with redox-rt stubs. 2025-04-19 19:26:57 +02:00
Jeremy Soller 6e165e2ef0 Fix build on i686 2025-04-14 09:16:27 -06:00
bjorn3 17172720a7 Always pass offset to read_all and rename to pread_all 2025-04-12 21:49:42 +02:00
bjorn3 050edcdcc6 Pass PROT_READ to mmap when the segment has PF_R
This will allow the kernel to not add an implicit PROT_READ for every
mmap in the future.
2025-04-12 20:13:39 +02:00
bjorn3 095646517d Use a single mmap + read for each segment 2025-04-12 20:10:28 +02:00
bjorn3 d85fe6bdd5 Revert "Add a workaround for UB on arm64"
The kernel bug that caused this has been fixed.

This reverts commit 4d82cd90f8.
2025-04-12 17:14:01 +02:00