summaryrefslogtreecommitdiff
path: root/components/lwp/lwp_syscall.c
AgeCommit message (Collapse)Author
2026-08-30[libc][posix] Fix epoll waiters and LWP syscall copiesbernard
修复 epoll waiter 生命周期,避免等待队列节点在回调后失效。 整理 LWP POSIX syscall 的用户空间拷贝和错误返回路径。
2026-08-17Add AF_UNIX sockets implementation (#11681)Bernard Xiong
* 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.
2026-07-22lwp: copy timeout into kernel space in sys_select()yi chen
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]>
2026-03-31style: format code with clang-format [skip ci]Telecaster2147
2026-03-31fix(lwp): validate thread priority in sched syscallsAFWEF_147
2025-04-13add RT_THREAD_CTRL_SET_PRIORITYwycwyhwyq
2025-04-13add RT_THREAD_CTRL_SET_PRIORITYwycwyhwyq
2025-02-18[lwp]add comments for lwp system calls. (#9934)Guorui Li
2025-02-08[lwp]修正kill(pid < -1)时的返回值错误heyuanjie87
2025-01-06feat: add support for dfs remount functionalityShell
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]>
2025-01-06feat: add system reboot and process teardown supportShell
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]>
2025-01-06feat: add signal kill all functionalityShell
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]>
2024-12-20kernel: cleanup debug APIsChen Wang
- `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]>
2024-11-17Modify the position of libc_rent definitionrcitachi
2024-11-12fixup: smart: uninitialized buffer on mount(2) (#9636)Shell
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]>
2024-10-21fixup: smart: sys_mount: UAF vulnerabilityShell
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]>
2024-09-13[component][net]add more socket flagzms123456
2024-09-11[components][lwp]remove extra check in sys_bindzms123456
2024-08-25【修复】修复link系统调用返回值问题zhuzhuzhu
2024-08-25【修复】修复rmdir系统调用返回值不符合用户预期问题zhuzhuzhu
2024-08-25【修复】修复symlink系统调用返回值不是预期问题zhuzhuzhu
2024-08-24fix_return_errzhujiale
2024-08-22[lwp] Implementation of setpgrp and fix mmap2 problems (#9308)rcitachi
* mmap2 failure handling 当传入一个非常大的地址时,offset会计算得到一个值,又因为传入的地址错误,rc会得到错误码,结合offset会得到一个很奇怪的值。 * Implementation of setpgrp 执行setpgrp会走到这一步,在执行getpgrp无法得到创建的group的值 * Modify the return method of mmap
2024-08-22[lwp][tid]add error log when tid depleted, and return correct errno when ↵zms123456
clone failed (#9327) add error log when tid depleted, and return correct errno when clone failed
2024-08-22[components][lwp]fix mount param issue (#9333)zms123456
fix mount param issue
2024-07-18fix exec and mount error codezhao maosheng
2024-05-31[smart] fixup of script execution (#9009)Shell
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]>
2024-05-29[smart] fixup errno passing on sys_mkdir() (#9007)Shell
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]>
2024-05-29[smart] update sched_setaffinity() to use thread(task) ID (#9004)Shell
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]>
2024-04-25fix sys_getcwd (#8852)xiao-mang
2024-03-30[fixup] aarch64 UMP compiler error (#8677)Shell
Signed-off-by: Shell <[email protected]>
2024-03-28sync smart & dfs (#8672)Shell
Signed-off-by: xqyjlj <[email protected]> Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2024-02-23🎯 Sync smart & scheduler codes (#8537)Shell
Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2024-01-26[sys_bind] [signalfd] update (#8507)rcitachi
2023-12-16dfsv2 code tidy. (#8374)geniusgogo
2023-12-06Updated issues related to uds capacity and eventfd macro redefinition (#8329)zmq810150896
2023-12-02[AF_UNIX] Update AF_UNIX bind, connect entry (#8314)rcitachi
2023-11-29修复 #8293 问题 (#8307)rcitachi
2023-11-28fix dfs path name overflow. (#8305)geniusgogo
2023-11-28[SAL] Update SAL,Add socketpair sendmsg recvmsg function (#8293)rcitachi
2023-11-02🐞 fix: fix taskset (#8211)xqyjlj
2023-11-02[smart] fixup of lwp recycling and mm varea (#8206)Shell
Signed-off-by: shell <[email protected]> Signed-off-by: Shell <[email protected]> Co-authored-by: xqyjlj <[email protected]>
2023-10-25🎈 perf: perf rt_hw_interrupt_disable/enable (#8042)xqyjlj
Signed-off-by: Shell <[email protected]> Co-authored-by: Shell <[email protected]>
2023-10-25[smart] replace varea pgmgr and fixup of dfs mmap (#8184)Shell
Signed-off-by: shell <[email protected]> Signed-off-by: Shell <[email protected]>
2023-10-17Sync dfs lwp (#8123)geniusgogo
2023-10-14[smart] fixup: syscall.c (#8131)Shell
Signed-off-by: shell <[email protected]>
2023-10-14[smart] Replace irq disable/enable codes in futex (#7941)Shell
Signed-off-by: Shell <[email protected]>
2023-10-13add sys_utimensat (#8124)xiao-mang
2023-10-11[smart] split out part of lwp_new() to lwp_create()Shell
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]>
2023-10-08add sys_setitimer syscall (#8096)skychen123