From 2e3bbf1e61c2e52be1f60145523af9ca8e646e03 Mon Sep 17 00:00:00 2001 From: lnlan Date: Sat, 30 Oct 2021 02:37:42 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dppoll=E6=8E=A5=E5=8F=A3"[ERR]?= =?UTF-8?q?OsMemFree=20check=20error!"=E6=8A=A5=E9=94=99=20=E3=80=90?= =?UTF-8?q?=E8=83=8C=E6=99=AF=E3=80=91=201.=E5=86=85=E6=A0=B8=E4=B8=AD?= =?UTF-8?q?=E9=87=8A=E6=94=BE=E7=94=A8=E6=88=B7=E7=A9=BA=E9=97=B4=E6=8C=87?= =?UTF-8?q?=E9=92=88=E6=8A=A5=E9=94=99:"[ERR]OsMemFree=20check=20error!"?= =?UTF-8?q?=202.=E7=8E=B0=E6=9C=89ppoll=E5=AE=9E=E7=8E=B0=E5=AD=98?= =?UTF-8?q?=E5=9C=A8=E9=97=AE=E9=A2=98=203.=E7=9B=B8=E5=85=B3=E7=94=A8?= =?UTF-8?q?=E4=BE=8B=E9=9C=80=E8=A6=81=E6=95=B4=E7=90=86=20=E3=80=90?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E6=96=B9=E6=A1=88=E3=80=91=201.=E5=8E=BB?= =?UTF-8?q?=E6=8E=89=E9=87=8A=E6=94=BE=E7=94=A8=E6=88=B7=E7=A9=BA=E9=97=B4?= =?UTF-8?q?=E6=8C=87=E9=92=88=E6=93=8D=E4=BD=9C=202.=E6=9B=B4=E6=AD=A3?= =?UTF-8?q?=E9=80=BB=E8=BE=91=E9=94=99=E8=AF=AF=203.=E6=9B=B4=E6=AD=A3?= =?UTF-8?q?=E6=8E=A9=E7=A0=81=E8=AE=BE=E7=BD=AE=E4=B8=8E=E6=81=A2=E5=A4=8D?= =?UTF-8?q?=E4=B8=8D=E8=B5=B7=E4=BD=9C=E7=94=A8=204.=E4=BF=AE=E5=A4=8D?= =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=8E=B0=E6=9C=89=E7=94=A8=E4=BE=8B=20?= =?UTF-8?q?=E3=80=90=E5=BD=B1=E5=93=8D=E3=80=91=20=E5=AF=B9=E7=8E=B0?= =?UTF-8?q?=E6=9C=89=E7=9A=84=E4=BA=A7=E5=93=81=E7=BC=96=E8=AF=91=E4=B8=8D?= =?UTF-8?q?=E4=BC=9A=E6=9C=89=E5=BD=B1=E5=93=8D=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit re #I47YWZ Change-Id: Ib2f60986e9cafb2ea5ef1097ab8552cbb1ede5b4 Signed-off-by: lnlan --- kernel/base/ipc/los_signal.c | 22 +++++----------------- syscall/fs_syscall.c | 36 ++++++++++++++---------------------- syscall/ipc_syscall.c | 12 ++++++++++-- 3 files changed, 29 insertions(+), 41 deletions(-) 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)