-
-
Notifications
You must be signed in to change notification settings - Fork 164
fix(syscall,vfs): fix SIG derivative when writing partial readable buffer #1375
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
fslongjin
merged 7 commits into
DragonOS-Community:master
from
mistcoversmyeyes:bugfix/writev
Nov 21, 2025
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5fd0d9c
fix(mm/vfs): 修复 writev 无法正确处理部分 iov 为受保护内存空间的情况
mistcoversmyeyes 9dc2604
docs(vfs/syscall): 添加文件系统实现分散写入的 TODO 注释
mistcoversmyeyes af3cd0d
feat(test): 添加 pwritev 性能测试程序
mistcoversmyeyes 8fb3f6d
style: 格式化代码
mistcoversmyeyes 10c624a
fix(syscall/user_access): 修复 潜在的死锁问题
mistcoversmyeyes 50b60cb
style: 格式化代码
mistcoversmyeyes 94bb0fb
test(gvisor): 在自动测试中启用所有的 writev 测试
mistcoversmyeyes File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
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
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
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
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
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -1,6 +1,7 @@ | ||||||
| //! This file contains functions for kernel-space access to user-space data | ||||||
|
|
||||||
| use core::{ | ||||||
| cmp::min, | ||||||
| mem::size_of, | ||||||
| num::NonZero, | ||||||
| slice::{from_raw_parts, from_raw_parts_mut}, | ||||||
|
|
@@ -12,7 +13,7 @@ use defer::defer; | |||||
|
|
||||||
| use crate::{ | ||||||
| arch::MMArch, | ||||||
| mm::{verify_area, MemoryManagementArch, VirtAddr}, | ||||||
| mm::{verify_area, MemoryManagementArch, VirtAddr, VmFlags}, | ||||||
| process::ProcessManager, | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -919,3 +920,118 @@ pub unsafe fn copy_to_user_protected(dest: VirtAddr, src: &[u8]) -> Result<usize | |||||
| _ => Err(SystemError::EFAULT), | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| /// Compute the contiguous accessible length starting at `addr`. | ||||||
| /// | ||||||
| /// Returns the number of bytes that can be accessed before hitting an unmapped | ||||||
| /// page or a page that lacks the requested permissions. | ||||||
| pub fn user_accessible_len(addr: VirtAddr, size: usize, check_write: bool) -> usize { | ||||||
| // log::error!( | ||||||
| // "user_accessible_len(addr: {:?}, size:{:?}, check_write:{:?}", | ||||||
| // addr, | ||||||
| // size, | ||||||
| // check_write | ||||||
| // ); | ||||||
fslongjin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| if size == 0 || addr.is_null() { | ||||||
| return 0; | ||||||
| } | ||||||
|
|
||||||
| // 获取当前进程的 vm (可访问的地址空间) | ||||||
| let vm = match ProcessManager::current_pcb().basic().user_vm() { | ||||||
| Some(vm) => vm, | ||||||
| None => return 0, | ||||||
| }; | ||||||
|
|
||||||
| let vma_read_guard = vm.read_irqsave(); | ||||||
| let mappings = &vma_read_guard.mappings; | ||||||
|
|
||||||
| let mut checked = 0usize; | ||||||
| let mut current = addr; | ||||||
|
|
||||||
| while checked < size { | ||||||
| // 判断当前地址是否落在一个有效 VMA 中 | ||||||
fslongjin marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
| let Some(vma) = mappings.contains(current) else { | ||||||
| break; | ||||||
| }; | ||||||
|
|
||||||
| // 获取地址所在 VMA 的起始地址 和结束地址,访问权限标志,后备的文件和当前VMA第一页映射到文件的哪一页 | ||||||
| let (region_start, region_end, vm_flags, vma_size, file, file_page_offset) = { | ||||||
| let guard = vma.lock_irqsave(); | ||||||
| let region_start = guard.region().start().data(); | ||||||
| let region_end = guard.region().end().data(); | ||||||
| let vm_flags = *guard.vm_flags(); | ||||||
| let vma_size = region_end.saturating_sub(region_start); | ||||||
| let file = guard.vm_file(); | ||||||
| let file_page_offset = guard.file_page_offset(); | ||||||
|
|
||||||
| drop(guard); | ||||||
| ( | ||||||
| region_start, | ||||||
| region_end, | ||||||
| vm_flags, | ||||||
| vma_size, | ||||||
| file, | ||||||
| file_page_offset, | ||||||
| ) | ||||||
| }; | ||||||
|
|
||||||
| // 根据 vm_flags 判断是否具备访问权限 | ||||||
|
||||||
| // 根据 vm_flags 判断是否具备访问权限 | |
| // Check if access permission is available based on vm_flags |
mistcoversmyeyes marked this conversation as resolved.
Show resolved
Hide resolved
mistcoversmyeyes marked this conversation as resolved.
Show resolved
Hide resolved
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.