Re: [PATCH] include all vmas with unbacked pages in ELF core dumps

From: Hugh Dickins
Date: Thu Oct 21 2004 - 14:36:37 EST


On Wed, 20 Oct 2004, Linus Torvalds wrote:
>
> In general, I'd much prefer just adding a VM_DIRTY flag, and making the
> COW logic set it. That should guarantee that we write out the minimal
> required sections.

VM_DIRTY flag would be problematic, since you need mmap_sem exclusively
to modify vm_flags, whereas faulting holds mmap_sem non-exclusively.

But if I understand you aright, testing vma->anon_vma should do it.

> So "maydump()" might sanely look something like
>
> /* Shared or IO mappings are never written out */
> if (vma->vm_flags & (VM_IO | VM_SHARED | VM_SHM))
> return 0;

VM_SHM is a relic, there might be a driver or two still setting it,
but we should have deleted it long ago: you mean VM_RESERVED, I think.

> /*
> * Was the mapped backing store opened for writing?
> * This really only happens for VM_SHARED (which we
> * don't write out anyway), but it's conceptually
> * the right thing to do. Some future internal use
> * might end up doing this.
> */
> if (!(vma->vm_flags & VM_MAYWRITE))
> return 0;

Conceptually the right thing to do? I think it's best left out until
that future internal use makes sense of it. As it stands, I can't work
out what it's up to; and VM_MAYWRITE doesn't say if the backing store
was opened for writing, but whether the memory may be mprotected writable.

> /* We really should add this flag */
> if (!(vma->vm_flags & VM_DIRTY))
> return 0;

if (!vma->anon_vma)
return 0;

> /* otherwise, write it out */
> return 1;

Hugh

-
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/