openvmm: virtiofs: inode lookup count wraps to zero at u64::MAX
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 半日
- 初心者へのやさしさ
- 68/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start in vm/devices/virtio/virtiofs/src/inode.rs around lines 236-262: compare lookup/inc_lookup (which use fetch_add) with the neighbouring forget, which already uses AtomicU64::update with saturating_sub. Decide whether the restore path in vm/devices/virtio/virtiofs/src/microvm/state.rs (validate_microvm_state) should also reject an implausible lookup_count, then add a unit test that replays the reproduction steps and asserts the inode survives fs.forget(node_id, 1) followed by get_attr. Done means a lookup at u64::MAX keeps the count saturated and the node stays in InodeMap; run the virtiofs crate tests with cargo test -p virtiofs.
索引モデルが issue の本文から書いたものです。
説明
Summary
VirtioFsInode::lookup and VirtioFsInode::inc_lookup increment lookup_count with AtomicU64::fetch_add(1, Ordering::AcqRel), which uses wrapping arithmetic at u64::MAX. When an inode's lookup_count is u64::MAX — reachable directly via microVM saved-state restore without 2^64 live requests — one additional FUSE_LOOKUP, FUSE_READDIRPLUS, or FUSE_LINK wraps lookup_count to 0, allowing the next FUSE_FORGET to evict the still-referenced inode from InodeMap. Found by formal verification.
Root Cause
In vm/devices/virtio/virtiofs/src/inode.rs, both VirtioFsInode::lookup and VirtioFsInode::inc_lookup use fetch_add(1, Ordering::AcqRel) rather than saturating addition, even though VirtioFsInode::forget immediately below already uses AtomicU64::update with saturating_sub:
/// Increments the lookup count.
pub fn lookup(&self, new_path: PathBuf) {
self.lookup_count.fetch_add(1, Ordering::AcqRel);
self.aliases.write().insert(new_path.clone());
let mut path = self.path.write();
*path = new_path;
}
/// Increments the lookup count without updating the path.
///
/// This is used when returning an existing inode in a FUSE reply (e.g., for hard links)
/// where the kernel will track the reference and later send a forget.
pub fn inc_lookup(&self) {
self.lookup_count.fetch_add(1, Ordering::AcqRel);
}
In microVM mode, validate_microvm_state accepts any SavedInode with inode.lookup_count != 0, including u64::MAX, and restores it verbatim into VirtioFsInode::lookup_count.
Consequence
Once lookup_count wraps from u64::MAX to 0, the inode remains in InodeMap with a zero reference count until any FUSE_FORGET(node_id, n) arrives. At that point, Fuse::forget computes 0u64.saturating_sub(n) == 0 and removes the node from InodeMap while the guest still holds active FUSE references to node_id. Subsequent guest operations on node_id fail with EINVAL (request for unknown inode), and in microVM mode save_microvm_state also fails if an open handle still points to the evicted inode (open handle refers to an untracked inode).
Reproduction
- Create a temporary directory containing a file
"f", instantiateVirtioFs::new(dir.path(), None), and look up"f"once to obtainnode_id. - Set that inode's
lookup_counttou64::MAX(simulating a restoredSavedInodewithlookup_count: u64::MAXor cumulative lookups). - Look up
"f"a second time (or callinode.inc_lookup()).lookup_countwraps fromu64::MAXto0. - Call
fs.forget(node_id, 1)and thenfs.get_attronnode_id.forgetevictsnode_idfromInodeMap, andget_attrfails withlx::Error::EINVAL.
Related: #1627.
- 主要言語
- Rust
- スター
- 848
- フォーク
- 63
- 平均マージ
- 13時間 37分
- マージ済み PR(30日)
- 571
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドなし
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
microsoft/nvx のほかの issue
-
area: ci
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
area: ci
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
メンテナーはふだん 1 日以内に返信
-
openvmm: virtiofs: aggregate synthetic root st_nlink counts single-file shares as subdirectoriesオープンarea: openvmm
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
microsoft/nvx#1632 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: openvmm
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
microsoft/nvx#1628 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
area: openvmm
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
microsoft/nvx#1629 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
obi1kenobi/cargo-semver-checks#1814 ·
メンテナーはふだん 1 日以内に返信
-
community differential help wanted
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
hffgzktbcc-blip/ounce-core#489 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
pbakaus/impeccable#1560 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 68/100
pact-foundation/pact-plugins#125 ·