Repository navigation
[drivers][block] reject GPT entries with ending_lba before starting_lba - #11978
BernardXiong wants to merge 1 commit into
Conversation
is_pte_valid() accepted a GPT entry as long as both LBAs were inside the disk, so a crafted image could set ending_lba < starting_lba. The size computed in efi_partition() then underflowed to a huge value and was registered as the logical partition size. Reject entries whose end LBA is below the start LBA, and compute the partition start/size only after the entry passed validation. This avoids evaluating the underflow at all and reuses the validated start value for the size calculation. Fixes RT-Thread#11271. Co-authored-by: DeepSeek 4.1 Flash <noreply@deepseek.com>
|
👋 感谢您对 RT-Thread 的贡献!Thank you for your contribution to RT-Thread! 为确保代码符合 RT-Thread 的编码规范,请在你的仓库中执行以下步骤运行代码格式化工作流(如果格式化CI运行失败)。 🛠 操作步骤 | Steps
完成后,提交将自动更新至 如有问题欢迎联系我们,再次感谢您的贡献!💐 |
📌 Code Review Assignment🏷️ Tag: componentsReviewers: @Maihuanyi Changed Files (Click to expand)
📊 Current Review Status (Last Updated: 2026-11-03 07:18 CST)
📝 Review Instructions
|
|
拉取/合并请求描述:(PR description)
为什么提交这份PR (why to submit this PR)
这是对 #11275 的重做(原 PR 已过时)。修复 #11271。
is_pte_valid()只要求starting_lba、ending_lba都在磁盘范围内,没有检查ending_lba >= starting_lba。构造一个 CRC 有效的 GPT 镜像即可让efi_partition()中的发生无符号下溢,得到一个巨大的分区大小,并作为逻辑分区注册。
你的解决方案是什么 (what is your solution)
is_pte_valid()中增加end < start判断,拒绝首尾颠倒的分区条目;start/size的计算移到合法性检查之后,并用已校验的start计算size,从源头避免下溢计算被求值。改动只涉及
components/drivers/block/partitions/efi.c一个文件,复用现有的 GPT 校验流程,没有引入新接口。请提供验证的bsp和config (provide the config and bsp)
BSP: bsp/qemu-vexpress-a9
.config: CONFIG_RT_USING_BLK=y, CONFIG_RT_BLK_PARTITION_EFI=y
action: 已使用 arm-none-eabi 工具链本地编译
components/drivers/block/partitions/efi.c通过;完整构建由 CI 验证。当前拉取/合并请求的状态 Intent for your PR
必须选择一项 Choose one (Mandatory):
代码质量 Code Quality:
我在这个拉取/合并请求中已经考虑了 As part of this pull request, I've considered the following:
#if 0代码,不包含已经被注释了的代码 All redundant code is removed and cleaned up本 PR 由 DeepSeek 4.1 Flash 协同完成。