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

eventfd, abstract socket and FUSE cleanup still match by fd number

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

维护者通常 2 天内回复

还没有人认领这个 Issue。

评估

难度
4/5
预计耗时
3-5 天
新手友好度
35/100
Issue 类型
缺陷
描述清晰度
基本清楚
活跃度
活跃
技术栈
c
领域
backend

调研方向

Start by reading #408 and the fd-generation handling in src/syscall/fd.c; then trace eventfd_close and sys_eventfd2, absock_fd_cleanup and sys_close in src/syscall/net.c, and the FUSE cleanup paths in src/syscall/fuse.c. Run tests/test-special-fd-reuse.c and the eventfd reproduction described here. Done means cleanup cannot affect a replacement fd or lose its reference, and the reproduced reuse failures are fixed.

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

描述

bug

fd_cleanup_entry runs a type's cleanup callback after fd_snapshot_and_close has freed the guest fd number, so a sibling thread's open can hold the number before the callback runs. #408 hands the callback the generation of the slot being closed, and pidfd, usbdev, timerfd, signalfd, inotify and netlink tear down by it. Three callbacks receive the generation and still match on the fd number alone:

  • eventfd_close (src/syscall/fd.c) reads eventfd_owner[guest_fd], clears it and drops a reference on that slot. When a sibling's eventfd2 has taken the number and set its own mapping, the close clears that mapping and drops that eventfd's reference. Aliases share one slot through eventfd_owner[], so the generation belongs on each owner mapping, not on the slot. sys_eventfd2 has a second window on the create side: fd_alloc publishes the fd before eventfd_owner[gfd] is written under sfd_lock. A close in that window finds no owner and drops no reference, and the write that follows leaves the slot holding a reference no fd owns. When the number has been reused by then, the write also replaces the other eventfd's mapping. eventfd_dup_fd closes this window for its destination by reserving the reference before the fd is published and committing under fd_lock and sfd_lock; sys_eventfd2 does neither.
  • absock_fd_cleanup (src/syscall/net.c) calls absock_unregister_fd(guest_fd), which unlinks the socket file of the absock_table entry holding that number and deactivates it. When a sibling has bound an abstract name on the reused number, its name is removed while its socket is open. sys_close also calls absock_unregister_fd directly, by number, ahead of the close, so keying the table by generation means that caller has to read the fd's generation first.
  • fuse_fd_cleanup (src/syscall/fuse.c) calls fuse_unbind_file_fd_locked(guest_fd) and fuse_unbind_dev_fd_locked(guest_fd), and both match guest_fd alone. A close that reaches a replacement's binding removes it and drops its alias reference. The bindings are shared between aliases through a refcount, so the per-fd match the other tables use does not carry over unchanged.

eventfd is reproduced; abstract sockets and FUSE are not. Four threads that each run eventfd, dup, close of the dup, an 8-byte write and read, and close for 1000 rounds: 3206 to 3252 of the 4000 eventfd() calls return ENOMEM over three runs, 18 to 23 of the write-read pairs fail, and with every fd closed afterwards 1 of the 32 slots can be allocated. tests/test-special-fd-reuse.c from #408 is the same shape: four threads that open, dup and close one kind of fd, each checking the fd it holds with a call that fails once the state behind it is gone. That test failed 5 of 5 runs for each of timerfd, signalfd, inotify and netlink before their tables matched by generation.

主要语言
C
星标
271
派生
28
平均合并
2 天 18 小时
30 天内合并 PR
19

环境准备

  • 没有 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 摘要。