[HUST CSE][libcpu][arm]fix MPU region validation operator precedence#11311
[HUST CSE][libcpu][arm]fix MPU region validation operator precedence#11311Telecaster2147 wants to merge 1 commit intoRT-Thread:masterfrom
Conversation
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
| if ((region->size & (~(MPU_MIN_REGION_SIZE - 1U))) != region->size) | ||
| { | ||
| LOG_E("Region size is not a multiple of 32 bytes"); | ||
| return RT_FALSE; |
There was a problem hiding this comment.
好像check没有通过,但是似乎是因为原先这里写的返回值没有用负值,要求修改成-RT_FALSE这种,需要一并修改吗(๑•̀ㅂ•́)
拉取/合并请求描述:(PR description)
[
为什么提交这份PR (why to submit this PR)
Cortex-M33 与 Cortex-M7 的 MPU region 参数校验存在运算符优先级错误,!= 的优先级高于 & 的优先级,会导致校验语义被改写,从而可能把不合法的 region 当作合法配置写入 MPU,带来保护失效或异常风险。
你的解决方案是什么 (what is your solution)
在 libcpu/arm/cortex-m33/mpu.c 与 libcpu/arm/cortex-m7/mpu.c 中,为 size 与 start 对齐相关的按位与表达式补齐括号
请提供验证的bsp和config (provide the config and bsp)
]
当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following: