<feed xmlns='http://www.w3.org/2005/Atom'>
<title>rt-thread.git/components/lwp/lwp_pid.c, branch copilot/bug-security-related-issue</title>
<subtitle>Unnamed repository; edit this file 'description' to name the repository.</subtitle>
<id>http://cgit.235523.xyz/rt-thread.git/atom/components/lwp/lwp_pid.c?h=copilot%2Fbug-security-related-issue</id>
<link rel='self' href='http://cgit.235523.xyz/rt-thread.git/atom/components/lwp/lwp_pid.c?h=copilot%2Fbug-security-related-issue'/>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/'/>
<updated>2026-05-26T08:56:36Z</updated>
<entry>
<title>lwp: fix pid leak on exec failure before task startup</title>
<updated>2026-05-26T08:56:36Z</updated>
<author>
<name>yang.zhang</name>
<email>zhangyang01@kylinos.cn</email>
</author>
<published>2026-05-03T00:58:55Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=d4f4c50b9e60223078a7178e47d338ca484bcbc0'/>
<id>urn:sha1:d4f4c50b9e60223078a7178e47d338ca484bcbc0</id>
<content type='text'>
When msh tries to execute a non-ELF path, lwp_execve() may allocate a PID
before lwp_load() fails. The old error path only dropped the LWP reference,
leaving the PID tree entry pointing to a freed LWP.

In an init-less boot flow, this can poison pid 1 after a failed command from
msh. A later LWP launch may then treat the stale pid 1 entry as a valid parent
LWP, resulting in invalid pgrp/session state and a job-control assertion during
process exit.

Add lwp_pid_rollback() for exec/spawn failures before the process becomes
runnable. Unlike lwp_pid_put(), it always releases the PID lock and does not
enter the "no more pid allocation" state when the PID tree becomes empty.

Use the rollback helper in lwp_execve() failure paths after PID allocation.

Signed-off-by: zhangyang &lt;gaoshanliukou@163.com&gt;
</content>
</entry>
<entry>
<title>[components/lwp]add doxygen comment for lwp_pid. #10702</title>
<updated>2025-09-19T10:18:26Z</updated>
<author>
<name>Guorui Li</name>
<email>liguorui1213@163.com</email>
</author>
<published>2025-09-19T10:18:26Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=2cd44e23c034ce04310c017914a705b586a3fbdc'/>
<id>urn:sha1:2cd44e23c034ce04310c017914a705b586a3fbdc</id>
<content type='text'>
</content>
</entry>
<entry>
<title>[lwp]修正无法通过文件名查找pid的问题 (#9935)</title>
<updated>2025-01-21T05:01:58Z</updated>
<author>
<name>heyuanjie87</name>
<email>sc943313837@gmail.com</email>
</author>
<published>2025-01-21T05:01:58Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=ed3222c2f8355ca55cd35640f4c417e7a31ad56a'/>
<id>urn:sha1:ed3222c2f8355ca55cd35640f4c417e7a31ad56a</id>
<content type='text'>
</content>
</entry>
<entry>
<title>feat: add system reboot and process teardown support</title>
<updated>2025-01-06T11:34:16Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-11-12T09:47:51Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=944f3d05b508d5eaeaabd8f5d2964847c80dbc3e'/>
<id>urn:sha1:944f3d05b508d5eaeaabd8f5d2964847c80dbc3e</id>
<content type='text'>
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 &lt;smokewood@qq.com&gt;
</content>
</entry>
<entry>
<title>feat: support PID iteration</title>
<updated>2025-01-06T11:34:16Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-11-15T03:54:38Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=c0b0838892538d2ca13c844ea598db25ca0323e8'/>
<id>urn:sha1:c0b0838892538d2ca13c844ea598db25ca0323e8</id>
<content type='text'>
This change introduces the `lwp_pid_for_each` function, which provides a
convenient and thread-safe method for iterating over PIDs with a user-
defined callback. This addition is necessary to support cases where
operations must be performed on each PID in the balanced tree, enhancing
flexibility and modularity for PID management.

Changes:
- Added `lwp_pid_for_each` function in `lwp_pid.c` to allow iteration
  over PIDs using a callback function and optional data parameter.
- Defined a new internal `pid_foreach_param` structure to encapsulate
  the callback and data for the iteration.
- Added `_before_cb` helper function for executing the callback on each
  PID node during AVL traversal.
- Ensured thread safety by acquiring and releasing the PID lock around
  the AVL traversal within `lwp_pid_for_each`.
- Updated `lwp_pid.h` with the `lwp_pid_for_each` function prototype and
  included `rtthread.h` for necessary types.

Signed-off-by: Shell &lt;smokewood@qq.com&gt;
</content>
</entry>
<entry>
<title>[lwp]list_process can print tid (#8991)</title>
<updated>2024-05-31T09:30:46Z</updated>
<author>
<name>rcitachi</name>
<email>yearsince@yeah.net</email>
</author>
<published>2024-05-31T09:30:46Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=85b428df429483676d808e82ea9c0c535057f6a0'/>
<id>urn:sha1:85b428df429483676d808e82ea9c0c535057f6a0</id>
<content type='text'>
* list_process can print tid

* fix-ci

* update list_process

* Update lwp_pid.c</content>
</entry>
<entry>
<title>[smart] update sched_setaffinity() to use thread(task) ID (#9004)</title>
<updated>2024-05-28T22:53:22Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-05-28T22:53:22Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=f179ce12b71c01a5fba3b79f00e245178f482483'/>
<id>urn:sha1:f179ce12b71c01a5fba3b79f00e245178f482483</id>
<content type='text'>
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:

&gt;        int sched_setaffinity(pid_t pid, size_t cpusetsize,
&gt;                             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-&gt;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 &lt;smokewood@qq.com&gt;</content>
</entry>
<entry>
<title>[quality] fixup compiler warning (#8961)</title>
<updated>2024-05-21T11:47:42Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-05-21T11:47:42Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=6b12bce22fc6faaf1c3c9d06583e5679540df7ca'/>
<id>urn:sha1:6b12bce22fc6faaf1c3c9d06583e5679540df7ca</id>
<content type='text'>
Signed-off-by: Shell &lt;smokewood@qq.com&gt;</content>
</entry>
<entry>
<title>sync smart &amp; dfs (#8672)</title>
<updated>2024-03-28T15:42:56Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-03-28T15:42:56Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=83e95bdff4c48c661b50e1eec56d5fd293b28fbb'/>
<id>urn:sha1:83e95bdff4c48c661b50e1eec56d5fd293b28fbb</id>
<content type='text'>
Signed-off-by: xqyjlj &lt;xqyjlj@126.com&gt;
Signed-off-by: Shell &lt;smokewood@qq.com&gt;
Co-authored-by: xqyjlj &lt;xqyjlj@126.com&gt;</content>
</entry>
<entry>
<title>🎯 Sync smart &amp; scheduler codes (#8537)</title>
<updated>2024-02-23T09:49:15Z</updated>
<author>
<name>Shell</name>
<email>smokewood@qq.com</email>
</author>
<published>2024-02-23T09:49:15Z</published>
<link rel='alternate' type='text/html' href='http://cgit.235523.xyz/rt-thread.git/commit/?id=71560bafb5735220696ca24a42ba4a668b55949b'/>
<id>urn:sha1:71560bafb5735220696ca24a42ba4a668b55949b</id>
<content type='text'>
Signed-off-by: Shell &lt;smokewood@qq.com&gt;
Co-authored-by: xqyjlj &lt;xqyjlj@126.com&gt;</content>
</entry>
</feed>
