cpu_fork(): Check "flags" before dereferencing "p2". Otherwise,

the call "vm_fork(p1, 0, flags);" early in fork1 can cause a kernel
panic.
This commit is contained in:
Alan Cox 2000-06-11 06:22:01 +00:00
parent 957dc12dec
commit 6fba331424
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61540
3 changed files with 6 additions and 9 deletions

View File

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

View File

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

View File

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