openvmm: virtiofs: non-exclusive FUSE_CREATE on an existing file bypasses read-only alias checks and truncates protected hard links
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 35/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 技術スタック
- rust
調査の方向性
Start in vm/devices/virtio/virtiofs/src/lib.rs: compare VirtioFs::create (~lines 290-315) with VirtioFs::open (276-287) and check_open_readonly (670-700), then read VirtioFsInode::create in src/inode.rs (327-345) and policy_permits_writes in src/microvm/inode.rs (169-179). The gap is that create checks only the parent and target path, while dedup onto an existing inode happens after the host open syscall. Done means a non-exclusive FUSE_CREATE on an existing hard-linked inode with a read-only alias fails with EROFS before the host open, with a test mirroring the five reproduction steps.
索引モデルが issue の本文から書いたものです。
説明
Summary
VirtioFs::create checks writability only on the parent directory and the single child path (check_writable and check_writable_entry) before calling self.volume.open(&path, open_options | lx::O_CREAT, ...), without checking whether path already resolves to a held VirtioFsInode that is read-only through another hard-link alias. As a result, while FUSE_OPEN with O_WRONLY | O_TRUNC on a file hard-linked between a read-only path and a writable path is rejected with EROFS, a non-exclusive FUSE_CREATE (O_WRONLY | O_TRUNC without O_EXCL) at the writable hard-link path bypasses multi-alias write protection and truncates the protected host file immediately during the open syscall. Found during formal specification (blocks formal verification).
Root Cause
For FUSE_OPEN, VirtioFs::open calls VirtioFs::check_open_readonly, which inspects inode.readonly()—backed on microVM shares by VirtioFsInode::policy_permits_writes, requiring every tracked alias of the inode to lie under writable_paths.
In VirtioFs::create, however, only the parent inode and the single target path are checked before invoking VirtioFsInode::create:
let inode = self.get_inode(request.node_id())?;
self.check_writable(&inode)?;
let path = inode.child_path(name)?;
self.check_writable_entry(&inode, &path)?;
self.preflight_create_inode(&inode, name, &path)?;
self.preflight_file_insert()?;
let inode_reservation = self.reserve_inode()?;
let file_reservation = self.reserve_file()?;
let (new_inode, attr, file) =
inode.create(name, options, arg.mode, request.uid(), request.gid())?;
VirtioFsInode::create immediately executes self.volume.open(&path, open_options | lx::O_CREAT, Some(options))? on the host. When O_EXCL is not set and path already exists on disk, O_CREAT opens the existing file—truncating it on the host if O_TRUNC is set—before inode_reservation.insert(new_inode) ever deduplicates new_inode onto the existing VirtioFsInode in self.inner.inodes.
Consequence
- MicroVM write-policy bypass (
O_TRUNCdata destruction): If a host file has both a read-only path (for examplemarkeroutsidewritable_paths) and a hard link insidewritable_paths(for exampleout/twin), and the guest holds the node with both aliases tracked,FUSE_OPEN(twin, O_WRONLY | O_TRUNC)fails withEROFS, yetFUSE_CREATE(out, "twin", O_WRONLY | O_TRUNC)succeeds and truncatesmarkerto zero bytes on the host. - Inconsistent write-open admission: Even without
O_TRUNC, a non-exclusiveFUSE_CREATEwithO_WRONLYorO_RDWRon that existing hard link succeeds and allocates a writable host file handle for an inode whosereadonly()predicate istrue, violating the rule that a read-only node cannot be opened for writing.
Reproduction
- On the host share root, create a protected file
markercontaining"host"and a hard linkout/twinpointing tomarker. - Configure a microVM virtio-fs share with
writable_paths = ["out"]. - Issue
FUSE_LOOKUPon"out"(out_node),"out/twin"(twin_node), and"marker"(which deduplicates ontotwin_nodeand records"marker"in itsaliases). - Confirm
FUSE_OPEN(twin_node, O_WRONLY | O_TRUNC)fails withEROFS. - Issue
FUSE_CREATEon(out_node, "twin")withflags = O_WRONLY | O_TRUNCandmode = S_IFREG | 0o644: the call unexpectedly succeeds and truncatesmarkeron the host to"".
Related: #1610, #1604, #1620.
- 主要言語
- 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 ·