修复ppoll接口"[ERR]OsMemFree check error!"报错
【背景】 1.内核中释放用户空间指针报错:"[ERR]OsMemFree check error!" 2.现有ppoll实现存在问题 3.相关用例需要整理 【修改方案】 1.去掉释放用户空间指针操作 2.更正逻辑错误 3.更正掩码设置与恢复不起作用 4.修复补充现有用例 【影响】 对现有的产品编译不会有影响。 re #I47YWZ Change-Id: Ib2f60986e9cafb2ea5ef1097ab8552cbb1ede5b4 Signed-off-by: lnlan <lanleinan@163.com>
This commit is contained in:
parent
78a297fd4e
commit
2e3bbf1e61
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include "syscall_pub.h"
|
||||
#include "mqueue.h"
|
||||
#include <errno.h>
|
||||
#include <sys/types.h>
|
||||
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue