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

Aberta
#486 0 comentários 0 reações 0 responsáveis Ver no GitHub

Mantenedores costumam responder em até 2 dias

Ninguém assumiu esta issue ainda.

Avaliação

Dificuldade
3/5
Tempo estimado
1-2 dias
Facilidade para iniciantes
72/100
Tipo de issue
Bug
Clareza
Claramente especificada
Status de atividade
Ativa
Stack de tecnologia
c, macos

Direção de pesquisa

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.

Escrita pelo modelo de indexação a partir do texto da issue.

Descrição

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).

Linguagem predominante
C
Estrelas
287
Forks
33
Merge médio
2d 17h
PRs com merge (30d)
18

Preparar o ambiente

Primeiros passos

  1. Leia a issue inteira e depois o guia de contribuição do projeto.
  2. Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
  3. Faça um fork do repositório e trabalhe em uma branch.
  4. Abra um pull request que referencie o número da issue.

Mais de sysprog21/elfuse

Todas as issues de sysprog21/elfuse

Issues semelhantes

Mais issues de C

Receba novas issues na sua caixa de entrada

Um resumo curto de issues do GitHub para quem está começando.