Re: [BUG] hugetlb MAP_PRIVATE mapping vs /dev/zero

From: Andrew Morton
Date: Thu Jul 01 2004 - 16:54:20 EST


Oleg Nesterov <oleg@xxxxxxxxxx> wrote:
>
> Hugetlbfs mmap with MAP_PRIVATE becomes MAP_SHARED
> silently, but vma->vm_flags have no VM_SHARED bit.
> I think it make sense to forbid MAP_PRIVATE in
> hugetlbfs_file_mmap() because it may confuse user
> space applications. But the real bug is that reading
> from /dev/zero into hugetlb will do:
>
> read_zero()
> read_zero_pagealigned()
> if (vma->vm_flags & VM_SHARED)
> break; // OK if MAP_PRIVATE
> zap_page_range();
> zeromap_page_range();
>
> We can fix hugetlbfs_file_mmap() or read_zero_pagealigned()
> or both.

This could break existing applications, yes?

If so, would an appropriate fixup be to coerce private mappings
of hugetlb files into shared ones in-kernel?
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/