[lwp] 校验 sigaction 信号编号 (#11899)

在信号处理表访问前校验信号编号,避免越界访问。
This commit is contained in:
Bernard Xiong authored and GitHub committed 2026-11-05 11:16:16 +08:00
1 parent f14ab20efd
commit 4d1e4e58f0
2 files changed
+16

No files matched your search

+10
View File
@@ -1115,6 +1115,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 */
+6
View File
@@ -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);