Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions components/lwp/lwp_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -1114,6 +1114,16 @@ rt_err_t lwp_signal_action(struct rt_lwp *lwp, int signo,
rt_list_t *thread_list;
rt_err_t ret = RT_EOK;

/*
* Signal numbers are 1-based. valid_signo_check() accepts 0 for the
* kill(pid, 0) probe, so reject it here as well before using signo - 1
* to index sig_action[].
*/
if (signo <= 0 || valid_signo_check(signo))
{
return -RT_EINVAL;
}

if (lwp)
{
/** acquire READ access to lwp */
Expand Down
6 changes: 6 additions & 0 deletions components/lwp/syscall/syscall_signal.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ sysret_t sys_sigaction(int sig, const struct k_sigaction *act,
struct lwp_sigaction kact, *pkact = RT_NULL;
struct lwp_sigaction koact, *pkoact = RT_NULL;

/* Reject out-of-range signal numbers before indexing the action arrays. */
if (sig <= 0 || (unsigned long)sig > _LWP_NSIG)
{
SET_ERRNO(EINVAL);
goto out;
}
if (!sigsetsize)
{
SET_ERRNO(EINVAL);
Expand Down
Loading