[RISC-V/Linux] getrandom with a zero-length buffer triggers an assertion
还没有人认领这个 Issue。
评估
调研方向
该错误位于 qiling/os/posix/syscall/random.py 中的 ql_syscall_getrandom,它将零大小传给映射内存写入辅助函数,而该函数断言大小为正数。请先阅读该函数及其调用的辅助函数,然后使用 buflen=0 运行示例探测脚本,复现 AssertionError。完成标准是:零长度的 getrandom 返回 0 且不触碰缓冲区,正长度的情况仍返回 8。
由索引模型根据 Issue 内容生成。
描述
Describe the bug
An RV64 Linux guest that calls getrandom() with a valid mapped buffer and buflen=0 triggers an AssertionError in Qiling. Linux defines a zero-length request as a successful call returning zero.
Sample Code
#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <unistd.h>
int main(void)
{
unsigned char buf[8];
long first = syscall(SYS_getrandom, buf, sizeof(buf), 0);
printf("positive=%zd\n", first);
fflush(stdout);
errno = 0;
long zero = syscall(SYS_getrandom, buf, 0, 0);
printf("zero=%zd errno=%d\n", zero, errno);
return 0;
}
riscv64-linux-gnu-gcc -static -O2 -Wall -Wextra probe.c -o probe.elf
mkdir -p rootfs
python3 - <<'PY'
from qiling import Qiling
ql = Qiling(["./probe.elf"], "./rootfs")
ql.run()
PY
Expected behavior
The first call returns 8; the zero-length call returns 0 without accessing the buffer. QEMU-user and native Linux produce {8, 0}. With the current Qiling dev build, the first call prints 8 and the second raises AssertionError.
Additional context
Reproduced on Qiling commit 23ad4fd369a360ad7992d90cb7577f0241061c2b under RV64 Linux. The current ql_syscall_getrandom passes the zero size to the mapped-memory helper, which asserts that the requested size is positive.
- 主要语言
- Python
- 星标
- 6.2k
- 派生
- 806
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
qilingframework/qiling 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 62/100
qilingframework/qiling#1690 ·
-
难度 2/5 1-3 小时 新手友好度 78/100
qilingframework/qiling#1688 ·
-
难度 2/5 1-3 小时 新手友好度 80/100
qilingframework/qiling#1686 ·
-
难度 2/5 半天 新手友好度 82/100
qilingframework/qiling#1640 ·
-
Linked to wiki installation instructions from source are incorrect可能已有人在做 关联的 PR 仍在进行中或已合并。 未关闭
难度 1/5 1-3 小时 新手友好度 78/100
qilingframework/qiling#1628 ·
查看 qilingframework/qiling 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 78/100
huggingface/datasets#9128 ·
维护者通常 1 天内回复
-
priority:low ready-for-dev
难度 2/5 1-3 小时 新手友好度 68/100
OpenHands/extensions#975 ·
维护者通常 1 天内回复
-
Function/dict state handlers can't supply provider-state injected values (`generate.provider_state`)未关闭
难度 2/5 1-3 小时 新手友好度 78/100
pact-foundation/pact-python#1789 ·
维护者通常 9 天内回复
-
documentation
难度 2/5 1-3 小时 新手友好度 82/100
juandresrodca/AdminForge#66 ·
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复