Merged
[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release #1126
FengHaozhanAdd on 22 days ago
[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release #1126
Merged
Merged fromFengHaozhan/opbasefix-core-9.2.0intocann/opbase9.2.0
Pull Request has been successfully merged by CANN-robot.
(Thank you for FengHaozhan's contribution.)22 days ago Created pull request, commit b46e93d5
22 days ago Associated issue: [Bug-Report|缺陷反馈]: 算子复用cache执行期没有强持有proto内存,存在UAF窗口
atomgit-bot
22 days ago Comments:
22 days ago Comments:
变更摘要
该 PR 为修复 AICPU 算子反复切流场景下 CpuKernelCache 缓存释放引发的 coredump(Issue #486):根因是异步执行期间 FIFO 缓存队列压满后队首算子的 nodedef proto 内存被释放,形成 UAF 窗口。改动通过在缓存命中时同时持有 context 与 nodedef proto,并将异步路径改为以 shared_ptr 值捕获相关对象,使 lambda 回调执行期间相关对象生命周期得以延长。
主要改动
DispatchCpuKernel接口签名调整:cpu_kernel_cache.h中将参数由CpuKernelContext&、ExtInfoMsg&引用改为const std::shared_ptr<CpuKernelContext>&、const std::shared_ptr<ExtInfoMsg>&,并新增const std::shared_ptr<NodeDef>& nodedef_proto参数,以便在调度链路中传递并延长 nodedef proto 的生命周期。- 异步回调改为值捕获共享指针: 异步分支的
cblambda 由捕获栈上引用改为按值捕获ctx、ext_info_msg、nodedef_proto,回调内部以UpdateFWKOutputShape(*ext_info_msg, *ctx)解引用,并通过(void)nodedef_proto;保留该 proto 的持有,避免回调执行期间对象已被释放。 - 缓存命中时同步取出 nodedef proto:
GetCpuKernelContext的缓存命中分支新增nodedef_proto = cache->proto;,在返回cache->context的同时持有对应的 nodedef proto。 - Block 路径同步相同处理:
GetCpuKernelContextWithBlock的缓存命中分支同样新增nodedef_proto = cache->proto;,保证带 Block 的调用路径具备一致的生命周期保护。 - 调用点适配新签名:
RunKernel与RunCpuKernelWithBlock中改为以DispatchCpuKernel(ctx, ext_info_msg, node_def_proto)调用,同步/异步执行分支统一通过解引用后的*ctx、ext_info_msg->...访问参数。


Incorrect?
atomgit-bot
22 days ago Comments:
22 days ago Comments:
22 days ago Added label: stat/needs-squash
22 days ago Added label: cann-cla/yes
CANN-robot
22 days ago Comments:
22 days ago Comments:
Thanks for your pull-request.
The full list of commands accepted by me can be found at here.
You can get sig-info at here.
You can self-configure the PR merge rules for this repository. For more details, please refer to Here.
For more, you also can visit HICANN.
PR Approval Progress
✅ Congratulations! All modules have met the lgtm and approve requirements.
Module Approval Details
| module | lgtm status | approve status |
|---|---|---|
| 9.2.0 | ✅ Andy-lb, 刘伟 (2/2) | ✅ Andy-lb (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
FengHaozhan, thanks for your pull request. All authors of the commits have signed the CLA. 👍


22 days ago Set pengjiahao96,FelixTang7,zhou-qilong,wangrui_,rxtfeng,loov1,TianXL,jia0liang,zl_hw,liu-wei,LiWei79,songkai111,jiangtao_rts,gitcode-chenjiao,hanxiaolong,pingchuantang,llimwang,gubaocheng,gcw_kUomxQ2l,Andy-lb as approver
22 days ago Set pengjiahao96,FelixTang7,zhou-qilong,wangrui_,rxtfeng,loov1,TianXL,jia0liang,zl_hw,liu-wei,LiWei79,songkai111,jiangtao_rts,gitcode-chenjiao,hanxiaolong,pingchuantang,llimwang,gubaocheng,gcw_kUomxQ2l,Andy-lb as approver
22 days ago Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
22 days ago Set TianXL,jiangtao_rts,gitcode-chenjiao,hanxiaolong,gcw_kUomxQ2l,Andy-lb as approver
22 days ago Change title to "[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release", originally titled "[fix][fix-core-9.2.0] Fix the coredump bug caused by AICPU cache release".
22 days ago Change title to "[Fix][9.2.0] Fix the coredump bug caused by AICPU cache release", originally titled "[fix][fix-core-9.2.0] Fix the coredump bug caused by AICPU cache release".
FengHaozhan
22 days ago Comments:
22 days ago Comments:
compile


22 days ago Pre merge succeeded (commit_id: 7c54194635610088f07706e4489f182aa8f53108)
CANN-robot
22 days ago Comments:
22 days ago Comments:
| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


22 days ago Added label: ci-pipeline-running
22 days ago Removed label: ci-pipeline-running
22 days ago Added label: ci-pipeline-passed
21 days ago Added label: SC-SUCC
21 days ago Added label: BUILD-SUCC
Andy-lb
21 days ago Comments:
21 days ago Comments:
/approve


21 days ago Added label: approved
liu-wei
21 days ago Comments:
21 days ago Comments:
/lgtm


21 days ago Added label: lgtm
21 days ago Merged pull request
描述
修复 AICPU 算子反复切流导致的 coredump 问题,问题及原因见 Issue。
修复方案:当 AICPU 算子缓存命中时,持有 context 的同时持有 nodedef proto,避免 FIFO 缓存队列压满后队首算子的 nodedef proto 内存被释放,从而消除异步执行期间的 UAF 窗口。
关联的Issue
#486
测试
cmake --build build --target aicpu_context_host -j8通过cmake --build build/device_build --target aicpu_context aicpu_cust_log -j8通过git diff --check通过文档更新
不涉及
类型标签