[RISC-V/Linux] fstatfs succeeds for an invalid file descriptor

未关闭 适合新手
#1,688 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

还没有人认领这个 Issue。

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
78/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
c, linux, python

调研方向

fstatfs 处理函数位于 qiling/os/posix/syscall/stat.py,链接到报告中的提交;RISC-V Linux 使用系统调用号 44。请先阅读该处理函数如何获取客户机的 fd 并填充 statfs 缓冲区,然后将其与已经能处理无效描述符的 fstat 路径进行比较。当报告中的探测程序对 fd -1 返回 -1 且 errno 为 EBADF,并且有效描述符仍然成功时,即视为完成。

由索引模型根据 Issue 内容生成。

描述

Describe the bug

For an RV64 Linux guest, fstatfs(-1, valid_buffer) returns success in Qiling instead of failing with EBADF.

Sample Code

#define _GNU_SOURCE
#include <errno.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <sys/vfs.h>
#include <unistd.h>

int main(void)
{
    struct statfs st;
    errno = 0;
    long rc = syscall(SYS_fstatfs, -1, &st);
    printf("fstatfs=%ld errno=%d\n", rc, 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

Linux and QEMU-user return -1 with errno=EBADF. Qiling v1.4.11 returns success for this invalid descriptor.

Additional context

Earlier issue #551 reported fstatfs as unimplemented for an Android guest. This report concerns the implemented RISC-V/Linux path returning success for fd=-1.

The RISC-V syscall number is 44. The current dev source at commit 23ad4fd369a360ad7992d90cb7577f0241061c2b still writes a default statfs structure and reports success without validating the guest fd. That revision was checked in source, not dynamically run for this report.

主要语言
Python
星标
6.2k
派生
806
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

qilingframework/qiling 的其他 Issue

查看 qilingframework/qiling 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。