mirror of
https://github.com/apache/nuttx.git
synced 2026-08-01 20:28:58 +00:00
sched/Kconfig: waitpid() depends on SCHED_HAVE_PARENT if BUILD_KERNEL
waitpid() cannot be used in kernel mode unless SCHED_HAVE_PARENT is
selected -> add dependency if BUILD_KERNEL is selected.
Why? Because without SCHED_HAVE_PARENT waitpid() works in a non-standard
way, meaning it does not use SIGCHLD to wake the parent, as it should.
Also, returning the child status via stat_loc corrupts memory as stat_loc
points to the parent's address environment:
pid_t nxsched_waitpid(pid_t pid, int *stat_loc, int options)
{
...
group->tg_statloc = stat_loc;
...
}
And later when the status is returned, the child writes to tg_statloc,
which points to the parent's address environment -> random memory
corruption:
static inline void nxtask_exitwakeup(FAR struct tcb_s *tcb, int status)
{
...
if (group->tg_statloc != NULL)
{
*group->tg_statloc = status << 8;
}
...
}
This commit is contained in:
parent
36cafbb37f
commit
c1ceec3404
1 changed files with 3 additions and 1 deletions
|
|
@ -755,13 +755,15 @@ endif # SCHED_CHILD_STATUS
|
|||
config SCHED_WAITPID
|
||||
bool "Enable waitpid() API"
|
||||
default n
|
||||
depends on SCHED_HAVE_PARENT || !BUILD_KERNEL
|
||||
---help---
|
||||
Enables the waitpid() interface in a default, non-standard mode
|
||||
(non-standard in the sense that the waited for PID need not be child
|
||||
of the caller). If SCHED_HAVE_PARENT is also defined, then this
|
||||
setting will modify the behavior or waitpid() (making more spec
|
||||
compliant) and will enable the waitid() and wait() interfaces as
|
||||
well.
|
||||
well. Note that SCHED_HAVE_PARENT must be defined in BUILD_KERNEL if
|
||||
SCHED_WAITPID is needed.
|
||||
|
||||
config SCHED_DUMP_LEAK
|
||||
bool "Enable catch task memory leak"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue