diff --git a/kernel/base/ipc/los_signal.c b/kernel/base/ipc/los_signal.c index 16e9d7c0..465db123 100644 --- a/kernel/base/ipc/los_signal.c +++ b/kernel/base/ipc/los_signal.c @@ -218,28 +218,22 @@ void OsSigMaskSwitch(LosTaskCB * const rtcb, sigset_t set) } } -int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldset) +int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldsetl) { LosTaskCB *spcb = NULL; - sigset_t oldSigprocmask; int ret = LOS_OK; unsigned int intSave; sigset_t set; - int retVal; - if (setl != NULL) { - retVal = LOS_CopyToKernel(&set, sizeof(sigset_t), &(setl->sig[0]), sizeof(sigset_t)); - if (retVal != 0) { - return -EFAULT; - } - } SCHEDULER_LOCK(intSave); spcb = OsCurrTaskGet(); /* If requested, copy the old mask to user. */ - oldSigprocmask = spcb->sig.sigprocmask; - + if (oldsetl != NULL) { + *(sigset_t *)oldsetl = spcb->sig.sigprocmask; + } /* If requested, modify the current signal mask. */ if (setl != NULL) { + set = *(sigset_t *)setl; /* Okay, determine what we are supposed to do */ switch (how) { /* Set the union of the current set and the signal @@ -267,12 +261,6 @@ int OsSigprocMask(int how, const sigset_t_l *setl, sigset_t_l *oldset) } SCHEDULER_UNLOCK(intSave); - if (oldset != NULL) { - retVal = LOS_CopyFromKernel(&(oldset->sig[0]), sizeof(sigset_t), &oldSigprocmask, sizeof(sigset_t)); - if (retVal != 0) { - return -EFAULT; - } - } return ret; } diff --git a/syscall/fs_syscall.c b/syscall/fs_syscall.c index ae2e05af..f3e10416 100644 --- a/syscall/fs_syscall.c +++ b/syscall/fs_syscall.c @@ -2516,16 +2516,12 @@ int SysFstatfs64(int fd, size_t sz, struct statfs *buf) int SysPpoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, const sigset_t *sigMask, int nsig) { - int timeout; - int ret; - int retVal; - sigset_t_l origMask; - sigset_t_l setl; + int timeout, retVal; + sigset_t_l origMask = {0}; + sigset_t_l set = {0}; CHECK_ASPACE(tmo_p, sizeof(struct timespec)); - CHECK_ASPACE(sigMask, sizeof(sigset_t)); CPY_FROM_USER(tmo_p); - CPY_FROM_USER(sigMask); if (tmo_p != NULL) { timeout = tmo_p->tv_sec * OS_SYS_US_PER_MS + tmo_p->tv_nsec / OS_SYS_NS_PER_MS; @@ -2535,24 +2531,20 @@ int SysPpoll(struct pollfd *fds, nfds_t nfds, const struct timespec *tmo_p, cons } else { timeout = -1; } - + if (sigMask != NULL) { - memcpy_s(&setl.sig[0], sizeof(sigset_t), sigMask, sizeof(sigset_t)); - } - - ret = OsSigprocMask(SIG_SETMASK, sigMask ? &setl : NULL, &origMask); - if (ret != 0) { - return -EINVAL; - } - ret = SysPoll(fds, nfds, timeout); - if (ret < 0) { - retVal = -get_errno(); - } - ret = OsSigprocMask(SIG_SETMASK, &origMask, NULL); - if (ret != 0) { - return -EINVAL; + retVal = LOS_ArchCopyFromUser(&set, sigMask, sizeof(sigset_t)); + if (retVal != 0) { + return -EFAULT; + } + (VOID)OsSigprocMask(SIG_SETMASK, &set, &origMask); + } else { + (VOID)OsSigprocMask(SIG_SETMASK, NULL, &origMask); } + retVal = SysPoll(fds, nfds, timeout); + (VOID)OsSigprocMask(SIG_SETMASK, &origMask, NULL); + return retVal; } diff --git a/syscall/ipc_syscall.c b/syscall/ipc_syscall.c index 628a966c..83ebac4b 100644 --- a/syscall/ipc_syscall.c +++ b/syscall/ipc_syscall.c @@ -29,6 +29,7 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ +#include "syscall_pub.h" #include "mqueue.h" #include #include @@ -36,6 +37,7 @@ #include "time_posix.h" #include "user_copy.h" #include "los_signal.h" +#include "los_process_pri.h" #include "los_strncpy_from_user.h" #include "fs/file.h" @@ -229,8 +231,14 @@ int SysSigAction(int sig, const sigaction_t *restrict sa, sigaction_t *restrict int SysSigprocMask(int how, const sigset_t_l *restrict setl, sigset_t_l *restrict oldl, size_t sigsetsize) { - /* Let nxsig_procmask do all of the work */ - return OsSigprocMask(how, setl, oldl); + CHECK_ASPACE(setl, sizeof(sigset_t_l)); + CHECK_ASPACE(oldl, sizeof(sigset_t_l)); + CPY_FROM_USER(setl); + CPY_FROM_USER(oldl); + /* Let OsSigprocMask do all of the work */ + int ret = OsSigprocMask(how, setl, oldl); + CPY_TO_USER(oldl); + return ret; } int SysKill(pid_t pid, int sig)