Subject: Re: powerpc/powerpc/vm_machdep.c:cpu_fork(): tf used uninitialized
To: Tad Hunt <tad@entrisphere.com>
From: Nathan J. Williams <nathanw@MIT.EDU>
List: port-powerpc
Date: 03/31/2001 02:00:47
Tad Hunt <tad@entrisphere.com> writes:

> ``tf'' will be used uninitialized in cpu_fork(), (if ``stack != NULL'').
> 
> I haven't looked at how cpu_fork() is used, so I can't provide a bugfix.
> I currently panic() if stack != NULL until I figure out what is supposed
> to happen.

The only place where fork1(), and hence cpu_fork(), is passed a
non-NULL stack is in the emulation of the Linux clone() system call. 

It looks like a reasonable (though untested) fix to vm_machdep.c would be:

*** vm_machdep.c	2001/03/22 04:11:46	1.24
--- vm_machdep.c	2001/03/31 06:56:15
***************
*** 112,118 ****
  	 * Setup the trap frame for the new process
  	 */
  	stktop1 = (caddr_t)trapframe(p1);
! 	stktop2 = (caddr_t)trapframe(p2);
  	bcopy(stktop1, stktop2, sizeof(struct trapframe));
  
  	/*
--- 112,119 ----
  	 * Setup the trap frame for the new process
  	 */
  	stktop1 = (caddr_t)trapframe(p1);
! 	tf = trapframe(p2);
! 	stktop2 = (caddr_t)tf;
  	bcopy(stktop1, stktop2, sizeof(struct trapframe));
  
  	/*

        - Nathan