Skip to content

Conversation

@sunhaosheng
Copy link
Contributor

  1. read child pid/exit_code before free in waitpid

In sys_waitpid, child.pid() and child.exit_code() were read after calling child.free(), which could lead to use-after-free issues.

Fix: Read pid and exit_code before calling free().

  1. PR_SET_MM Handling in prctl

File: api/src/syscall/task/ctl.rs

Bug Description:
The prctl syscall was incorrectly matching PR_SET_MM_* constants at the top level instead of as sub-options of PR_SET_MM.

Fix:
Restructured the match to properly handle PR_SET_MM with its sub-options:

PR_SET_MM => match arg2 as u32 {
    PR_SET_MM_START_CODE | PR_SET_MM_END_CODE | ... => {}
    _ => return Err(AxError::InvalidInput),
}
  1. Added mincore Syscall Stub

File: api/src/syscall/mm/mmap.rs

Description:
Added sys_mincore that returns ENOSYS (Unsupported). This is safer than returning incorrect data and lets programs use fallback logic.

In sys_waitpid, child.pid() and child.exit_code() were read after
calling child.free(), which could lead to use-after-free issues.

Fix: Read pid and exit_code before calling free().
PR_SET_MM_* constants were incorrectly matched at the top level of
prctl instead of as sub-options of PR_SET_MM.

Fix: Restructure the match to handle PR_SET_MM with its sub-options
properly, and add more PR_SET_MM sub-options (BRK, ARG_*, ENV_*, etc.)
Add sys_mincore that returns ENOSYS (Unsupported). This is safer than
returning incorrect data and lets programs use fallback logic.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants