summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralc <alc@FreeBSD.org>2000-06-11 06:22:01 +0000
committeralc <alc@FreeBSD.org>2000-06-11 06:22:01 +0000
commit4fc801a85706650d7922df5965352e4517d542fd (patch)
treea018f2fba749c71cbdf30b8ea4c195a4201a6d30
parent4b9e219ff866aa7302f05fe87ce0d68d935cb86b (diff)
downloadFreeBSD-src-4fc801a85706650d7922df5965352e4517d542fd.zip
FreeBSD-src-4fc801a85706650d7922df5965352e4517d542fd.tar.gz
cpu_fork(): Check "flags" before dereferencing "p2". Otherwise,
the call "vm_fork(p1, 0, flags);" early in fork1 can cause a kernel panic.
-rw-r--r--sys/alpha/alpha/vm_machdep.c5
-rw-r--r--sys/powerpc/aim/vm_machdep.c5
-rw-r--r--sys/powerpc/powerpc/vm_machdep.c5
3 files changed, 6 insertions, 9 deletions
diff --git a/sys/alpha/alpha/vm_machdep.c b/sys/alpha/alpha/vm_machdep.c
index 17fe494..68bbf29 100644
--- a/sys/alpha/alpha/vm_machdep.c
+++ b/sys/alpha/alpha/vm_machdep.c
@@ -121,8 +121,6 @@ cpu_fork(p1, p2, flags)
register struct proc *p1, *p2;
int flags;
{
- struct user *up = p2->p_addr;
-
if ((flags & RFPROC) == 0)
return;
@@ -133,7 +131,7 @@ cpu_fork(p1, p2, flags)
* Cache the physical address of the pcb, so we can
* swap to it easily.
*/
- p2->p_md.md_pcbpaddr = (void*) vtophys((vm_offset_t) &up->u_pcb);
+ p2->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p2->p_addr->u_pcb);
/*
* Copy floating point state from the FP chip to the PCB
@@ -176,6 +174,7 @@ cpu_fork(p1, p2, flags)
* create the child's kernel stack, from scratch.
*/
{
+ struct user *up = p2->p_addr;
struct trapframe *p2tf;
/*
diff --git a/sys/powerpc/aim/vm_machdep.c b/sys/powerpc/aim/vm_machdep.c
index 17fe494..68bbf29 100644
--- a/sys/powerpc/aim/vm_machdep.c
+++ b/sys/powerpc/aim/vm_machdep.c
@@ -121,8 +121,6 @@ cpu_fork(p1, p2, flags)
register struct proc *p1, *p2;
int flags;
{
- struct user *up = p2->p_addr;
-
if ((flags & RFPROC) == 0)
return;
@@ -133,7 +131,7 @@ cpu_fork(p1, p2, flags)
* Cache the physical address of the pcb, so we can
* swap to it easily.
*/
- p2->p_md.md_pcbpaddr = (void*) vtophys((vm_offset_t) &up->u_pcb);
+ p2->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p2->p_addr->u_pcb);
/*
* Copy floating point state from the FP chip to the PCB
@@ -176,6 +174,7 @@ cpu_fork(p1, p2, flags)
* create the child's kernel stack, from scratch.
*/
{
+ struct user *up = p2->p_addr;
struct trapframe *p2tf;
/*
diff --git a/sys/powerpc/powerpc/vm_machdep.c b/sys/powerpc/powerpc/vm_machdep.c
index 17fe494..68bbf29 100644
--- a/sys/powerpc/powerpc/vm_machdep.c
+++ b/sys/powerpc/powerpc/vm_machdep.c
@@ -121,8 +121,6 @@ cpu_fork(p1, p2, flags)
register struct proc *p1, *p2;
int flags;
{
- struct user *up = p2->p_addr;
-
if ((flags & RFPROC) == 0)
return;
@@ -133,7 +131,7 @@ cpu_fork(p1, p2, flags)
* Cache the physical address of the pcb, so we can
* swap to it easily.
*/
- p2->p_md.md_pcbpaddr = (void*) vtophys((vm_offset_t) &up->u_pcb);
+ p2->p_md.md_pcbpaddr = (void*)vtophys((vm_offset_t)&p2->p_addr->u_pcb);
/*
* Copy floating point state from the FP chip to the PCB
@@ -176,6 +174,7 @@ cpu_fork(p1, p2, flags)
* create the child's kernel stack, from scratch.
*/
{
+ struct user *up = p2->p_addr;
struct trapframe *p2tf;
/*
OpenPOWER on IntegriCloud