A dup of a timerfd, signalfd, inotify or netlink fd has no state behind it
メンテナーはふだん 2 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 52/100
- issue の種類
- バグ
- 明瞭さ
- おおむね明確
- 活発さ
- 活発
- 技術スタック
- c, linux
調査の方向性
Start with duplicate_guest_fd in src/syscall/fs.c, then read the side-table lookup and cleanup paths for timerfd, signalfd, inotify, and netlink. Compare the alias mapping and reference-counting approach in eventfd_dup_fd and pidfd_dup_ref/pidfd_map. Done means aliases share the original state until the last descriptor closes, and the listed operations work through either fd.
索引モデルが issue の本文から書いたものです。
説明
dup(2) returns a second fd for the same open file description, so on Linux every operation works through either fd and the object lives until the last one is closed. Under elfuse a dup of a timerfd, signalfd, inotify or netlink fd is an fd of the right type with no state behind it.
duplicate_guest_fd (src/syscall/fs.c) copies these four types through the generic path: a new slot of the same type on a dup of the host fd, with the type's cleanup callback. Each type keeps its state in a side table whose entries record one guest fd number, the one the create call returned, and timerfd_find, signalfd_find, inotify_find and nl_find match on that number. A lookup by the alias's number finds no entry.
Single-threaded, on 9f12c41 and on Linux 6.12 (the qemu reference VM):
int fd = timerfd_create(CLOCK_MONOTONIC, TFD_NONBLOCK);
int alias = dup(fd);
struct itimerspec its = {.it_value = {.tv_nsec = 50 * 1000 * 1000}};
/* Linux elfuse */
timerfd_settime(alias, 0, &its, NULL); /* 0 EBADF */
timerfd_settime(fd, 0, &its, NULL); /* 0 0 */
timerfd_gettime(alias, &cur); /* 0 EBADF */
poll(&(struct pollfd){alias, POLLIN}, 1, 500);
/* 1, POLLIN 1, POLLIN */
read(alias, &n, 8); /* 8 EBADF */
read(fd, &n, 8); /* EAGAIN 8 */
close(fd);
timerfd_settime(alias, 0, &its, NULL); /* 0 EBADF */
The alias shares the host kqueue, so poll reports it readable, and the read that follows fails. A loop that polls the alias and reads on POLLIN does not block again.
The other three fail the same way through the alias, with the original open or closed, where Linux 6.12 succeeds in both:
- signalfd:
signalfd(alias, &mask, 0)returnsEINVAL. - inotify:
inotify_add_watch(alias, ...)returnsEBADF. - netlink:
getsockname(alias, ...)returnsEBADF.
Closing the original frees the entry, and the alias stays as it was. Closing the alias leaves the original working: the cleanup callback matches the entry by fd generation and the alias has none.
eventfd and pidfd are the shape a fix takes. eventfd_dup_fd and pidfd_dup_ref with pidfd_map (#408) map each alias to the source's entry and count the references, and the entry is released with the last one. usbdev is separate: duplicate_guest_fd refuses the dup with EBADF, under a TODO(stage 3) in the same function.
- 主要言語
- C
- スター
- 271
- フォーク
- 28
- 平均マージ
- 2日 18時間
- マージ済み PR(30日)
- 19
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
sysprog21/elfuse のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
-
bug
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
メンテナーはふだん 2 日以内に返信
-
難易度 3/5 1〜2日 初心者へのやさしさ 78/100
メンテナーはふだん 2 日以内に返信
-
難易度 5/5 1週間以上 初心者へのやさしさ 48/100
メンテナーはふだん 2 日以内に返信
sysprog21/elfuse の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kovidgoyal/kitty#10625 ·
メンテナーはふだん 1 日以内に返信
-
Feature Status: Needs Triage
難易度 2/5 1〜3時間 初心者へのやさしさ 73/100
メンテナーはふだん 1 日以内に返信
-
docs
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
RubyMetric/chsrc#396 ·