MAP_FIXED shared mapping of a read-only fd fails with EACCES
Maintainers usually reply within 2 days
Nobody has claimed this yet.
Assessment
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Newbie friendliness
- 72/100
- Issue type
- Bug
- Clarity
- Clearly specified
- Activity status
- Active
- Tech stack
- c, macos
- Domain
- operating-systems
Research direction
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.
Written by the indexing model from the issue text.
Description
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).
- Dominant language
- C
- Stars
- 287
- Forks
- 33
- Avg merge
- 2d 17h
- Merged PRs (30d)
- 18
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from sysprog21/elfuse
-
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
Maintainers usually reply within 2 days
-
Difficulty 1/5 Under an hour Newbie friendliness 80/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
Maintainers usually reply within 2 days
All issues in sysprog21/elfuse
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
libreswan/libreswan#3185 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
-
category:port-update
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
Maintainers usually reply within 2 days
-
llvm:instcombine
Difficulty 2/5 1-3 hours Newbie friendliness 64/100
llvm/llvm-project#246503 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 85/100
Maintainers usually reply within 1 day