Commit Graph

1059 Commits

Author SHA1 Message Date
Chen Chengjun f8e4aefcca Add tmpfs support by wrapping ramfs 2025-08-29 15:45:20 +08:00
Yang Zhichao d84ad988d4 Implement `EnvironFileOps` to handle `/proc/[pid]/environ` 2025-08-29 10:07:29 +08:00
Zejun Zhao d3e27ae03a Use vDSO for fallback of user-provided sa_restorer on RISC-V platforms 2025-08-28 17:35:55 +08:00
jiangjianfeng 2098b11b68 Unify the implementation of /proc/[pid] and /proc/[pid]/task/[tid] 2025-08-27 15:22:08 +08:00
Arthur Paulino 888eecb350 Patch a futex vulnerability
If the futex wait operation was interrupted by a signal or timed out, the
`FutexItem` must be dequeued and dropped. Otherwise, malicious user programs
could repeatedly issue futex wait operations to exhaust kernel memory.

Due to asynchronicity, this removal can't be done by queue position nor by
futex key match up:
* The position might have changed during the pause as some earlier futex might
  have been dequeued
* If two futexes with the same key are enqueued and then one of them times out
  or is interrupted, a removal by key would likely dequeue the wrong futex

Therefore, we need to perform a removal by unique global futex ID.
2025-08-26 18:04:34 +08:00
Ruihan Li a6d37f0e79 Mark all kernel modules as private 2025-08-26 18:02:56 +08:00
Ruihan Li f35ae6fe1c Adjust visibility in `sem{,_set}.rs` 2025-08-26 18:02:56 +08:00
Ruihan Li 5c49142515 Remove `base` and `size` in `Vmar` 2025-08-26 18:02:56 +08:00
Ruihan Li a84897097e Remove `RangeLockItemBuilder` 2025-08-26 18:02:56 +08:00
Ruihan Li c9ac58e8df Remove unused "unregister" methods 2025-08-26 18:02:56 +08:00
Ruihan Li b2f17d11c6 Remove common enum suffixes 2025-08-26 18:02:56 +08:00
Ruihan Li 09e7355d87 Remove dead code in `file_table.rs` 2025-08-26 18:02:56 +08:00
Chen Chengjun b1bbd6c3fe Optimize the initialization logic during Asterinas init phase 2025-08-26 14:36:59 +08:00
Chen Chengjun a5c4566485 Include the VDSO library directly 2025-08-24 19:09:40 +08:00
Zejun Zhao 0a126a0c8c Set correct default value for VdsoData::mask 2025-08-23 12:38:22 +08:00
Zejun Zhao 47b05143cf Correct vDSO data segment's permission 2025-08-23 12:38:22 +08:00
Zejun Zhao e68631d1b6 Implement arch-aware vDSO 2025-08-23 12:38:22 +08:00
Ruihan Li a4aa745de1 Refine the lock usage in the vDSO module 2025-08-22 16:20:01 +08:00
Ruihan Li f457acdb8b Rewrite documentations in the vDSO module 2025-08-22 16:20:01 +08:00
Tao Su 226ea2865c Resolve `semget01` failure by fixing key limit and adding `IPC_STAT` 2025-08-20 19:57:14 +08:00
Ruihan Li 6b6c64c591 Rename `atomic_update` to `atomic_fetch_update` 2025-08-20 13:17:57 +08:00
Arthur Paulino a73f210c7a Make `wake_robust_futex` atomic
Replace `VmWriter::atomic_update` with `VmWriter::atomic_compare_exchange`,
which takes the old value for comparison and new value instead of a
closure to compute it. This version has one less unsafe call.

Then use `atomic_compare_exchange` to reimplement the looping logic
of `wake_robust_futex` and make it atomic.
2025-08-19 19:22:12 +08:00
Chen Chengjun fc5a12356a Fix LOONGARCH clippy warnings 2025-08-19 19:20:54 +08:00
Chen Chengjun 9507475102 Fix RISCV clippy warnings 2025-08-19 19:20:54 +08:00
Zhang Junyang 1452aab69c Optimize the space for `TlbFlushOp`s 2025-08-16 22:09:29 +08:00
Arthur Paulino c31c6110f6 chore: use `jhash` to compute the `FutexKey` hash
This patch pays the price of making the instantiation of `FutexKey`
more expensive to achieve two goals:
* Minor: make `match_up` slightly faster
* Major: make futex bucket allocation balancing more robust
2025-08-16 09:16:50 +08:00
Arthur Paulino 91351e338f fix: avoid distribution skew in `FutexBucketVec::get_bucket`
Doing `addr / self.size()` before masking with `(self.size() - 1)`
removes the low bits entirely, which causes adjacent addresses
(modulo `self.size()`) to map to the same bucket, entailing bad
load balance. This patch solves that.

Further, make `FutexBucketVec::new` and `FutexBucketVec::get_bucket`
private, as they only make sense within the scope of `futex.rs`,
where the invariant of `size` being a power of two is guaranteed to
hold via `get_bucket_count` (which is also private).
2025-08-16 09:16:50 +08:00
Arthur Paulino c345876bc0 chore: avoid several `FutexKey` copies
Use shared references instead of copied objects on some functions
that don't necessarily require ownership of `FutexKey`.

Remove the `Copy` derivation of `FutexKey` to discourage suboptimal
copies.
2025-08-16 09:16:50 +08:00
Tao Su c15106734a Align `MS_ASYNC` and `MS_SYNC` flags with Linux behavior 2025-08-14 20:01:36 +08:00
Ruihan Li 5b91064316 Add a method that disables page fault handlers 2025-08-14 11:59:05 +08:00
Ruihan Li e4fafb13b1 Add atomic operations for VM readers/writers 2025-08-14 11:59:05 +08:00
Ruihan Li 086a80c05f Drop unsound TLS methods from `Task` 2025-08-12 19:19:34 +08:00
Ruihan Li 923982c2e5 Remove `user_ctx` from `Task` 2025-08-12 19:19:34 +08:00
Zejun Zhao 60bc63b0e2 Refine system call tables 2025-08-12 17:03:44 +08:00
Chen Chengjun 25d217397a Rename MountNode to Mount 2025-08-12 15:20:17 +08:00
Chen Chengjun 32ee4a41f1 Refine visibility 2025-08-12 15:20:17 +08:00
Chen Chengjun e155057d55 Move all mount operation interfaces to Path 2025-08-12 15:20:17 +08:00
Chen Chengjun aea4013a43 Fix the mountpoint state maintaining for Dentry 2025-08-12 15:20:17 +08:00
Chen Chengjun ae32062e77 Avoid passing self when calling internal mount methods within Path 2025-08-12 15:20:17 +08:00
Chen Chengjun 9985d64535 Complete some remaining rename tasks 2025-08-12 15:20:17 +08:00
jiangjianfeng 9a56028afc Support parsing shebang with multiple arguments in intepreter line 2025-08-12 11:23:30 +08:00
Ruihan Li cdd28787ed Replace `write_vals` by `fill_zeros` in `VmIo` 2025-08-10 16:40:11 +08:00
Ruihan Li 2700d88bef Provide efficient `VmIo` with VM readers/writers 2025-08-10 16:40:11 +08:00
Ruihan Li aa7aca3dde Add `VmWriter::fill_zeros` 2025-08-10 16:40:11 +08:00
Tate, Hongliang Tian f2ead0b3ed Remove O_TMPFILE flag because it is not really supported 2025-08-09 16:26:50 +08:00
jiangjianfeng f6478d62cc Refactor the implementation about sigstack 2025-08-08 12:06:26 +08:00
Ruihan Li c19c7765d8 Fix race conditions in `pause_timeout` 2025-08-06 17:17:34 +08:00
Ruihan Li 20893be80e Allow to receive empty SEQPACKET packets 2025-08-06 17:17:34 +08:00
Chen Chengjun c6a6e66aac Rename Dentry to Path in the other modules and rename some local variables 2025-08-06 14:06:39 +08:00
Chen Chengjun 6aa516e2bf Move Path to mod.rs of the path module 2025-08-06 14:06:39 +08:00