Copy siginfo_t to step before calling a user-space signal handler

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5769 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-03-21 20:02:14 +00:00
parent 170952d6e8
commit ee885b45d8
14 changed files with 32 additions and 14 deletions

View File

@ -4410,4 +4410,9 @@
all system call inline functions with > 3 parameters (2013-03-20)
* arch/*/src/common/up_stackframe.c and include/nuttx/arch.h: Add
and new interface to set aside memory on the stack. This will be
used at least in the kernel build to hold task arguments 2013-03-21).
used at least in the kernel build to hold task arguments (2013-03-21).
* sched/sig_deliver.c: When dispatching signals to user threads,
copy the siginfo_t from the sigq to the stack. The signal queue
is allocated from kernel memory; however, the current stack is
the user's stack and the user code will be able to access the
signinfo_t data from the stack copy (2013-03-21).

View File

@ -1713,7 +1713,7 @@ The system can be re-made subsequently by just typing <code>make</code>.
This function may be called anytime after <code>up_create_stack()</code> or <code>up_use_stack()</code> have been called but before the task has been started.
</p>
<p>
Thread data may be kept in the stack (instead of in the TCB) if it is accessed by the user code directory.
Thread data may be kept in the stack (instead of in the TCB) if it is accessed by the user code directly.
This includes such things as <code>argv[]</code>.
The stack memory is guaranteed to be in the same protection domain as the thread.
</p>

View File

@ -96,7 +96,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -73,7 +73,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -85,7 +85,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -85,7 +85,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -88,7 +88,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -84,7 +84,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -85,7 +85,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -86,7 +86,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -84,7 +84,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -84,7 +84,7 @@
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -228,7 +228,7 @@ int up_use_stack(FAR struct tcb_s *tcb, FAR void *stack, size_t stack_size);
* up_use_stack() have been called but before the task has been started.
*
* Thread data may be kept in the stack (instead of in the TCB) if it is
* accessed by the user code directory. This includes such things as
* accessed by the user code directly. This includes such things as
* argv[]. The stack memory is guaranteed to be in the same protection
* domain as the thread.
*

View File

@ -136,12 +136,25 @@ void sig_deliver(FAR struct tcb_s *stcb)
#ifdef CONFIG_NUTTX_KERNEL
if ((stcb->flags & TCB_FLAG_TTYPE_MASK) != TCB_FLAG_TTYPE_KERNEL)
{
/* The sigq_t pointed to by sigq resides in kernel space. So we
* cannot pass a reference to sigq->info to the user space.
* Instead, we will copy the siginfo_t structure onto that stack.
* We are currently executing on the stack of the user thread
* (albeit temporarily in kernel mode), so the copy of the
* siginfo_t structure will be accessible by the user thread.
*/
siginfo_t info;
memcpy(&info, sigq->info, sizeof(siginfo_t));
up_signal_handler(sigq->action.sighandler, sigq->info.si_signo,
&sigq->info, NULL);
&info, NULL);
}
else
#endif
{
/* The kernel thread signal handler is much simpler. */
(*sigq->action.sighandler)(sigq->info.si_signo, &sigq->info,
NULL);
}