Skip to content

Commit

Permalink
[lwp] Implementation of setpgrp and fix mmap2 problems (#9308)
Browse files Browse the repository at this point in the history
* mmap2 failure handling

当传入一个非常大的地址时,offset会计算得到一个值,又因为传入的地址错误,rc会得到错误码,结合offset会得到一个很奇怪的值。

* Implementation of setpgrp

执行setpgrp会走到这一步,在执行getpgrp无法得到创建的group的值

* Modify the return method of mmap
  • Loading branch information
rcitach authored Aug 22, 2024
1 parent 9d95ad9 commit 9a84c13
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
12 changes: 12 additions & 0 deletions components/lwp/lwp_pgrp.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,18 @@ sysret_t sys_setpgid(pid_t pid, pid_t pgid)
if (group == RT_NULL)
{
group = lwp_pgrp_create(process);
lwp_pgrp_move(group, process);
session = lwp_session_find(sid);
if (session == RT_NULL)
{
LOG_E("the session of sid: %d cannot be found", sid);
err = -EPERM;
goto exit;
}
else
{
lwp_session_insert(session, group);
}
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion components/lwp/lwp_syscall.c
Original file line number Diff line number Diff line change
Expand Up @@ -1229,7 +1229,7 @@ void *sys_mmap2(void *addr, size_t length, int prot,
rc = (sysret_t)lwp_mmap2(lwp_self(), addr, length, prot, flags, fd, pgoffset);
}

return (char *)rc + offset;
return rc < 0 ? (char *)rc : (char *)rc + offset;
}

sysret_t sys_munmap(void *addr, size_t length)
Expand Down

0 comments on commit 9a84c13

Please sign in to comment.