| Age | Commit message (Collapse) | Author |
|
修复 epoll waiter 生命周期,避免等待队列节点在回调后失效。
整理 LWP POSIX syscall 的用户空间拷贝和错误返回路径。
|
|
* components/dfs: support unix socket nodes
AF_UNIX pathname binding and descriptor passing require DFSv2 socket
nodes and retained open file descriptions across fd tables.
Add socket-node creation for tmpfs and devtmpfs, fd reference helpers,
and socket F_SETFL forwarding.
Impact: DFSv2 socket nodes and descriptor reference handling.
Validation: git diff --cached --check.
* components/net/sal: support local protocol providers
Local IPC protocol families do not have a backing network device.
Store the selected provider in each SAL socket and add a local provider
registry while preserving netdev checks for Internet sockets.
Handle DFSv2 close semantics, socketpair flags, and MSG_CTRUNC for
AF_UNIX integration.
Impact: SAL protocol dispatch for all socket families.
Validation: git diff --cached --check.
* components/lwp: support unix socket messages
Musl AF_UNIX addresses and ancillary data require explicit ABI and
user-memory conversion at the LWP syscall boundary.
Add the musl msghdr layout, bounded address and message copying,
control-message level conversion, and MSG_CTRUNC translation. Correct
receive buffer allocation and copy lengths while handling messages.
Impact: LWP socket syscalls when SAL is enabled.
Validation: git diff --cached --check.
* components/net/af_unix: add local sockets
Add an opt-in AF_UNIX provider for pathname-based local IPC without
a synthetic network device.
Support datagram and stream sockets, blocking and nonblocking I/O,
timeouts, poll, socketpair, and SCM_RIGHTS descriptor passing. Include
bounded Kconfig settings, component documentation, and utest coverage.
Impact: enabled only by RT_USING_AF_UNIX and requires SAL POSIX with
DFSv2.
Validation: git diff --cached --check.
* Fix AF_UNIX CI checks
Apply the repository clang-format rules to the affected source lines.
Suppress the cppcheck false positive for the devtmpfs list iterator.
No functional behavior is changed.
* components/lwp: preserve NULL optional msghdr buffers
When msg_name or msg_control is NULL, keep the kernel pointer NULL
instead of substituting an uninitialized buffer. Reject a NULL control
buffer with a nonzero length as EFAULT.
Impact: LWP sendmsg/recvmsg conversion on MMU targets.
Validation: git diff --cached --check.
* components/net/af_unix: fix poll UAF, namespace leak, and SCM_RIGHTS cycles
Poll only the local wait queue and wake writers from the receiver.
Free namespace entries on detach, and reject AF_UNIX descriptors in
SCM_RIGHTS until cycle collection exists.
Impact: AF_UNIX poll, bind lifetime, and descriptor passing.
Validation: git diff --cached --check.
* components/dfs: add DFSv2 AF_UNIX utest suite
Add opt-in tests under dfs/utest/v2/af_unix for socket nodes, IPC,
poll peer-close, namespace cleanup, and SCM_RIGHTS rejection.
Sources are built only when RT_UTEST_TC_USING_DFS_V2_AF_UNIX and the
selected test groups are enabled.
Impact: DFS utest menu and build; no production AF_UNIX behavior change.
Validation: git diff --cached --check.
|
|
sys_select() passed the raw user-space timeout pointer straight
through to select(), unlike readfds/writefds/exceptfds which are
all validated with lwp_user_accessable() and copied into kernel
memory first. A malicious or buggy user thread could pass a
timeout pointing at unmapped or otherwise invalid memory, which
select() would then dereference directly (timeout->tv_sec /
timeout->tv_usec) without any check, from kernel context.
Validate and copy it into a kernel-local struct timeval the same
way the fd_set arguments already are, before it reaches select().
Fixes #10298
Signed-off-by: yi chen <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
This patch introduces a remount feature for the DFS, allowing for the
modification of mount parameters without unmounting the filesystem,
the remount functionality helps modify certain mount flags (like `MS_RDONLY`) without
requiring an unmount, providing more control over mounted filesystems in the system.
The updates is essential for user space init proc to cleanup the runtime
resource, ensuring clean handling of cached data and enhancing system
robustness during power down processing.
Changes:
- Defined new constants for remount flags in `dfs_fs.h`.
- Added the `dfs_remount()` function in `dfs_fs.c` to handle remount operations.
- Introduced a check for unsupported flags and handle error conditions such as invalid paths
or non-directory targets.
- Updated the `dfs_mnt` structure in `dfs_mnt.h` to include a read-only flag (`MNT_RDONLY`).
- The `dfs_remount()` function allows changing the read-only status of a mounted filesystem.
- Added `MNT_LAZY_UMNT` and `MNT_RDONLY` flags to `dfs_mnt` structure.
- Introduced `dfs_mnt_setflags` function for dynamic flag management.
- Updated `dfs_remount` to utilize `dfs_mnt_setflags` for flag setting.
- Enhanced unmount operations with `dfs_mnt_umount_iter` and lazy unmounting.
- Added `dfs_pcache_clean` to handle cache cleanup for read-only mounts.
- Improved error reporting in `dfs_umount` for better user feedback.
- Refactored `sys_mount` to streamline parameter handling and support remounts.
- Introduced `_cp_from_usr_string` helper for user-space string operations.
- Updated internal APIs to ensure consistency in reference count management.
Signed-off-by: Shell <[email protected]>
|
|
The patch introduces support for system reboot functionality and process teardown,
allowing for a clean shutdown and unmounting of the root filesystem. This is
necessary for ensuring a proper system shutdown process, especially when dealing
with resource cleanup and ensuring that all processes have exited before system
shutdown.
Changes:
- Added `lwp_teardown()` function to handle process cleanup and system teardown.
- Introduced `lwp_pid_wait_for_empty()` to wait for process ID table emptiness
before proceeding with shutdown.
- Updated `dfs_mnt_unref()` to trigger callbacks when unmounting a filesystem.
- Added new reboot types (`RB_AUTOBOOT`, `RB_POWER_OFF`) and implemented their
corresponding actions, including cleanup of processes and unmounting root
filesystem.
- Extended `sys_reboot()` to handle reboot and power off types with appropriate
callbacks for process and filesystem teardown.
- Introduced callback mechanism for root filesystem unmount notifications.
Signed-off-by: Shell <[email protected]>
|
|
This change introduces the `lwp_signal_kill_all` function, which allows a
signal to be sent to all processes in the system. The function iterates
over all PIDs and sends the specified signal to each process, except those
that are protected from signals. This enhancement provides a convenient way
to broadcast signals across all processes in the system.
Changes:
- Added `lwp_signal_kill_all` function in `lwp_signal.c` to broadcast a
signal to all processes by iterating over all PIDs using the existing
`lwp_pid_for_each` function.
- Introduced a new `kill_all_param` structure to encapsulate the signal
information needed for killing processes.
- Added internal `_kill_each` helper function for sending the signal to each
PID.
- Updated `lwp_signal.h` with the new function prototype for `lwp_signal_kill_all`.
- Modified `sys_kill` in `lwp_syscall.c` to call `lwp_signal_kill_all` when
a process is not specified.
Signed-off-by: Shell <[email protected]>
|
|
- `dbg_log` is a “NOT RECOMMENDED API”, convert the calling of this
API to LOG_x and remove this API.
- `dbg_here`/`dbg_enter`/`dbg_exit`: no one use these APIs, remove
them directly.
Signed-off-by: Chen Wang <[email protected]>
|
|
|
|
The `struct stat` object used inside mount(2) is uninitialized, which
can lead to undefined behavior during running
Changes:
- Set zero to buffer before calling to stat()
Signed-off-by: Shell <[email protected]>
|
|
This patch addresses a use-after-free (UAF) vulnerability in the
sys_mount. The issue occurred due to improper handling of memory
deallocation, which could lead to crashes or undefined behavior on user
request of mounting.
Changes made:
- Moved the `rt_free(copy_source)` function call to occur after the necessary
operations are completed, preventing premature deallocation of memory.
Signed-off-by: Shell <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
* mmap2 failure handling
当传入一个非常大的地址时,offset会计算得到一个值,又因为传入的地址错误,rc会得到错误码,结合offset会得到一个很奇怪的值。
* Implementation of setpgrp
执行setpgrp会走到这一步,在执行getpgrp无法得到创建的group的值
* Modify the return method of mmap
|
|
clone failed (#9327)
add error log when tid depleted, and return correct errno when clone failed
|
|
fix mount param issue
|
|
|
|
This patch fixup the script execution capabilities on argv passing
and adds support for arguments larger than 4k.
According to POSIX, the script parameter is quiet different
from the current implementation. Especially on the way it inserts
the path of executables. At the end, when you execute a script
from `$PATH`, it always fails.
For the script, interpreter will be invoked with the following
arguments: `{interpreter [optional-arg] pathname arg...}`
where pathname is the pathname of the file specified as the first
argument of execve(), and arg... is the series of words pointed
to by the argv argument of execve(), starting at argv[1]. Note that
there is no way to get the argv[0] that was passed to the
execve() call.
The changes include:
- Separating argument, environment variable, and auxiliary vector
processing into a new lwp_args.c file.
- Fixing bugs in script argument processing and supporting arguments
larger than 4k.
- Updating lwp_execve to use the new argscopy function and removing
the old lwp_argscopy function.
- Making various modifications to lwp_load and elf_aux_fill to work
with the new argument processing.
- Removing unnecessary code related to dynamic loading and interpreter
scripts.
Signed-off-by: Shell <[email protected]>
|
|
Use _SYS_WRAP to fetch errno on return of mkdir to avoiding overriding
of it on other system APIs.
Signed-off-by: Shell <[email protected]>
|
|
Correct `sched_setaffinity()` to use the thread IDs (TIDs) instead of
process IDs (PIDs). The previous implementation used PIDs, which
caused issues since affinity settings need to be applied at the
thread level.
As the manual documented, the signature is:
> int sched_setaffinity(pid_t pid, size_t cpusetsize,
> const cpu_set_t *mask);
Yes, it's tricky, the identification passing in is called **'PID'**.
But when we talk about 'pid' from GNU libc, it's the **'task-id'**,
aka, `thread->tid` known in kernel.
Changes were made by updating the function signatures and logic in
`lwp.h`, `lwp_pid.c`, and `lwp_syscall.c` to accept TIDs. Specifically,
the `lwp_setaffinity` function and related internal functions now
operate using thread IDs and adjust thread affinity settings accordingly
Signed-off-by: Shell <[email protected]>
|
|
|
|
Signed-off-by: Shell <[email protected]>
|
|
Signed-off-by: xqyjlj <[email protected]>
Signed-off-by: Shell <[email protected]>
Co-authored-by: xqyjlj <[email protected]>
|
|
Signed-off-by: Shell <[email protected]>
Co-authored-by: xqyjlj <[email protected]>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Signed-off-by: shell <[email protected]>
Signed-off-by: Shell <[email protected]>
Co-authored-by: xqyjlj <[email protected]>
|
|
Signed-off-by: Shell <[email protected]>
Co-authored-by: Shell <[email protected]>
|
|
Signed-off-by: shell <[email protected]>
Signed-off-by: Shell <[email protected]>
|
|
|
|
Signed-off-by: shell <[email protected]>
|
|
Signed-off-by: Shell <[email protected]>
|
|
|
|
Prev implementation of lwp_new() including the create of lwp object
and the pid allocation. But not every lwp object need a pid.
So this patch split out the business of lwp_new() to improve the
maintainability.
Signed-off-by: Shell <[email protected]>
|
|
|