fix(mm): 修复madvise和msync系统调用中的边界处理问题#1345
Merged
fslongjin merged 1 commit intoDragonOS-Community:masterfrom Nov 6, 2025
Merged
fix(mm): 修复madvise和msync系统调用中的边界处理问题#1345fslongjin merged 1 commit intoDragonOS-Community:masterfrom
fslongjin merged 1 commit intoDragonOS-Community:masterfrom
Conversation
Member
fslongjin
commented
Nov 6, 2025
- 修复madvise长度参数未对齐时的处理逻辑,添加长度向上舍入和溢出检查
- 优化msync系统调用中的VMA查找逻辑,修复锁竞争和边界条件问题
- 修复UserMappings::find_nearest中的VMA查找逻辑错误
- 启用madvise测试
Contributor
There was a problem hiding this comment.
Pull Request Overview
This pull request adds support for the madvise system call and fixes critical bugs in VMA (Virtual Memory Area) traversal logic. The changes improve memory management functionality and resolve issues related to memory mapping operations.
- Enables
madvise_testin the test whitelist with specific blocked test cases - Fixes the
find_nearestVMA search logic to correctly find the next VMA after a given address - Refactors
sys_msyncto release locks before callingfind_nearest, preventing potential deadlocks - Updates
sys_madviseto properly handle unaligned length parameters and overflow conditions
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| user/apps/tests/syscall/gvisor/whitelist.txt | Adds madvise_test to the test suite |
| user/apps/tests/syscall/gvisor/blocklists/madvise_test | Defines blocked test cases for madvise (DontforkShared and DontforkAnonPrivate) |
| user/apps/tests/syscall/gvisor/blocklists/fork_test | Adds detailed comments explaining glibc error with COWSegment test |
| kernel/src/mm/ucontext.rs | Fixes find_nearest logic to search forward instead of backward |
| kernel/src/mm/syscall/sys_msync.rs | Refactors to release VMA lock before calling find_nearest, preventing deadlock |
| kernel/src/mm/syscall/sys_madvise.rs | Updates to handle unaligned length with proper overflow checking |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- 修复madvise长度参数未对齐时的处理逻辑,添加长度向上舍入和溢出检查 - 优化msync系统调用中的VMA查找逻辑,修复锁竞争和边界条件问题 - 修复UserMappings::find_nearest中的VMA查找逻辑错误 - 启用madvise测试 Signed-off-by: longjin <longjin@DragonOS.org>
7b362b5 to
9e25976
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.