kern/87990: [kernel] [patch] SMP Race Condition in kdb_enter/kdb_exit code

Lonnie VanZandt lonniev at predictableresponse.com
Tue Oct 25 21:40:19 PDT 2005


The following reply was made to PR kern/87990; it has been noted by GNATS.

From: "Lonnie VanZandt" <lonniev at predictableresponse.com>
To: <bug-followup at FreeBSD.org>
Cc:  
Subject: Re: kern/87990: [kernel] [patch] SMP Race Condition in kdb_enter/kdb_exit code
Date: Tue, 25 Oct 2005 22:35:48 -0600

 This is a multi-part message in MIME format.
 
 ------=_NextPart_000_0185_01C5D9B4.761893B0
 Content-Type: multipart/alternative;
 	boundary="----=_NextPart_001_0186_01C5D9B4.761893B0"
 
 
 ------=_NextPart_001_0186_01C5D9B4.761893B0
 Content-Type: text/plain;
 	charset="US-ASCII"
 Content-Transfer-Encoding: quoted-printable
 
 The context diff as plaintext and not as an attachment.
 =20
 *** subr_kdb.c.orig Wed Sep 21 15:27:16 2005
 --- /tmp/subr_kdb.c Wed Sep 21 15:23:23 2005
 ***************
 *** 444,455 ****
  =20
    makectx(tf, &kdb_pcb);
  =20
    critical_enter();
  =20
 !  kdb_active++;
 !  kdb_frame =3D tf;
 !  kdb_thr_select(curthread);
 !=20
   #ifdef SMP
    if ((did_stop_cpus =3D kdb_stop_cpus) !=3D 0)
      {
 --- 444,454 ----
  =20
    makectx(tf, &kdb_pcb);
  =20
 +  // disable interrupts to our own CPU
    critical_enter();
  =20
 !  // halt any other CPUs who might trip over our
 !  // traps and try to rush into KDB before us
   #ifdef SMP
    if ((did_stop_cpus =3D kdb_stop_cpus) !=3D 0)
      {
 ***************
 *** 462,479 ****
      }
   #endif
  =20
    /* Let MD code do its thing first... */
    kdb_cpu_trap(type, code);
  =20
    handled =3D kdb_dbbe->dbbe_trap(type, code);
  =20
   #ifdef SMP
    if (did_stop_cpus)
     restart_cpus(stopped_cpus);
   #endif
  =20
 !  kdb_active--;
 !=20
    critical_exit();
  =20
    return (handled);
 --- 461,497 ----
      }
   #endif
  =20
 +  // we can't be interrupted now and we must be
 +  // the only running CPU. So, if kdb_active remains 0
 +  // then we have won the race to enter KDB, otherwise
 +  // some other CPU beat us through the gate...
 +  if ( 0 !=3D kdb_active )
 +  {
 +   return 0;
 +  }
 +=20
 +  // claim the prize
 +  kdb_active++;
 +=20
 +  // set the kdb context
 +  kdb_frame =3D tf;
 +  kdb_thr_select( curthread );
 +=20
    /* Let MD code do its thing first... */
    kdb_cpu_trap(type, code);
  =20
    handled =3D kdb_dbbe->dbbe_trap(type, code);
  =20
 +  // release the prize
 +  kdb_active--;
 +=20
 +  // let other CPUs have a chance to run
   #ifdef SMP
    if (did_stop_cpus)
     restart_cpus(stopped_cpus);
   #endif
  =20
 !  // let our own ISRs to run
    critical_exit();
  =20
    return (handled);
 
 =20
 
 
 
  <http://www.predictableresponse.com/> 	 Engineering Reliable Software
 Solutions...=09
 =09
 
 Lonnie VanZandt
 Consulting Systems Engineer 	Predictable Response Consulting
 637 Witter Gulch Road
 <http://maps.yahoo.com/py/maps.py?Pyt=3DTmap&addr=3D637+Witter+Gulch+Road=
 &csz=3DEv
 ergreen%2C+CO+80439&country=3Dus>=20
 Evergreen, CO 80439 =09
 lonniev at predictableresponse.com
 IM: lonnievanzandt at yahoo.com =09
 tel:=20
 fax:=20
 mobile: 	303 679-6035
 303 679-8119
 720 201-1349 =09
 =09
 
  <https://www.plaxo.com/add_me?u=3D410949&v0=3D816147&k0=3D1128357437> =
 Add me to
 your address book...	  <http://www.plaxo.com/signature> Want a signature
 like this?=09
 =20
 
 ------=_NextPart_001_0186_01C5D9B4.761893B0
 Content-Type: text/html;
 	charset="US-ASCII"
 Content-Transfer-Encoding: quoted-printable
 
 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 <HTML><HEAD>
 <META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
 charset=3Dus-ascii">
 <TITLE>Message</TITLE>
 
 <META content=3D"MSHTML 6.00.2900.2769" name=3DGENERATOR></HEAD>
 <BODY>
 <DIV><FONT face=3DArial size=3D2><SPAN class=3D260253404-26102005>The =
 context diff as=20
 plaintext and not as an attachment.</SPAN></FONT></DIV>
 <DIV><FONT face=3DArial size=3D2><SPAN=20
 class=3D260253404-26102005></SPAN></FONT>&nbsp;</DIV>
 <DIV><FONT face=3DArial size=3D2>*** subr_kdb.c.orig&nbsp;Wed Sep 21 =
 15:27:16=20
 2005<BR>--- /tmp/subr_kdb.c&nbsp;Wed Sep 21 15:23:23=20
 2005<BR>***************<BR>*** 444,455 ****<BR>&nbsp; <BR>&nbsp;=20
 &nbsp;makectx(tf, &amp;kdb_pcb);<BR>&nbsp; <BR>&nbsp;=20
 &nbsp;critical_enter();<BR>&nbsp; <BR>! &nbsp;kdb_active++;<BR>! =
 &nbsp;kdb_frame=20
 =3D tf;<BR>! &nbsp;kdb_thr_select(curthread);<BR>! <BR>&nbsp; #ifdef =
 SMP<BR>&nbsp;=20
 &nbsp;if ((did_stop_cpus =3D kdb_stop_cpus) !=3D 0)<BR>&nbsp; =
 &nbsp;&nbsp; {<BR>---=20
 444,454 ----<BR>&nbsp; <BR>&nbsp; &nbsp;makectx(tf, =
 &amp;kdb_pcb);<BR>&nbsp;=20
 <BR>+ &nbsp;// disable interrupts to our own CPU<BR>&nbsp;=20
 &nbsp;critical_enter();<BR>&nbsp; <BR>! &nbsp;// halt any other CPUs who =
 might=20
 trip over our<BR>! &nbsp;// traps and try to rush into KDB before =
 us<BR>&nbsp;=20
 #ifdef SMP<BR>&nbsp; &nbsp;if ((did_stop_cpus =3D kdb_stop_cpus) !=3D =
 0)<BR>&nbsp;=20
 &nbsp;&nbsp; {<BR>***************<BR>*** 462,479 ****<BR>&nbsp; =
 &nbsp;&nbsp;=20
 }<BR>&nbsp; #endif<BR>&nbsp; <BR>&nbsp; &nbsp;/* Let MD code do its =
 thing=20
 first... */<BR>&nbsp; &nbsp;kdb_cpu_trap(type, code);<BR>&nbsp; =
 <BR>&nbsp;=20
 &nbsp;handled =3D kdb_dbbe-&gt;dbbe_trap(type, code);<BR>&nbsp; =
 <BR>&nbsp; #ifdef=20
 SMP<BR>&nbsp; &nbsp;if (did_stop_cpus)<BR>&nbsp;=20
 &nbsp;&nbsp;restart_cpus(stopped_cpus);<BR>&nbsp; #endif<BR>&nbsp; <BR>! =
 
 &nbsp;kdb_active--;<BR>! <BR>&nbsp; &nbsp;critical_exit();<BR>&nbsp; =
 <BR>&nbsp;=20
 &nbsp;return (handled);<BR>--- 461,497 ----<BR>&nbsp; &nbsp;&nbsp; =
 }<BR>&nbsp;=20
 #endif<BR>&nbsp; <BR>+ &nbsp;// we can't be interrupted now and we must =
 be<BR>+=20
 &nbsp;// the only running CPU. So, if kdb_active remains 0<BR>+ &nbsp;// =
 then we=20
 have won the race to enter KDB, otherwise<BR>+ &nbsp;// some other CPU =
 beat us=20
 through the gate...<BR>+ &nbsp;if ( 0 !=3D kdb_active )<BR>+ =
 &nbsp;{<BR>+=20
 &nbsp;&nbsp;return 0;<BR>+ &nbsp;}<BR>+ <BR>+ &nbsp;// claim the =
 prize<BR>+=20
 &nbsp;kdb_active++;<BR>+ <BR>+ &nbsp;// set the kdb context<BR>+ =
 &nbsp;kdb_frame=20
 =3D tf;<BR>+ &nbsp;kdb_thr_select( curthread );<BR>+ <BR>&nbsp; &nbsp;/* =
 Let MD=20
 code do its thing first... */<BR>&nbsp; &nbsp;kdb_cpu_trap(type,=20
 code);<BR>&nbsp; <BR>&nbsp; &nbsp;handled =3D =
 kdb_dbbe-&gt;dbbe_trap(type,=20
 code);<BR>&nbsp; <BR>+ &nbsp;// release the prize<BR>+ =
 &nbsp;kdb_active--;<BR>+=20
 <BR>+ &nbsp;// let other CPUs have a chance to run<BR>&nbsp; #ifdef=20
 SMP<BR>&nbsp; &nbsp;if (did_stop_cpus)<BR>&nbsp;=20
 &nbsp;&nbsp;restart_cpus(stopped_cpus);<BR>&nbsp; #endif<BR>&nbsp; <BR>! =
 
 &nbsp;// let our own ISRs to run<BR>&nbsp; =
 &nbsp;critical_exit();<BR>&nbsp;=20
 <BR>&nbsp; &nbsp;return (handled);<BR></DIV></FONT>
 <DIV>&nbsp;</DIV>
 <STYLE>
 <!--
 A.psl {
 	TEXT-DECORATION:none; COLOR: #4e81c4
 }
 A:hover {
 	TEXT-DECORATION: underline
 }
 A.psl:hover {
 	COLOR: #999999
 }
 .noro {
 	FONT-SIZE: 8pt; COLOR: #4e81c4; FONT-FAMILY: Verdana,Arial,fixed
 }
 .tiny {
 	FONT-SIZE: 1pt
 }
 .logotext {
 	TEXT-DECORATION: none; FONT-SIZE: 10pt; COLOR: #ffffff; FONT-FAMILY: =
 Verdana,Arial,fixed
 }
 A.brand {
 	COLOR: #777777; FONT-SIZE: 7pt; FONT-FAMILY: Verdana,Arial,fixed; =
 TEXT-DECORATION: none
 }
 -->
 </STYLE>
 
 <TABLE cellSpacing=3D0 cellPadding=3D0 width=3D600 border=3D0>
   <TBODY>
   <TR>
     <TD>
       <TABLE height=3D80 cellSpacing=3D0 cellPadding=3D0 width=3D600 =
 align=3Dright=20
       border=3D0>
         <TBODY>
         <TR>
           <TD class=3Dtiny>
             <TABLE=20
             style=3D"BORDER-RIGHT: #666666 1px solid; BORDER-TOP: =
 #666666 1px solid; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: =
 #666666 1px solid"=20
             height=3D"100%" cellSpacing=3D0 width=3D600>
               <TBODY>
               <TR bgColor=3D#4e81c4>
                 <TD class=3Dtiny width=3D"100%" height=3D1>
                   <TABLE cellSpacing=3D0 cellPadding=3D1 width=3D"100%" =
 border=3D0>
                     <TBODY>
                     <TR>
                       <TD class=3Dlogotext style=3D"PADDING-LEFT: =
 5px"><A=20
                         class=3Dlogotext=20
                         href=3D"http://www.predictableresponse.com/"=20
                         target=3D_blank><IMG =
 src=3D"cid:260253404 at 26102005-0B99"=20
                         border=3D0></A></TD>
                       <TD class=3Dnoro=20
                       style=3D"PADDING-RIGHT: 5px; FONT-SIZE: 7pt; =
 COLOR: #ffffff"=20
                       align=3Dright>Engineering Reliable Software=20
                     Solutions...</TD></TR></TBODY></TABLE></TD>
                 <TD class=3Dtiny></TD></TR>
               <TR>
                 <TD colSpan=3D2>
                   <TABLE height=3D"100%" cellSpacing=3D2 width=3D"100%" =
 align=3Dright=20
                   border=3D0>
                     <TBODY>
                     <TR style=3D"PADDING-BOTTOM: 4px" height=3D1>
                       <TD class=3Dnoro style=3D"PADDING-LEFT: 4px"=20
                         vAlign=3Dtop><B>Lonnie =
 VanZandt</B><BR><I>Consulting=20
                         Systems Engineer</I> </TD>
                       <TD class=3Dnoro style=3D"PADDING-RIGHT: 4px" =
 vAlign=3Dtop=20
                       align=3Dright><B>Predictable Response =
 Consulting</B><BR><A=20
                         class=3Dpsl=20
                         =
 href=3D"http://maps.yahoo.com/py/maps.py?Pyt=3DTmap&amp;addr=3D637+Witter=
 +Gulch+Road&amp;csz=3DEvergreen%2C+CO+80439&amp;country=3Dus"=20
                         target=3D_blank>637 Witter Gulch =
 Road<BR>Evergreen, CO=20
                         80439</A> </TD></TR>
                     <TR height=3D1>
                       <TD class=3Dnoro=20
                       style=3D"PADDING-LEFT: 4px; PADDING-BOTTOM: 4px"=20
                       vAlign=3Dbottom><A class=3Dpsl=20
                         href=3D"mailto:lonniev at predictableresponse.com"=20
                         =
 target=3D_blank>lonniev at predictableresponse.com</A><BR>IM:=20
                         lonnievanzandt at yahoo.com </TD>
                       <TD class=3Dnoro=20
                       style=3D"PADDING-RIGHT: 4px; PADDING-BOTTOM: 4px"=20
                       vAlign=3Dbottom align=3Dright>
                         <TABLE cellSpacing=3D0 align=3Dright border=3D0>
                           <TBODY>
                           <TR>
                             <TD class=3Dnoro noWrap align=3Dright>tel: =
 <BR>fax:=20
                               <BR>mobile: </TD>
                             <TD class=3Dnoro style=3D"PADDING-LEFT: 4px" =
 noWrap=20
                             align=3Dright>303 679-6035<BR>303 =
 679-8119<BR>720=20
                               201-1349=20
                 =
 </TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE></TD></TR></TBODY></T=
 ABLE></TD>
           <TD></TD></TR></TBODY></TABLE></TD></TR>
   <TR>
     <TD class=3Dtiny colSpan=3D2>
       <TABLE cellSpacing=3D0 cellPadding=3D0 width=3D"100%">
         <TBODY>
         <TR>
           <TD align=3Dleft><A class=3Dbrand=20
             =
 href=3D"https://www.plaxo.com/add_me?u=3D410949&amp;v0=3D816147&amp;k0=3D=
 1128357437"=20
             target=3D_blank><I>Add me to your address =
 book...</I></A></TD>
           <TD align=3Dright><A class=3Dbrand =
 href=3D"http://www.plaxo.com/signature"=20
             target=3D_blank><I>Want a signature like=20
       this?</I></A></TD></TR></TBODY></TABLE></TD></TR></TBODY></TABLE>
 <DIV>&nbsp;</DIV></BODY></HTML>
 
 ------=_NextPart_001_0186_01C5D9B4.761893B0--
 
 ------=_NextPart_000_0185_01C5D9B4.761893B0
 Content-Type: image/gif;
 	name="Predictable Logo as GIF.gif"
 Content-Transfer-Encoding: base64
 Content-ID: <260253404 at 26102005-0B99>
 
 R0lGODdheQBOAHcAACH+GlNvZnR3YXJlOiBNaWNyb3NvZnQgT2ZmaWNlACwAAAAAeQBOAIcAAAAA
 ADMAAGYAAJkAAMwAAP8AMwAAMzMAM2YAM5kAM8wAM/8AZgAAZjMAZmYAZpkAZswAZv8AmQAAmTMA
 mWYAmZkAmcwAmf8AzAAAzDMAzGYAzJkAzMwAzP8A/wAA/zMA/2YA/5kA/8wA//8zAAAzADMzAGYz
 AJkzAMwzAP8zMwAzMzMzM2YzM5kzM8wzM/8zZgAzZjMzZmYzZpkzZswzZv8zmQAzmTMzmWYzmZkz
 mcwzmf8zzAAzzDMzzGYzzJkzzMwzzP8z/wAz/zMz/2Yz/5kz/8wz//9mAABmADNmAGZmAJlmAMxm
 AP9mMwBmMzNmM2ZmM5lmM8xmM/9mZgBmZjNmZmZmZplmZsxmZv9mmQBmmTNmmWZmmZlmmcxmmf9m
 zABmzDNmzGZmzJlmzMxmzP9m/wBm/zNm/2Zm/5lm/8xm//+ZAACZADOZAGaZAJmZAMy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