Pull Request已成功合入, 合并人@CANN-robot
(感谢 ccs 的贡献)变更摘要
本 PR 针对 Issue #674,在 HcclAlltoAllV 的参数校验函数 CheckAlltoAllInputPara(位于 src/ops/all_to_all_v/all_to_all_v.cc)中新增了对 sendType 数据类型的合法性校验:当 sendType >= HCCL_DATA_TYPE_RESERVED 时判定为非法参数,记录错误日志并返回 HCCL_E_PARA,从而在原有空指针、缓冲区相同、大小溢出等校验基础上补齐了数据类型的边界检查,避免非法数据类型进入后续处理流程。
主要改动
- 新增
sendType合法性校验: 在CheckAlltoAllInputPara中增加CHK_PRT_RET检查,当sendType大于等于HCCL_DATA_TYPE_RESERVED时输出"sendType[%u] is invalid"错误并返回HCCL_E_PARA,将非法数据类型在入口处拦截。 - 错误码与返回路径统一: 新增校验沿用既有的
HCCL_ERROR日志与HCCL_E_PARA参数错误码约定,与同函数内其他参数校验(如空指针、sendBuf/recvBuf相同、大小溢出)保持一致的处理方式。


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 |
|---|---|---|
| src | ✅ 李标智, 陈毅 (2/2) | ✅ 李标智 (1/1) |
💡 Tip:
- Committer can comment
/approveor/lgtm- Commenting
/approveimplies both code review (lgtm) and intent to merge (approve)
CLA Signature Pass
cuishuang1, thanks for your pull request. All authors of the commits have signed the CLA. 👍


/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


下标 ≥ 18 即会读到无意义的 0 值(非越界,但语义错误);下标 ≥ 255 才是真正的数组越界。
当255> sendType≥18 时,会返回0,那么下面sendCount > UINT64_MAX / DATATYPE_SIZE_TABLE[sendType]会有除0风险


changed this line on c048eb1e view diff detail
/compile


| 🚀 CI 流水线已启动 |
|---|
| 📋 执行详情: 点击查看流水线 |


描述
HcclAlltoAll 的参数校验函数 CheckAlltoAllInputPara 中存在数组越界风险:
校验流程中,溢出检查语句在确认 sendType 是否为合法 HcclDataType 之前,
就使用 sendType 作为下标访问 DATATYPE_SIZE_TABLE:
DATATYPE_SIZE_TABLE 数组长度为 HCCL_DATA_TYPE_RESERVED,合法下标范围是
0 ~ HCCL_DATA_TYPE_RESERVED - 1。当外部传入 sendType = recvType =
HCCL_DATA_TYPE_RESERVED 时:
构成 one-past-the-end 越界访问;
修改方案
在溢出检查访问 DATATYPE_SIZE_TABLE 之前,新增 sendType 合法性校验,
不合法时直接返回 HCCL_E_PARA:
关联的Issue
https://gitcode.com/cann/hccl/issues/674
测试
RDV
文档更新
类型标签