v2 2026-09-09

mm: make MAP_PRIVATE-/dev/zero mappings truly anonymous · v2

让 MAP_PRIVATE /dev/zero 映射真正匿名:识别 /dev/zero、限制 VMA 类型并删除匿名特例。

原始补丁链接

子 Patch(6)

1/6
mm: move drivers/char/mem.c to mm/char-mem.c
[mm: move drivers/char/mem.c to mm/char-mem.c] The memory character driver implements several mm-specific features and is always compiled into the kernel, so move it to mm/ where it belongs. Among ot
2/6
mm: implement file_is_dev_zero() to uniquely identify /dev/zero
[mm: implement file_is_dev_zero() to uniquely identify /dev/zero] To lay the foundation for a future change that converts MAP_PRIVATE-/dev/zero mappings to be truly anonymous, add the ability to uniqu
3/6
mm/vma: only permit MAP_PRIVATE /dev/zero to be mapped anonymous
[mm/vma: only permit MAP_PRIVATE /dev/zero to be mapped anonymous] In order to use mmap_prepare() with MAP_PRIVATE mappings of /dev/zero without the success_hook hack we explicitly permitted mmap_prep
4/6
mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous
[mm/vma: make MAP_PRIVATE-mapped /dev/zero mappings truly anonymous] When mapping /dev/zero with MAP_PRIVATE, one ends up with strange VMAs originating from Linux’s distant past. These have vma->vm_f
5/6
tools/testing/vma: add test to assert MAP_PRIVATE-/dev/zero is anon
[tools/testing/vma: add test to assert MAP_PRIVATE-/dev/zero is anon] Now we’ve made MAP_PRIVATE-mapped /dev/zero mappings truly anonymous, add a VMA userland test to assert that this is the case and
6/6
tools/testing/selftests/mm: add MAP_PRIVATE-/dev/zero merge tests
[tools/testing/selftests/mm: add MAP_PRIVATE-/dev/zero merge tests] Assert that MAP_PRIVATE-mapped /dev/zero mappings behave like they are anonymous. Test both unfaulted and faulted/unfaulted merges