mirror of
https://github.com/freebsd/freebsd-src.git
synced 2024-11-30 08:43:23 +00:00
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:
parent
957dc12dec
commit
6fba331424
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=61540
@ -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;
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
||||
/*
|
||||
|
@ -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;
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user