fallocate on a read-only descriptor does not fail with EBADF
维护者通常 3 天内回复
评估
- 难度
- 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 内容生成。
描述
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 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
sysprog21/elfuse 的其他 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 86/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 3 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 75/100
维护者通常 3 天内回复
-
bug
难度 5/5 一周以上 新手友好度 35/100
维护者通常 3 天内回复
-
bug
难度 4/5 3-5 天 新手友好度 54/100
维护者通常 3 天内回复
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 83/100
nextbsd/nextbsd-userland#434 ·
维护者通常 1 天内回复
-
[YSQL] Local-node initdb reads postgres.bki, but YB clusters bootstrap only from yb_postgres.bki未关闭area/ysql kind/enhancement priority/low status/awaiting-triage
难度 2/5 1-3 小时 新手友好度 72/100
yugabyte/yugabyte-db#35763 ·
维护者通常 1 天内回复
-
category:port-update
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 2 天内回复
-
emerge failure MARK mark-unstable media-kit
难度 2/5 1-3 小时 新手友好度 82/100
macaroni-os/mark-issues#834 ·
-
难度 2/5 1-3 小时 新手友好度 76/100
NVIDIA/open-gpu-kernel-modules#1479 · 2 条评论 ·
维护者通常 1 天内回复