-
-
Notifications
You must be signed in to change notification settings - Fork 169
fix(ipc): 修复 ShmTest 错误的测试用例 #1674
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
base: master
Are you sure you want to change the base?
fix(ipc): 修复 ShmTest 错误的测试用例 #1674
Conversation
|
在合入之前需要清理多余的提交 |
|
skills的相关的commit要从这个pr里面drop掉 |
ea16ea1 to
ca5cd84
Compare
|
@claude review |
|
Claude finished @fslongjin's task in 6m 12s —— View job Claude's Review of PR #1674I've reviewed the code changes in this PR. Here's my analysis: Todo List:
Summary of ChangesThis PR fixes SysV shared memory test cases (
Code Review FeedbackPositive Aspects
Potential Issues to Verify
Suggestions
Extra Commits That Should Be DroppedThe PR currently includes 5 unrelated commits that should be removed before merging:
The formatting commit ( RecommendationApprove with changes: The SHM fixes look correct and improve Linux compatibility. However, the unrelated commits must be dropped first. If you'd like me to help clean up the branch by dropping these extra commits, please let me know. |
Initialize shmat VM flags with VM_SHARED|VM_MAYSHARE so SHM_RDONLY stays readable. Increase shm map_count when cloning address space. Newly passing: - ShmDeathTest.ReadonlySegment
Populate uid/gid/cuid/cgid and keep only permission bits.
Report shm_{a,d,c}time in seconds and initialize shm_lpid to 0.
Newly passing:
- ShmTest.IpcStat
- ShmTest.ShmCtlSet
Reject shmget size greater than existing segment to match shm_more_checks. Newly passing: - ShmTest.SegmentsSizeFixedOnCreation
Track attachment base to detach all fragments and update map_count once. Avoid premature SHM_DEST cleanup when munmap splits VMAs. Newly passing: - ShmTest.PartialUnmap
ca5cd84 to
bf7328d
Compare
kernel/src/ipc/shm.rs
Outdated
| let current_cred = ProcessManager::current_pcb().cred(); | ||
| let kern_ipc_perm = KernIpcPerm { | ||
| id: shm_id, | ||
| key, | ||
| uid: 0, | ||
| gid: 0, | ||
| _cuid: 0, | ||
| _cgid: 0, | ||
| mode: shmflg & ShmFlags::from_bits_truncate(InodeMode::S_IRWXUGO.bits()), | ||
| uid: current_cred.uid.data(), | ||
| gid: current_cred.gid.data(), | ||
| cuid: current_cred.uid.data(), | ||
| cgid: current_cred.gid.data(), | ||
| mode: shmflg & ShmFlags::PERM_MASK, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个的创建、填写uid/gid的工作应该是可以封装成一个new函数里面做?
| shm_ctim: PosixTimeSpec::now(), | ||
| shm_cprid, | ||
| shm_lprid: shm_cprid, | ||
| shm_lprid: RawPid::new(0), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
为什么是0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Linux 中创建一个新的内存段的函数是 shm.c:new_seg ,这个函数会在创建的时候将 shm_lprid 的值设置为 NULL 。所以这里设置为 0 肯定是没问题的
// ./linux-6.6/ipc/shm.c:705
static int newseg(struct ipc_namespace *ns, struct ipc_params *params) {
// ....
shp->shm_cprid = get_pid(task_tgid(current));
shp->shm_lprid = NULL;
shp->shm_atim = shp->shm_dtim = 0;
shp->shm_ctim = ktime_get_real_seconds();
shp->shm_segsz = size;
shp->shm_nattch = 0;
shp->shm_file = file;
shp->shm_creator = current;
// ...
}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
我加个注释说明一下。
关联到:
shm_test未通过测试用例 #1632