truncate on /dev/shm drops the guest's record locks

オープン
#469 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

メンテナーはふだん 2 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
48/100
issue の種類
バグ
明瞭さ
おおむね明確
活発さ
活発
技術スタック
c, linux, macos

調査の方向性

Read sys_truncate and shm_open_leaf in src/syscall/fs.c, then compare the /dev/shm branch with the regular-file change in #463. Reproduce the issue with the described aarch64 probe: lock the file, truncate it, and have a child check the lock. Done means /dev/shm truncation preserves the guest's record lock while retaining the branch's protection against following symlinks.

索引モデルが issue の本文から書いたものです。

説明

bug

truncate() on a /dev/shm path drops every POSIX record lock the guest holds on that file. sys_truncate in src/syscall/fs.c reaches a /dev/shm leaf through shm_open_leaf, truncates through that descriptor and closes it. On macOS, closing any descriptor for a file releases all of the process's fcntl record locks on it, and guest F_SETLK locks are host record locks.

Measured with a static aarch64 probe: open /dev/shm/elfuse-lock-probe, take an F_SETLK write lock, call truncate(path, 100), then have a forked child check the lock with F_GETLK.

Linux (qemu) elfuse main (e9fdbbb)
truncate 0 0
lock seen by the child held gone

Linux's vfs_truncate opens nothing, so the lock survives. #463 removed the same open-and-close from the regular-file path of truncate after review; the /dev/shm branch was left as it was.

Goal: truncate on a /dev/shm path leaves the guest's record locks in place. The branch opens the leaf because truncate(2) has no nofollow form, so a fix would have to keep that protection without closing a descriptor on the file.

主要言語
C
スター
287
フォーク
33
平均マージ
2日 17時間
マージ済み PR(30日)
18

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

sysprog21/elfuse のほかの issue

sysprog21/elfuse の issue をすべて見る

似ている issue

C の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。