Repository navigation
feat(rkp): 加入 --rkp-probe 多变异诊断 - #5
Merged
Merged
Conversation
真机上 challenge 能取到,但 send_cmd 返回 0 且响应缓冲区零字节 (written: 0、status_le: 0),既不是帧格式问题也不是长度字段问题。 这类"空成功"只靠一次调用无法区分原因,因此把可疑变量拆开逐项试探。 - ta 层拆出 CallOptions:缓冲区初始化(哨兵 / 全 0 / 前 4 字节写容量)、 security_level(1 / 0)、请求封装(裸 / 长度前缀) - 新增 6 个变体,每个变体在独立子进程中 dlopen 并调用一次, 某个变体触发崩溃只丢失该组结果 - 记录 status、written、request_changed、response_head, request_changed 用于判断 out 参数是否落在请求缓冲区上 - 哨兵残留时直接报 abi,不再让上层去猜帧格式 - 新增 CLI --rkp-probe 与隐藏入口 --rkp-ta-probe,输出 JSON 对照表 主机 111 项测试通过(新增帧封装、写入量、请求改写、变体唯一性)。 四 ABI release:arm64 922,984 字节,包 2,104,262 字节。
设备侧检查排除了权限:keystore2 正常运行,dmesg 里没有任何涉及 teeforge 或 smcinvoke 的 avc 拒绝。公开代码里也找不到第二份 libkeymasterdeviceutils 的调用示例,上游那套「0x40 对象 + 哨兵 + 参数顺序」只是单点观察。 因此再补两个维度: - CallOptions.object_size:0x40 / 0x80 / 0x100 三个变体。对象存储改用 16 字节对齐的动态缓冲区,并统一预留 0x100 尾部余量——如果固件对象 比 0x40 大,构造会写越界,没有余量就会破坏相邻堆数据,反而让探测 结果失去意义 - 新增 rkp/elf.rs:极简 ELF64 动态符号解析,列出 KeymasterUtils 与 send_cmd 相关导出符号,随探测输出为 library_symbols,用于判断是否 存在必须先调用的初始化入口或其它重载;读取失败不影响探测 变体 6 -> 8,README 与 ARCHITECTURE 的判读表同步。 主机 115 项测试通过(新增 4 项 ELF 解析用例)。 四 ABI release:arm64 927,032 字节,包 2,112,878 字节。
Owner
Author
|
补充两项诊断维度(提交
设备侧检查结论(供对照): 主机 115 项测试通过,四 ABI 与打包均已通过。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
PR #4 的修复上线后,真机(小米 17 Pro)的错误变成了:
{"error":{"code":"unparsed","stage":"frame", "message":"无法识别 TA 响应帧", "raw":{"buffer":40960,"written":0,"status_le":0, "head_hex":"0000…0000"}},"ok":false}日志显示
challenge已成功获取(RKP 传输工具: curl之后才失败),所以:send_cmd返回 0(TA 没有拒绝)written: 0、status_le: 0)注意
status_le是 0 而不是哨兵0x80000000的00000080,说明厂商确实写过前 4 字节,只是没写任何数据。这是「空成功」,既不是帧格式问题,也不是长度字段问题,单次调用无法继续区分原因。改动
把可疑变量拆开逐项试探,一次装包拿回对照数据。
CallOptions三个维度:security_level6 个变体:
baselinezero-buffercapacity-headersmall-bufferlevel-0length-prefix每个变体独立子进程:重新 dlopen、重新构造对象。某个变体触发崩溃只丢失该组,而不是整轮探测;
security_level不同也无法复用同一个对象。输出字段:
status:send_cmd返回值written:响应最后一个非零字节位置request_changed:请求缓冲区是否被厂商改写 → 判断 out 参数是否落在了请求缓冲区上request_before/request_after/response_head:各 64 字节 hex另外,哨兵残留时直接报
frame/abi,不再让上层去猜帧格式。判读表(已写入 README)
baseline空、zero-buffer有数据written均为 0 且request_changed为 falserequest_changed为 truelevel-0有数据security_level = 0length-prefix有数据crashed: true使用
会消耗一次 Google RKP challenge,不写任何产物、不改后端配置。
验证
cargo test -p teeforge:111 项通过(新增 5 项:帧封装、写入量、请求改写、变体唯一性)cargo clippy --all-targets、cargo fmt --check:通过xtask package2,104,262 字节,verify通过--rkp-probe --json:正确返回prerequisite/arch阻断(主机非 arm64)真机探测结果待回传,结论会更新到 ROADMAP。
说明
--rkp-issue仍是「哨兵 + level 1 + 裸帧」,探测只用于诊断