mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Linus Torvalds <torvalds@osdl.org>
To: Roland McGrath <roland@redhat.com>
Cc: Andrew Morton <akpm@osdl.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] include all vmas with unbacked pages in ELF core dumps
Date: Wed, 20 Oct 2004 10:19:41 -0700 (PDT)	[thread overview]
Message-ID: <Pine.LNX.4.58.0410201003192.2317@ppc970.osdl.org> (raw)
In-Reply-To: <200410200822.i9K8MHtp024040@magilla.sf.frob.com>



On Wed, 20 Oct 2004, Roland McGrath wrote:
>
> This patch changes the criteria for including vm regions in a core dump.
> In recent glibc, the dynamic linker uses mprotect on part of a data segment
> to write-protect pages that should never be touched after startup time
> (this makes it harder for exploits to clobber indirection tables and the like).
> Currently, this part of the segment is omitted from core dumps, losing
> information about what the program did before it died.

Augh. Not all filesystems support holes, and I think VM_SHARED should 
trump VM_WRITE.

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.

> Including unreadable regions gives you things like guard pages, showing
> an accurate representation of of those in the core dump image. Since we
> now have the ZERO_PAGE check, this won't actually write any more pages
> to disk for those cases.

But any non-dumped section _will_ show up in the ELF headers, so things
like guard pages have nothing to do with "maydump()", imho. And as 
mentioned, some filesystems _will_ write many more pages.

So if gdb has trouble with guard pages, pls get somebody to fix gdb 
instead, and tell them what the difference between p_filesz and p_memsz 
is. Putting them into the dump is just stupid.

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;

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

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

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

and that should make people happy. No?

		Linus

  reply	other threads:[~2004-10-21 12:03 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-10-20  8:22 Roland McGrath
2004-10-20 17:19 ` Linus Torvalds [this message]
2004-10-20 18:07   ` Roland McGrath
2004-10-21 19:05   ` Hugh Dickins
2004-10-21 20:01     ` Linus Torvalds
2004-10-21 22:00       ` Roland McGrath

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Pine.LNX.4.58.0410201003192.2317@ppc970.osdl.org \
    --to=torvalds@osdl.org \
    --cc=akpm@osdl.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®