Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

fallocate on a read-only descriptor does not fail with EBADF

未关闭
#462 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

维护者通常 3 天内回复

@xalestar 已经在做这个了。

开始于 2026年10月23日。

  • #463 来自 @xalestar —— 未关闭

评估

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

调研方向

Start with sys_fallocate in src/syscall/io.c and the aarch64 probe described in the issue. Compare the access-mode check order with Linux vfs_fallocate and run the probe for both ranges on an O_RDONLY descriptor. Done when every supported mode returns EBADF before checking file size, matching the reference kernel.

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

描述

bug

Background

vfs_fallocate (Linux fs/open.c) refuses a descriptor that is not open for writing with EBADF, after the offset, length and mode checks and before it looks at the file size. elfuse's sys_fallocate (src/syscall/io.c:3465 on e9fdbbb) never checks the access mode. For mode 0 it calls host ftruncate only when the request grows the file, so a read-only descriptor gets one of two wrong answers:

fallocate(fd, 0, off, len) on an O_RDONLY fd, file size 200 Linux elfuse
grows the file (0, 400) -1, EBADF -1, EINVAL (from host ftruncate)
stays within the file (0, 100) -1, EBADF 0

The second row reports success for a call Linux refuses.

Goal

fallocate on a descriptor not open for writing fails with EBADF in every mode elfuse supports, ahead of any size check, as on Linux.

Evidence

A static aarch64 probe creates a 200-byte file, reopens it O_RDONLY and calls fallocate with the two ranges above. elfuse built from e9fdbbb gives the elfuse column, and the qemu reference kernel used by make test-matrix-qemu-aarch64 gives the Linux column.

Found while adding RLIMIT_FSIZE enforcement (#448 follow-up 1): the new test-rlimit-fsize only checks that the call fails there without SIGXFSZ, not which errno it returns.

主要语言
C
星标
275
派生
29
平均合并
2 天 22 小时
30 天内合并 PR
18

环境准备

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

从这里开始

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

sysprog21/elfuse 的其他 Issue

查看 sysprog21/elfuse 的全部 Issue

相似的 Issue

更多 C Issue

把新 issue 发到你的邮箱

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