MAP_FIXED shared mapping of a read-only fd fails with EACCES

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

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

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

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
72/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
技術スタック
c, macos

調査の方向性

Start by reading sys_mmap, mmap_fixed_commit, and hvf_apply_file_overlay to follow how read-only file descriptors are handled in fixed and non-fixed mappings. Reproduce the issue with the supplied mmap sequence and compare it with Linux 6.12. Done when the fixed shared read-only mapping succeeds, including MAP_FIXED_NOREPLACE into a free hole, while existing behavior remains covered.

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

説明

bug

On 170b5df, mmap(addr, len, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0) with fd opened O_RDONLY fails with EACCES; MAP_FIXED_NOREPLACE into a free hole fails the same way. Linux 6.12 maps both. Without MAP_FIXED, the same call succeeds under elfuse.

The non-fixed path in sys_mmap checks overlay_fd_writable and falls back to the pread snapshot for a read-only fd. mmap_fixed_commit calls hvf_apply_file_overlay without that check, and hvf_apply_file_overlay returns EACCES for a read-only fd.

Repro: create a 4 MiB file, open it O_RDONLY, reserve 36 MiB with an anonymous PROT_NONE mapping, then mmap(reserve, 4 MiB, PROT_READ, MAP_SHARED | MAP_FIXED, fd, 0).

主要言語
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 を短くまとめたダイジェスト。