已关闭
【缺陷报告】数组索引越界 - 文件exp_segsum_grad_tiling.cpp - 函数GetNeedCoreNum - 行号139 #2782
zhangjunkai9创建于 17 天前关闭于 13 天前
陈思
17 天前 评论:
17 天前 评论:
分析结论
已核对当前 master。arch22 路径的 batchStart/batchEnd 固定容量为 50,GetNeedCoreNum 前确实没有像 arch35 路径那样做显式上限裁剪,这属于防御性缺口。
但 Issue 以“Ascend 910B 的 AIV 核数可达 64+”证明越界可达,目前未提供对应平台资料或实测值;现有代码路径属于 arch22,而 64 核上限来自另一架构路径的可能性较高。因此暂不能确认受支持的 arch22 平台上 coreNum > 50,也不能认定越界已可达。
建议后续无论平台值如何都按数组容量显式裁剪或校验;同时请补充具体 SoC、GetCoreNumAiv()/compileInfo 实测值及复现,便于确认影响范围。


13 天前 将 Nice_try 设为负责人
13 天前 关联了pull request:fix(exp_segsum_grad): clamp coreNumPlatform to MAX_CORE_CONT in arch22 tiling, harden arch22 tiling against zero-size inputs and null pointers.
13 天前 关联了pull request:fix(exp_segsum_grad): clamp coreNumPlatform to MAX_CORE_CONT in arch22 tiling, harden arch22 tiling against zero-size inputs and null pointers.
13 天前 关闭了 issue
13 天前 添加了label:resolved
缺陷信息
缺陷描述
needCoreNum由CeilA2B(batches, averageBatches)计算,当coreNumPlatform > MAX_CORE_CONT(50)时,needCoreNum可超过50,导致第139-142行batchStart[coreIndex]和batchEnd[coreIndex]越界写入。arch35版本在RunTiling中已有防御性截断(if (coreNumPlatform > EXP_SEGSUM_GRAD_MAX_CORE_ARCH35) coreNumPlatform = EXP_SEGSUM_GRAD_MAX_CORE_ARCH35),但arch22版本缺少此保护。Ascend 910B的AIV核数可达64以上,因此needCoreNum完全可能超过50。
事实核查
数据流证据
传播路径:
调用链
可达调用链1 起点:
(entry functions)→ 终点:optiling::ExpSegsumGradTiling::GetNeedCoreNum深度:2修复建议
void ExpSegsumGradTiling::GetNeedCoreNum(uint32_t coreNumPlatform) { if (coreNumPlatform > MAX_CORE_CONT) { coreNumPlatform = MAX_CORE_CONT; } int64_t averageBatches = CeilA2B(batches, coreNumPlatform); needCoreNum = CeilA2B(batches, averageBatches); for (int64_t coreIndex = 0; coreIndex < needCoreNum; coreIndex++) { batchStart[coreIndex] = coreIndex * averageBatches; batchEnd[coreIndex] = std::min((coreIndex + 1) * averageBatches, batches); } }