Commit Graph

2399 Commits

Author SHA1 Message Date
Wildan M f40b84a5cc Add lock token to FileDescription, without borrow check 2026-03-09 11:23:51 +07:00
bjorn3 6085c8935c Remove unused WaitQueue::receive method 2026-03-07 21:44:29 +01:00
bjorn3 6a10af6f77 Fully remove the broken support for unmounting schemes
It has been broken since we moved namespaces into userspace. Fixing it
can be done entirely inside userspace. Either by introducing a SYS_CALL
for the root capability or by treating closing the last fd as unmount.
2026-03-07 21:42:46 +01:00
Wildan M fd9c651410 Do not allocate on unneeded Vec 2026-03-07 09:15:20 -07:00
Wildan M 547722767a Optimize sys/stat a bit 2026-03-07 20:42:25 +07:00
Wildan M a5adc0cc69 Avoid heap allocation on event 2026-03-07 06:33:52 -07:00
bjorn3 4ccc521156 Show grant flags in the debugger 2026-03-07 12:19:40 +01:00
bjorn3 ea847f428f Fix compilation with the debugger feature enabled 2026-03-07 12:19:24 +01:00
auronandace 4c734e461a prefer saturating methods over direct arithetic 2026-03-05 10:58:45 +00:00
auronandace fc6ffd59ff avoid direct indexing in MemoryMap register function 2026-03-03 17:22:44 +00:00
auronandace 14b8c2b0c1 enforce two lints and collapse some ifs 2026-03-03 14:51:32 +00:00
auronandace f0f158e5d6 eliminate 2 unwraps in syscall fs 2026-03-02 17:11:51 -07:00
auronandace f7b0f5ec37 eliminate an unwrap in gdt for x86_shared 2026-03-02 10:56:28 +00:00
Ibuki Omatsu 4faa1bad45 feat: Implment std_fs_call kfstatvfs handling to memory scheme 2026-02-28 08:06:47 -07:00
Marsman 507d899587 fix: validate timespec in nanosleep 2026-02-28 07:02:30 +00:00
Wildan M fbe129918c Handle address release on flink 2026-02-27 15:43:19 +07:00
Wildan M 1b74bea620 EventQueue may dropped at trigger_inner 2026-02-27 15:29:58 +07:00
Wildan M 2e759a9cc5 Prevent drop on BorrowedHtBuf 2026-02-27 13:54:05 +07:00
Wildan M 437f762339 Prevent drop on WaitCondition 2026-02-27 12:34:13 +07:00
Wildan M 159e67f26d Add lock token for global REGISTRY 2026-02-27 11:16:57 +07:00
Wildan M c72e0a67f9 Prevent drop on AddrSpace 2026-02-27 10:47:45 +07:00
Jeremy Soller d34090f352 Accurately strip ANSI escape sequences in graphical debug display 2026-02-26 10:33:46 -07:00
Wildan M ac0bd2af74 Fix compilation 2026-02-26 04:33:10 +07:00
Anhad Singh ba94676fe4 chore: update redox_syscall
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-25 08:21:36 -07:00
Anhad Singh 8eb6d22ab4 misc(scheme/user): remove some debug logs
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-25 08:21:36 -07:00
Anhad Singh 955b4b2a1c feat(stdfscall): flocking
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-25 08:21:36 -07:00
Wildan M 14349d1649 Propagate ordered lock of event trigger 2026-02-25 11:42:31 +07:00
Wildan M 3c2b1a11c5 Add ordered lock for time offset mutex 2026-02-25 11:42:17 +07:00
Wildan M 735c68ec30 Add ordered lock for WaitQueue mutex 2026-02-25 09:48:13 +07:00
auronandace bf396c7f61 replace manual stripping 2026-02-23 15:49:32 +00:00
auronandace 8138826200 avoid direct indexing in wait_condition 2026-02-23 06:34:20 -07:00
auronandace 7770a9452c avoid direct indexing futexes 2026-02-23 11:57:28 +00:00
auronandace a19be5da11 avoid direct indexing in AlignedBox 2026-02-22 13:43:37 +00:00
auronandace aeb75d577f add assert to ensure both arrays are equal length 2026-02-21 20:37:08 +00:00
auronandace 8689e31674 remove an instance of direct indexing 2026-02-21 15:28:55 +00:00
auronandace df469ddcb3 apply is_multiple_of lint 2026-02-21 08:39:26 +00:00
auronandace 02a68d3c87 change static_mut_refs back to warn 2026-02-20 16:06:16 +00:00
auronandace 28ba26cc2b move lints to Cargo.toml file 2026-02-20 15:59:27 +00:00
Anhad Singh fc60dcced0 misc(main): add feature btree_cursors
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-21 00:59:24 +11:00
Anhad Singh a8699a7e72 feat(memory): handle grant merges when mutating
This commit fixes the following panic when running nodejs:
```
KERNEL PANIC: panicked at src/context/memory.rs:267:18:
grant cannot magically disappear while we hold the lock!
  FP ffff80002021f650: PC ffffffff8005e45b
    FFFFFFFF8005E2E0+017B
    kernel::panic::panic_handler_inner
  FP ffff80002021f730: PC ffffffff80057559
  FP ffff80002021f740: PC ffffffff8009a0ff
  FP ffff80002021f770: PC ffffffff8009c214
  FP ffff80002021f7d0: PC ffffffff80010997
    FFFFFFFF8000FDD0+0BC7
    kernel::context::memory::AddrSpaceWrapper::mprotect
  FP ffff80002021fd40: PC ffffffff8008cb0b
    FFFFFFFF8008CA40+00CB
    kernel::syscall::process::mprotect
  FP ffff80002021fd70: PC ffffffff8006ce6c
    FFFFFFFF8006CBE0+028C
    kernel::syscall::syscall
  FP ffff80002021fe90: PC ffffffff8008d3cf
    FFFFFFFF8008D320+00AF
    __inner_syscall_instruction
  FP ffff80002021ff50: PC ffffffff800830c3
    FFFFFFFF80083080+0043
    kernel::arch::x86_64::interrupt::syscall::syscall_instruction
  00007ffffffffaf0: GUARD PAGE
CPU #1, CID 0xffffff7f8015b910
NAME: /usr/bin/node, DEBUG ID: 74
SYSCALL: mprotect(0x203C0000, 262144, Some(MapFlags(0x0)))
HALT
```

The grant did not magically disappear. When going through the
`grant_span_res` regions, the function adds (and removes) grants to the
`self.grants` tree. The insertion and deletion functions also merge
adjacent grants together when possible. This is an issue since we can no
longer use the keys we established before we started iterating. This
commit modifies the places where `remove` is used in this fashion to use
`remove_containing` instead. The `remove_containing` function will
remove the grant that *contains* the page.

Should it be done this way (requires unstable feature `btree_cursors`)?

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-21 00:59:24 +11:00
auronandace 6853592ce4 add precedence clippy lint 2026-02-20 13:15:32 +00:00
Anhad Singh b85c2d7889 misc(rmm): update submodule
Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-20 00:26:47 +11:00
Anhad Singh 124b74e816 fix(context/memory): Grant::remap delegate write
`Grant::remap` should not directly mark entries as writeable because the
entry could be private and requires Copy-On-Write (COW) handling. This
bug fixes the random panics that occur when running programs that
incorrectly mark private memory regions as writeable. This also
inadvertently caused other systems to crash. This is because The Zeroed
Frame is mapped instead of allocating a new zeroed memory region every
time. Only after the first write is the frame actually allocated. This
means that with this bug one could remap a freshly mmap'ed ANONYMOUS
region with the write flag and rewrite the contents of The Zeroed Frame,
which is a big problem. This means that any program that allocated
memory with the ANONYMOUS flag after this would not receive zeroed
memory.

Example of `make` hitting this bug when the shared `ld.so` patches are
applied:
```
....
[page at 0x48bd000] is mapped to the zeroed frame with PageFlags { present: true, write: false, executable: false, user: true, bits: 0x8000000000000005 }
[page at 0x49b1000] is mapped to the zeroed frame with PageFlags { present: true, write: true, executable: false, user: true, bits: 0x8000000000000007 }
[page at 0x49b2000] is mapped to the zeroed frame with PageFlags { present: true, write: true, executable: false, user: true, bits: 0x8000000000000007 }
[page at 0x49b3000] is mapped to the zeroed frame with PageFlags { present: true, write: true, executable: false, user: true, bits: 0x8000000000000007 }
[page at 0x49b4000] is mapped to the zeroed frame with PageFlags { present: true, write: true, executable: false, user: true, bits: 0x8000000000000007 }
0x43ff000..0x49b5000 :: MapFlags(PROT_WRITE | PROT_READ)
[page at 0x49b5000] is mapped to the zeroed frame with PageFlags { present: true, write: false, executable: false, user: true, bits: 0x8000000000000005 }
[page at 0x49b6000] is mapped to the zeroed frame with PageFlags { present: true, write: false, executable: false, user: true, bits: 0x8000000000000005 }
....
```

and causing the following crash:

```
Page fault: 0000000000001718 P | WR | US
RFLAG: 0000000000010202
CS:    000000000000002b
RIP:   00000000004125fd
RSP:   00007fffffffdd80
SS:    0000000000000023
FSBASE  00000000003f6000
GSBASE  0000000000000000
KGSBASE ffff80007a800000
RAX:   0000000000001718
RCX:   0000000000000000
RDX:   ffffffffffffffff
RDI:   000000000043b5a0
RSI:   00000000004537e0
R8:    0000000000000030
R9:    000000000043b5a0
R10:   0000000000000030
R11:   00000000000000ff
RBX:   0000000000000000
RBP:   00007fffffffddb0
R12:   000000000043b5a0
R13:   00000000004537e0
R14:   00000000004537e0
R15:   000000000043b5a0
  FP 00007fffffffddb0: PC 000000000042614a
  FP 00007fffffffde40: PC 0000000000411ae9
  FP 00007fffffffde80: PC 0000000000417187
  FP 00007fffffffdee0: PC 0000000000411d39
  FP 00007fffffffdf90: PC 000000000041207d
  FP 00007fffffffe020: PC 000000000040bc4c
  FP 00007fffffffe0c0: PC 000000000040c7c9
  FP 00007fffffffe0f0: PC 00000000004276ba
  FP 00007fffffffe1a0: PC 0000000000428087
  FP 00007fffffffe210: PC 000000000041eb6a
  FP 00007fffffffe400: PC 00000000004205c3
  FP 00007fffffffe490: PC 00000000004208dd
  FP 00007fffffffe4d0: PC 000000000040747e
  FP 00007ffffffffd60: PC 000000000092111c
  <Invalid next frame pointer 0x0000000000438490; stack walk ended>
  FP ffff80001b5bfe80: PC ffffffff80046dad
    FFFFFFFF80046BD0+01DD
    kernel::arch::x86_shared::interrupt::exception::page::inner
  FP ffff80001b5bff50: PC ffffffff8003ffbb
    FFFFFFFF8003FF84+0037
    kernel::arch::x86_shared::interrupt::exception::page
  00007fffffffddb0: GUARD PAGE
kernel::context::signal:INFO -- UNHANDLED EXCEPTION, CPU #1, PID 6548, NAME /usr/bin/make, CONTEXT 0xffffff7f8013fdc0
```

Also the crash info would vary every time you run the program since the
contents of The Zeroed Frame would have been mutated. Sneaky bug :^)

This also fixes the crashes that happen when running node.js (and maybe
other programs): https://gitlab.redox-os.org/redox-os/relibc/-/issues/229

Signed-off-by: Anhad Singh <andypython@protonmail.com>
2026-02-19 19:54:14 +11:00
Ibuki Omatsu 5a8858ff81 refactor: Initialize sys schem resources when they are first accessed. 2026-02-12 06:24:43 -07:00
Jeremy Soller 934162f35a Implement stdfscall 2026-02-11 12:12:49 -07:00
bjorn3 858b712df5 Use naked_asm!() instead of global_asm!() where possible 2026-02-09 22:28:38 +01:00
bjorn3 d51fe0c7e0 Avoid concat!() in inline asm
It is no longer necessary in modern rustc versions.
2026-02-09 22:12:20 +01:00
bjorn3 6bd204e1a3 Remove always true supports_on_close field 2026-02-08 17:23:50 +01:00
bjorn3 4c2c2b6757 Remove Option from State::Waiting.fds 2026-02-08 17:08:59 +01:00
bjorn3 0576db1fb4 Inline UserInner::call and rename call_extended to call 2026-02-08 13:01:14 +01:00