mirror of
https://github.com/RT-Thread/rt-thread.git
synced 2026-11-17 07:05:31 +08:00
7ac0b44a8d4fdf6b21641d3ecbedbe3ec4f263ca
4
Commits
| Author | SHA1 | Message | Date | |
|---|---|---|---|---|
|
|
40e07d970e |
[smart] lwp: enforce user buffer validation and copyin/copyout in terminal ioctl (#11941)
* [smart] lwp: enforce user buffer validation and copyin/copyout in terminal ioctl In the RT-Smart terminal subsystem, userspace ioctl commands (such as TIOCGWINSZ, TIOCSWINSZ, TIOCGPGRP, TIOCGSID, FIONREAD, and TIOCGPTN) were previously passed directly to underlying FreeBSD ioctl handlers as raw user pointers without kernel staging or copy validation. This patch addresses the user pointer dereference sinks: 1. In lwp_tty_ioctl_adapter(), stage arguments in kernel stack buffers and use _copy_from_user() / _copy_to_user() (lwp_get_from_user / lwp_put_to_user) for TIOCGWINSZ, TIOCSWINSZ, TIOCGPGRP, TIOCSPGRP, TIOCGSID, TIOCSTI, TIOCOUTQ, FIONREAD, and modem commands. 2. In ptm_fops_ioctl(), safely buffer arguments for TIOCGPTN, TIOCPKT, TIOCSIG, TIOCGPGRP, TIOCGSID, FIONREAD, TIOCOUTQ, TIOCGWINSZ, TIOCSWINSZ, and termios settings, returning -ENOTTY on unrecognized commands. 3. In tty_generic_ioctl(), add defense-in-depth boundary checks using lwp_in_user_space() to safeguard kernel memory from arbitrary pointer dereferences. Signed-off-by: Adil Alperen Çiftci <adilalperenciftci@users.noreply.github.com> * [smart] lwp: make the tty ioctl adapters the single uaccess boundary lwp_tty_ioctl_adapter() and ptm_fops_ioctl() (through lwp_ptmx_ioctl_forward()) already stage every user argument into a kernel buffer before entering the BSD tty layer, so tty_generic_ioctl() only ever sees kernel pointers on the syscall path. Drop the lwp_in_user_space() branches that were added there, and the older one on TIOCSPGRP, so the trust boundary is in exactly one place per entry point and the switch no longer mixes two models. Zero the staging union in lwp_ptmx_ioctl_forward() before the backend runs: an *_OUT command copies it back to the caller, and a backend that returns 0 without filling it would otherwise hand out stack contents. Add the BSD termios commands TIOCGETA, TIOCSETA, TIOCSETAW and TIOCSETAF to the /dev/ptmx argument table so they keep reaching the tty layer as they did before the table existed. The termio-based TCGETA family is not handled by the BSD layer on this path and stays ENOTTY, as before. Rename lwp_ptmx_ioctl_arg_type() to lwp_ptmx_ioctl_arg_type_get() so the function no longer shares its name with the enum tag, rename the test case to testcases.lwp.tty_ptmx.regression since it covers more than the buffer bounds, and add the terminal directory to the utest CPPPATH instead of a relative include. Signed-off-by: Adil Alperen Ciftci <adilalperenciftci@users.noreply.github.com> * [smart] lwp: drop duplicate termios cases from the ptmx ioctl table In this port TIOCGETA and TIOCSETA/TIOCSETAW/TIOCSETAF are defined to the same values as TCGETS and TCSETS/TCSETSW/TCSETSF, so listing both sets makes the switch fail to compile with duplicate case values. The TCGETS family entries already cover the BSD names; the test asserts for the BSD spellings stay valid through the aliases. Signed-off-by: Adil Alperen Ciftci <adilalperenciftci@users.noreply.github.com> --------- Signed-off-by: Adil Alperen Çiftci <adilalperenciftci@users.noreply.github.com> Signed-off-by: Adil Alperen Ciftci <adilalperenciftci@users.noreply.github.com> Co-authored-by: Adil Alperen Çiftci <adilalperenciftci@users.noreply.github.com> Co-authored-by: Rbb666 <zhangbingru@rt-thread.com> |
||
|
|
ba79f69477 |
[kernel][ipc] Fix timeout wakeup ownership race
Keep thread timer ownership when timer stop races with an in-flight timeout callback, and consume IPC resources only after a waiter is resumed successfully. Complete ownership cleanup in the generic and RT-Smart channel timeout callbacks. Add deterministic scheduler and LWP regressions for Event, Semaphore, Mailbox, Message Queue, sender, and receiver paths. |
||
|
|
72a09a6aca |
fix: move tty_ptmx regression test to utest framework
ToolsCI / Tools (push) Has been cancelled
RT-Thread BSP Static Build Check / 🔍 Summary of Git Diff Changes (push) Has been cancelled
RT-Thread BSP Static Build Check / ${{ matrix.legs.RTT_BSP }} (push) Has been cancelled
RT-Thread BSP Static Build Check / collect-artifacts (push) Has been cancelled
pkgs_test / change (push) Has been cancelled
utest_auto_run / A9 :components/dfs.cfg (push) Has been cancelled
utest_auto_run / A9 :components/lwip.cfg (push) Has been cancelled
utest_auto_run / A9 :components/netdev.cfg (push) Has been cancelled
utest_auto_run / A9 :components/sal.cfg (push) Has been cancelled
utest_auto_run / A9 :cpp11/cpp11.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :default.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :default.cfg (push) Has been cancelled
utest_auto_run / A9-smp :default.cfg (push) Has been cancelled
utest_auto_run / RISCV :default.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :default.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/atomic_c11.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/ipc.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/kernel_basic.cfg (push) Has been cancelled
utest_auto_run / AARCH64-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / XUANTIE-rtsmart :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / AARCH64 :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / AARCH64-smp :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9 :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / A9-smp :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV :kernel/mem.cfg (push) Has been cancelled
utest_auto_run / RISCV-smp :kernel/mem.cfg (push) Has been cancelled
The previous commit placed the test in a new top-level tests/ directory that does not exist in the RT-Thread repo structure and used the external check library. Move the test to examples/utest/testcases/lwp/ and rewrite it using RT-Thread's native utest framework, add a Kconfig symbol (RT_UTEST_LWP_TTY_PTMX), and wire it into Kconfig.utestcases. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com> |
||
|
|
103d4c1d92 |
utest: move lwp testcases to components/lwp
Signed-off-by: CYFS <2805686936@qq.com> |