Repository navigation
fix(process): drop arch_info lock before copying fs/gs base to user - #2718
Merged
fslongjin merged 1 commit intoNov 27, 2026
Merged
Conversation
Member
|
LGTM |
fslongjin
approved these changes
Nov 27, 2026
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.
Fixes #2717
背景
arch_prctl(ARCH_GET_FS/ARCH_GET_GS)在持有arch_info(lock_irqsave)时把 fsbase/gsbase 写回用户内存。目标页还没有页表项时,这次写入在持锁期间触发缺页;缺页处理要取地址空间的写锁,被别的线程持有时会睡眠,schedule()里的preempt_count() == 0断言失败,内核 panic。根因
do_arch_prctl_64()开头取得的arch_info守卫一直活到copy_one_to_user()之后,用户内存的写入落在自旋锁临界区里。修复方案
两个 GET 分支在保存寄存器后先把值复制出来、
drop掉arch_info,再调用copy_one_to_user()。ARCH_SET_*分支不访问用户内存,不变。验证
新增 dunitest 测例
normal/arch_prctl_fault(加入whitelist.txt):一个线程反复 mmap 并写入 64 MiB 匿名内存,主线程对新映射的页反复做ARCH_GET_FS,检查返回 0 且结果与先前取得的值相同。src/sched/mod.rs:1219,left: 1, right: 0)。