mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Morton <akpm@osdl.org>
To: James Courtier-Dutton <James@superbug.demon.co.uk>
Cc: linux-kernel@vger.kernel.org,
	Guillaume Thouvenin <guillaume.thouvenin@bull.net>
Subject: Re: 2.6.12-rc6-mm1 oops on startup.
Date: Tue, 21 Jun 2005 23:51:44 -0700	[thread overview]
Message-ID: <20050621235144.15fc55c6.akpm@osdl.org> (raw)
In-Reply-To: <42B46C18.2030101@superbug.demon.co.uk>

James Courtier-Dutton <James@superbug.demon.co.uk> wrote:
>
> I have used the kernel.org normal kernel, and it compiles and boots fine.
>  I then use exactly the same .config file for the 2.6.12-rc6-mm1 and it
>  fails to boot.

It's due to the fork notifier code.  Set CONFIG_FORK_CONNECTOR=n and you
should be OK.

The oops is detected by CONFIG_DEBUG_PAGEALLOC.  It's good that you're
running with CONFIG_DEBUG_PAGEALLOC, but be aware that it uses tons of
memory and will slow down smaller machines quite a lot.


Here:

	if (clone_flags & CLONE_VFORK) {
		wait_for_completion(&vfork);
		if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE))
			ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
	}

	fork_connector(current->tgid, current->pid,
	               p->tgid, p->pid);

Someone does a call_usermodehelper() which uses CLONE_VFORK.  The new
process at `p' exits quickly so when the parent returns from
wait_for_completion() it is left with freed memory at *p.  When the parent
tries to reference p->pid we oops due to the use-after-free bug.

Guillaume, I'll do this for now:

--- 25/kernel/fork.c~connector-add-a-fork-connector-use-after-free-fix	2005-06-21 23:46:35.000000000 -0700
+++ 25-akpm/kernel/fork.c	2005-06-21 23:46:58.000000000 -0700
@@ -1248,14 +1248,15 @@ long do_fork(unsigned long clone_flags,
 			ptrace_notify ((trace << 8) | SIGTRAP);
 		}
 
+		fork_connector(current->tgid, current->pid, p->tgid, p->pid);
+
 		if (clone_flags & CLONE_VFORK) {
+
 			wait_for_completion(&vfork);
 			if (unlikely (current->ptrace & PT_TRACE_VFORK_DONE))
-				ptrace_notify ((PTRACE_EVENT_VFORK_DONE << 8) | SIGTRAP);
+				ptrace_notify((PTRACE_EVENT_VFORK_DONE << 8) |
+						SIGTRAP);
 		}
-
-		fork_connector(current->tgid, current->pid,
-		               p->tgid, p->pid);
 	} else {
 		free_pidmap(pid);
 		pid = PTR_ERR(p);
_


But you need to work out what semantics you want for vfork()?

  parent reply	other threads:[~2005-06-22  7:52 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-18 18:46 James Courtier-Dutton
2005-06-21 20:44 ` Alexey Dobriyan
2005-06-22  5:19 ` randy_dunlap
2005-06-22  6:51 ` Andrew Morton [this message]
2005-06-23  8:17   ` Guillaume Thouvenin
2005-06-23 19:30   ` James Courtier-Dutton
2005-06-23 21:38     ` James Courtier-Dutton
2005-06-23 23:52       ` Andrew Morton

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=20050621235144.15fc55c6.akpm@osdl.org \
    --to=akpm@osdl.org \
    --cc=James@superbug.demon.co.uk \
    --cc=guillaume.thouvenin@bull.net \
    --cc=linux-kernel@vger.kernel.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 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®