All of lore.kernel.org
 help / color / mirror / Atom feed
From: Oleg Nesterov <oleg@tv-sign.ru>
To: Roland McGrath <roland@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] core dump: remain dumpable
Date: Thu, 11 Oct 2007 14:25:07 +0400	[thread overview]
Message-ID: <20071011102507.GA101@tv-sign.ru> (raw)
In-Reply-To: <20071011062730.19F774D026B@magilla.localdomain>

On 10/10, Roland McGrath wrote:
> 
> As far as I know, set_dumpable was only used in do_coredump for
> synchronization and not intended for any security purpose.

I don't understand why do_coredump() clears DUMPABLE too.

> This changes do_coredump to use a separate bit for its
> synchronization, so the "dumpable" bits remain the same.
> ...
>
> @@ -1727,7 +1727,8 @@ int do_coredump(long signr, int exit_code, struct pt_regs * regs)
>  	if (!binfmt || !binfmt->core_dump)
>  		goto fail;
>  	down_write(&mm->mmap_sem);
> -	if (!get_dumpable(mm)) {
> +	if (!get_dumpable(mm) ||
> +	    test_and_set_bit(MMF_DUMP_STARTED, &mm->flags)) {
>  		up_write(&mm->mmap_sem);
>  		goto fail;

Do we really need the new MMF_DUMP_STARTED flag? We are holding ->mmap_sem,
can't we check "mm->core_waiters != 0" instead?

Hmm. Actually, do we need any check? If another thread (or CLONE_VM task)
already started do_coredump(), we must see SIGNAL_GROUP_EXIT when we take
->mmap_sem. In that case coredump_wait() does nothing but returns -EAGAIN.

> -	set_dumpable(mm, 0);

Looks like this change is all we need, no? The only problem is that we
return -EAGAIN if we race with another thread (the current code returns 0),
but nobody checks the returned value.

What do you think?

Oleg.


  reply	other threads:[~2007-10-11 10:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-10-11  6:27 [PATCH] core dump: remain dumpable Roland McGrath
2007-10-11 10:25 ` Oleg Nesterov [this message]
2007-10-11 10:34   ` Roland McGrath
2007-10-11 10:49     ` Oleg Nesterov
2007-10-11 10:51       ` Roland McGrath
2007-11-12  3:13 ` 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=20071011102507.GA101@tv-sign.ru \
    --to=oleg@tv-sign.ru \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=roland@redhat.com \
    --cc=torvalds@linux-foundation.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.