登录
注册
开源
企业版
高校版
搜索
帮助中心
使用条款
关于我们
开源
企业版
高校版
私有云
模力方舟
登录
注册
代码拉取完成,页面将自动刷新
开源项目
>
其他开源
>
操作系统
&&
捐赠
捐赠前请先登录
取消
前往登录
扫描微信二维码支付
取消
支付完成
支付提示
将跳转至支付宝完成支付
确定
取消
Watch
不关注
关注所有动态
仅关注版本发行动态
关注但不提醒动态
29
Star
70
Fork
379
openEuler
/
qemu
代码
Issues
37
Pull Requests
11
Wiki
统计
流水线
服务
质量分析
Jenkins for Gitee
腾讯云托管
腾讯云 Serverless
悬镜安全
阿里云 SAE
Codeblitz
SBOM
我知道了,不再自动展开
1525
【轻量级 PR】:system/physmem: fix use-after-free with dispatch
已关闭
N/A
openEuler:qemu-8.2.0
guping
创建于 2025-08-01 10:26
克隆/下载
HTTPS
SSH
复制
下载 Email Patch
下载 Diff 文件
cherry-pick from 2865bf1c5795371ef441e9029bc22566ccff8299 A use-after-free bug was reported when booting a Linux kernel during the pci setup phase. It's quite hard to reproduce (needs smp, and favored by having several pci devices with BAR and specific Linux config, which is Debian default one in this case). After investigation (see the associated bug ticket), it appears that, under specific conditions, we might access a cached AddressSpaceDispatch that was reclaimed by RCU thread meanwhile. In the Linux boot scenario, during the pci phase, memory region are destroyed/recreated, resulting in exposition of the bug. The core of the issue is that we cache the dispatch associated to current cpu in cpu->cpu_ases[asidx].memory_dispatch. It is updated with tcg_commit, which runs asynchronously on a given cpu. At some point, we leave the rcu critial section, and the RCU thread starts reclaiming it, but tcg_commit is not yet invoked, resulting in the use-after-free. It's not the first problem around this area, and commit 0d58c660689 [1] ("softmmu: Use async_run_on_cpu in tcg_commit") already tried to address it. It did a good job, but it seems that we found a specific situation where it's not enough. This patch takes a simple approach: remove the cached value creating the issue, and make sure we always get the current mapping for address space, using address_space_to_dispatch(cpu->cpu_ases[asidx].as). It's equivalent to qatomic_rcu_read(&as->current_map)->dispatch; This is not really costly, we just need two dereferences, including one atomic (rcu) read, which is negligible considering we are already on mmu slow path anyway. Note that tcg_commit is still needed, as it's taking care of flushing TLB, removing previously mapped entries. Another solution would be to cache directly values under the dispatch (dispatch themselves are not ref counted), keep an active reference on associated memory section, and release it when appropriate (tricky). Given the time already spent debugging this area now and previously, I strongly prefer eliminating the root of the issue, instead of adding more complexity for a hypothetical performance gain. RCU is precisely used to ensure good performance when reading data, so caching is not as beneficial as it might seem IMHO. [1] https://gitlab.com/qemu-project/qemu/-/commit/0d58c660689f6da1e3feff8a997014003d928b3b Cc: qemu-stable@nongnu.org Resolves: https://gitlab.com/qemu-project/qemu/-/issues/3040 Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> Reviewed-by: Richard Henderson <richard.henderson@linaro.org> Reviewed-by: Michael Tokarev <mjt@tls.msk.ru> Tested-by: Michael Tokarev <mjt@tls.msk.ru> Message-ID: <20250724161142.2803091-1-pierrick.bouvier@linaro.org> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
此 Pull Request 需要通过一些审核项
类型
指派人员
状态
审查
alexchen
ZhangBo
朱科潜
ZhiGang
Chuan
yezengruan
Bin Wu
frankyj915
imxcc
已完成
(0/0人)
怎样手动合并此 Pull Request
git checkout qemu-8.2.0
git pull https://gitee.com/openeuler/qemu.git N/A
git push origin qemu-8.2.0
评论
8
提交
1
文件
1
检查
代码问题
0
批量操作
展开设置
折叠设置
审查
Code Owner
审查人员
Chuan
Chuan-Zheng
Bin Wu
RootWB
ZhiGang
cellfaint
朱科潜
kevinzhu1
alexchen
zhendongchen
ZhangBo
ooorz
avenLiu
aven6
yezengruan
yezengruan
黄勇
Hyman-Huang
frankyj915
frankyj915
imxcc
imxcc
未设置
最少人数
0
测试
Chuan
Chuan-Zheng
Bin Wu
RootWB
ZhiGang
cellfaint
朱科潜
kevinzhu1
alexchen
zhendongchen
ZhangBo
ooorz
avenLiu
aven6
yezengruan
yezengruan
黄勇
Hyman-Huang
frankyj915
frankyj915
imxcc
imxcc
未设置
最少人数
0
优先级
不指定
严重
主要
次要
不重要
标签
openeuler-cla/yes
ci_failed
sig/Virt
关联 Issue
未关联
Pull Request 合并后将关闭上述关联 Issue
里程碑
未关联里程碑
参与者
(2)
C
1
https://gitee.com/openeuler/qemu.git
git@gitee.com:openeuler/qemu.git
openeuler
qemu
qemu
点此查找更多帮助
搜索帮助
Git 命令在线学习
如何在 Gitee 导入 GitHub 仓库
Git 仓库基础操作
企业版和社区版功能对比
SSH 公钥设置
如何处理代码冲突
仓库体积过大,如何减小?
如何找回被删除的仓库数据
Gitee 产品配额说明
GitHub仓库快速导入Gitee及同步更新
什么是 Release(发行版)
将 PHP 项目自动发布到 packagist.org
仓库举报
回到顶部
登录提示
该操作需登录 Gitee 帐号,请先登录后再操作。
立即登录
没有帐号,去注册