Partial teardown of a MAP_SHARED overlay detaches the surviving pages from the file
Mantenedores costumam responder em até 2 dias
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 5/5
- Tempo estimado
- Mais de uma semana
- Facilidade para iniciantes
- 25/100
- Tipo de issue
- Bug
- Clareza
- Claramente especificada
- Status de atividade
- Ativa
- Stack de tecnologia
- c, macos
- Domínio
- backend, operating-systems
Direção de pesquisa
Start with the failing cases in tests/test-msync.c and trace how partial munmap, MAP_FIXED hole reuse, and mremap update backing IPAs and HVF segments. The report says the fix also affects fork and guest address mapping. Done means the surviving shared pages retain file contents and two way coherence while a replacement anonymous page stays private; all four listed cases should pass.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
Problem
On Apple Silicon the host page is 16 KiB and the guest page is 4 KiB, so one host file overlay covers four guest pages. Removing only part of that host page (munmap of one guest page, mremap shrink, or moving part of a source range) tears down the whole overlay and restores slab backing under it. The guest pages that are still mapped keep valid PTEs but now read slab memory: they lose the file contents, a host pwrite is no longer visible through them, and their stores no longer reach the file.
Reproduction
char name[] = "/dev/shm/partial-XXXXXX";
int fd = mkstemp(name);
unlink(name);
ftruncate(fd, 16384);
for (int i = 0; i < 4; i++) {
unsigned char c = 0x31 + i;
pwrite(fd, &c, 1, i * 4096);
}
unsigned char *p = mmap(NULL, 16384, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0);
munmap(p, 4096);
/* Linux: p[4096], p[8192], p[12288] read 0x32 0x33 0x34 */
Expected, as on Linux: the removed page faults, the remaining pages read 0x32, 0x33 and 0x34, a pwrite at offset 8192 is visible at p[8192], and a store to p[12288] lands in the file.
Actual on elfuse: the remaining pages read 0x00, and neither direction of coherence holds. The file itself is not modified. mremap shrinking a shared mapping, or moving only part of one, shows the same result.
MAP_FIXED into the hole
A second case remains even if the removal paths keep the overlay alive. After the munmap above, map a different backing into the hole:
unsigned char *q = mmap(p, 4096, PROT_READ | PROT_WRITE,
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
q[0] = 'A';
The anonymous page must not write into the file, and its three neighbors must stay file-backed. One 16 KiB host range cannot carry both backings at once, so keeping the overlay corrupts the file and dropping it detaches the neighbors. Fixing this needs the surviving guest pages moved onto a separate host-aligned backing, which touches how guest addresses map to backing IPAs, HVF segments, fork and mremap.
Environment
- macOS 27.0.1 (26A434), SDK 27.0, Apple M5
- elfuse main at e9fdbbb
- Partial munmap, hole reuse, partial mremap and mremap shrink cases in tests/test-msync.c: all four fail on main
Follow-up to the discussion in #391.
- Linguagem predominante
- C
- Estrelas
- 287
- Forks
- 33
- Merge médio
- 2d 17h
- PRs com merge (30d)
- 18
Preparar o ambiente
- Sem Dockerfile nem arquivo Docker Compose
- Sem modelo de pull request
- Ler o guia de contribuição
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de sysprog21/elfuse
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
Mantenedores costumam responder em até 2 dias
-
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 80/100
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 86/100
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 2 dias
-
bug
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 75/100
Mantenedores costumam responder em até 2 dias
Todas as issues de sysprog21/elfuse
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
libreswan/libreswan#3185 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
[SDL3pp] update to 0.12.0Abertacategory:port-update
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 72/100
Mantenedores costumam responder em até 2 dias
-
[InstCombine] 23.x folds 0.0 * (0.0 / x) to 0.0 when x may be zero (fixed on main by #202482)Abertallvm:instcombine
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 64/100
llvm/llvm-project#246503 · 1 comentário ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 85/100
Mantenedores costumam responder em até 1 dia