Bug 14144

Summary: bad conversions in kern_fork()
Product: Base System Reporter: Valentin Nechayev <netch>
Component: kernAssignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 3.3-STABLE   
Hardware: Any   
OS: Any   

Description Valentin Nechayev 1999-10-05 17:10:01 UTC
kern_fork.c, since line 357:
=== cut here ===
                MALLOC (p2->p_procsig, struct procsig *, sizeof(struct procsig),
                        M_SUBPROC, M_WAITOK);
                bcopy(&p1->p_procsig->ps_begincopy, &p2->p_procsig->ps_begincopy,
                        (unsigned)&p1->p_procsig->ps_endcopy -
                        (unsigned)&p1->p_procsig->ps_begincopy);
                p2->p_procsig->ps_refcnt = 1;
=== end cut ===
 
This piece of code converts two pointers to integer values and then calculates
difference of the values to calculate difference between pointers.
It is ugly hack but it works on i386; but on alpha sizeof(int)==4,
size of pointer is 8, and conversion loses bits. I cannot understand is this
losing significant but in case of really huge memory it shall be.

Fix: 

Change it to calculate difference of two pointers converted to caddr_t.
Comment 1 Valentin Nechayev 1999-10-05 17:14:45 UTC
Oops! Please change category to "kern"
Comment 2 Dmitrij Tejblum 1999-10-05 17:27:08 UTC
>                 bcopy(&p1->p_procsig->ps_begincopy, &p2->p_procsig->ps_begincopy,
>                         (unsigned)&p1->p_procsig->ps_endcopy -
>                         (unsigned)&p1->p_procsig->ps_begincopy);

It is fixed in -current. I would not bother to fix it (and some similar 
things) in -stable.

Dima
Comment 3 Kris Kennaway freebsd_committer freebsd_triage 2001-05-24 20:06:39 UTC
State Changed
From-To: open->closed

Fixed on 1999/04/24: 

---------------------------- 
revision 1.59 
date: 1999/04/24 11:25:01;  author: dt;  state: Exp;  lines: +3 -3 
Use pointer arithmetic to do pointer arithmetic. 
----------------------------