Race condition in izo_upc_upcall() ?

=?ks_c_5601-1987?B?seggtb+/7Q==?= <[email protected]> Mon, 6 Oct 2003 18:46:10 +0900
Newsgroups gmane.comp.file-systems.intermezzo.devel
Message-ID <[email protected]>
This is a multi-part message in MIME format.

------_=_NextPart_001_01C38BEE.ABFDC27C
Content-Type: text/plain;
	charset="ks_c_5601-1987"
Content-Transfer-Encoding: quoted-printable

Hi, I think there=A1=AFs a race condition in the izo_upc_upcall().=20
The izo_upc_upcall() looks like this:
...
    buffer->u_uniq =3D req->rq_unique;
    buffer->u_async =3D async;
    spin_lock(&channel->uc_lock);
    list_add(&req->rq_chain, channel->uc_pending.prev);
    CDEBUG(...);
    wake_up_interruptible(&channel->uc_waitq);
    if (async) {
        req->rq_flags =3D REQ_ASYNC;
        EXIT;
        Return 0;
    }
...
As you can see the REQ_ASYNC is set after the request is added=20
into the channel->uc_pending list. But in the presto_psdev_read(),=20
the request is added into the channel->uc_processing if the=20
REQ_ASYNC is not set. And at the end of the presto_psdev_read(),=20
the request is got free if REQ_ASYNC is set. On SMP machine, I=20
think, this could lead to a Oops.
=20
=20
=20
=20
=20

------_=_NextPart_001_01C38BEE.ABFDC27C
Content-Type: text/html;
	charset="ks_c_5601-1987"
Content-Transfer-Encoding: quoted-printable

<html xmlns:o=3D"urn:schemas-microsoft-com:office:office" =
xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns=3D"http://www.w3.org/TR/REC-html40">

<head>
<META HTTP-EQUIV=3D"Content-Type" CONTENT=3D"text/html; =
charset=3Dks_c_5601-1987">


<meta name=3DProgId content=3DWord.Document>
<meta name=3DGenerator content=3D"Microsoft Word 10">
<meta name=3DOriginator content=3D"Microsoft Word 10">
<link rel=3DFile-List href=3D"cid:[email protected]">
<!--[if gte mso 9]><xml>
 <o:OfficeDocumentSettings>
  <o:DoNotRelyOnCSS/>
 </o:OfficeDocumentSettings>
</xml><![endif]--><!--[if gte mso 9]><xml>
 <w:WordDocument>
  <w:GrammarState>Clean</w:GrammarState>
  <w:DocumentKind>DocumentEmail</w:DocumentKind>
  <w:EnvelopeVis/>
  =
<w:DisplayHorizontalDrawingGridEvery>0</w:DisplayHorizontalDrawingGridEve=
ry>
  =
<w:DisplayVerticalDrawingGridEvery>2</w:DisplayVerticalDrawingGridEvery>
  <w:Compatibility>
   <w:SpaceForUL/>
   <w:BalanceSingleByteDoubleByteWidth/>
   <w:DoNotLeaveBackslashAlone/>
   <w:ULTrailSpace/>
   <w:DoNotExpandShiftReturn/>
   <w:AdjustLineHeightInTable/>
   <w:BreakWrappedTables/>
   <w:SnapToGridInCell/>
   <w:WrapTextWithPunct/>
   <w:UseAsianBreakRules/>
   <w:UseFELayout/>
  </w:Compatibility>
  <w:BrowserLevel>MicrosoftInternetExplorer4</w:BrowserLevel>
 </w:WordDocument>
</xml><![endif]-->
<style>
<!--
 /* Font Definitions */
 @font-face
	{font-family:=B9=D9=C5=C1;
	panose-1:2 3 6 0 0 1 1 1 1 1;
	mso-font-alt:Batang;
	mso-font-charset:129;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
@font-face
	{font-family:=B1=BC=B8=B2;
	panose-1:2 11 6 0 0 1 1 1 1 1;
	mso-font-alt:Gulim;
	mso-font-charset:129;
	mso-generic-font-family:modern;
	mso-font-pitch:variable;
	mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
@font-face
	{font-family:"\@=B1=BC=B8=B2";
	panose-1:2 11 6 0 0 1 1 1 1 1;
	mso-font-charset:129;
	mso-generic-font-family:modern;
	mso-font-pitch:variable;
	mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
@font-face
	{font-family:"\@=B9=D9=C5=C1";
	panose-1:2 3 6 0 0 1 1 1 1 1;
	mso-font-charset:129;
	mso-generic-font-family:roman;
	mso-font-pitch:variable;
	mso-font-signature:-1342176593 1775729915 48 0 524447 0;}
 /* Style Definitions */
 p.MsoNormal, li.MsoNormal, div.MsoNormal
	{mso-style-parent:"";
	margin:0cm;
	margin-bottom:.0001pt;
	text-align:justify;
	text-justify:inter-ideograph;
	mso-pagination:none;
	text-autospace:none;
	word-break:break-hangul;
	font-size:10.0pt;
	mso-bidi-font-size:12.0pt;
	font-family:=B9=D9=C5=C1;
	mso-hansi-font-family:"Times New Roman";
	mso-bidi-font-family:"Times New Roman";
	mso-font-kerning:1.0pt;}
a:link, span.MsoHyperlink
	{color:blue;
	text-decoration:underline;
	text-underline:single;}
a:visited, span.MsoHyperlinkFollowed
	{color:purple;
	text-decoration:underline;
	text-underline:single;}
span.EmailStyle17
	{mso-style-type:personal-compose;
	mso-style-noshow:yes;
	mso-ansi-font-size:10.0pt;
	mso-bidi-font-size:10.0pt;
	font-family:=B1=BC=B8=B2;
	mso-ascii-font-family:=B1=BC=B8=B2;
	mso-fareast-font-family:=B1=BC=B8=B2;
	mso-hansi-font-family:Arial;
	mso-bidi-font-family:Arial;
	color:windowtext;}
span.GramE
	{mso-style-name:"";
	mso-gram-e:yes;}
 /* Page Definitions */
 @page
	{mso-page-border-surround-header:no;
	mso-page-border-surround-footer:no;}
@page Section1
	{size:595.3pt 841.9pt;
	margin:99.25pt 3.0cm 3.0cm 3.0cm;
	mso-header-margin:42.55pt;
	mso-footer-margin:49.6pt;
	mso-paper-source:0;
	layout-grid:18.0pt;}
div.Section1
	{page:Section1;}
-->
</style>
<!--[if gte mso 10]>
<style>
 /* Style Definitions */=20
 table.MsoNormalTable
	{mso-style-name:"=C7=A5=C1=D8 =C7=A5";
	mso-tstyle-rowband-size:0;
	mso-tstyle-colband-size:0;
	mso-style-noshow:yes;
	mso-style-parent:"";
	mso-padding-alt:0cm 5.4pt 0cm 5.4pt;
	mso-para-margin:0cm;
	mso-para-margin-bottom:.0001pt;
	mso-pagination:widow-orphan;
	font-size:10.0pt;
	font-family:"Times New Roman";}
</style>
<![endif]-->
</head>

<body lang=3DKO link=3Dblue vlink=3Dpurple =
style=3D'tab-interval:40.0pt'>

<div class=3DSection1 style=3D'layout-grid:18.0pt'>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>Hi, I think there</span></font><font =
face=3DArial><span
lang=3DEN-US =
style=3D'mso-bidi-font-size:10.0pt;font-family:Arial;mso-ascii-font-famil=
y:
=B1=BC=B8=B2;mso-fareast-font-family:=B1=BC=B8=B2'>=A1=AF</span></font><f=
ont face=3D=B1=BC=B8=B2><span lang=3DEN-US
style=3D'mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-fon=
t-family:Arial;
mso-bidi-font-family:Arial'>s a race condition in the izo_upc_<span
class=3DGramE>upcall(</span>). <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>The izo_upc_<span =
class=3DGramE>upcall(</span>) looks
like this:<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>...<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span><span class=3DGramE>buffer</span>-&gt;u_uniq =3D =
req-&gt;rq_unique;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span><span class=3DGramE>buffer</span>-&gt;u_async =3D =
async;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span>spin_<span =
class=3DGramE>lock(</span>&amp;channel-&gt;uc_lock);<o:p></o:p></span></f=
ont></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span>list_<span class=3DGramE>add(</span>&amp;req-&gt;rq_chain,
channel-&gt;uc_pending.prev);<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span><span =
class=3DGramE>CDEBUG(</span>...);<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span>wake_up_<span =
class=3DGramE>interruptible(</span>&amp;channel-&gt;uc_waitq);<o:p></o:p>=
</span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span><span class=3DGramE>if</span> (async) =
{<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span><span
class=3DGramE>req</span>-&gt;rq_flags =3D =
REQ_ASYNC;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
</span>EXIT;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
</span>Return
0;<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><span =
style=3D'mso-spacerun:yes'>&nbsp;&nbsp;&nbsp;
</span>}<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>...<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>As you can see the REQ_ASYNC is set after =
the
request is added <o:p></o:p></span></font></p>

<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3D=B1=BC=B8=B2><span lang=3DEN-US
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=
=B2;mso-hansi-font-family:
Arial;mso-bidi-font-family:Arial'>into</span></font></span><font =
face=3D=B1=BC=B8=B2><span
lang=3DEN-US =
style=3D'mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-fon=
t-family:
Arial;mso-bidi-font-family:Arial'> the channel-&gt;uc_pending list. But =
in the presto_psdev_<span
class=3DGramE>read(</span>), <o:p></o:p></span></font></p>

<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3D=B1=BC=B8=B2><span lang=3DEN-US
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=
=B2;mso-hansi-font-family:
Arial;mso-bidi-font-family:Arial'>the</span></font></span><font =
face=3D=B1=BC=B8=B2><span
lang=3DEN-US =
style=3D'mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-fon=
t-family:
Arial;mso-bidi-font-family:Arial'> request is added into the =
channel-&gt;uc_processing
if the <o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'>REQ_ASYNC is not set. And at the end of the
presto_psdev_<span class=3DGramE>read(</span>), =
<o:p></o:p></span></font></p>

<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3D=B1=BC=B8=B2><span lang=3DEN-US
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=
=B2;mso-hansi-font-family:
Arial;mso-bidi-font-family:Arial'>the</span></font></span><font =
face=3D=B1=BC=B8=B2><span
lang=3DEN-US =
style=3D'mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-fon=
t-family:
Arial;mso-bidi-font-family:Arial'> request is got free if REQ_ASYNC is =
set. On
SMP machine, I <o:p></o:p></span></font></p>

<p class=3DMsoNormal><span class=3DGramE><font size=3D2 =
face=3D=B1=BC=B8=B2><span lang=3DEN-US
style=3D'font-size:10.0pt;mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=
=B2;mso-hansi-font-family:
Arial;mso-bidi-font-family:Arial'>think</span></font></span><font =
face=3D=B1=BC=B8=B2><span
lang=3DEN-US =
style=3D'mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-fon=
t-family:
Arial;mso-bidi-font-family:Arial'>, this could lead to a =
Oops.<o:p></o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

<p class=3DMsoNormal><font size=3D2 face=3D=B1=BC=B8=B2><span =
lang=3DEN-US style=3D'font-size:10.0pt;
mso-bidi-font-size:10.0pt;font-family:=B1=BC=B8=B2;mso-hansi-font-family:=
Arial;
mso-bidi-font-family:Arial'><o:p>&nbsp;</o:p></span></font></p>

</div>

</body>

</html>

------_=_NextPart_001_01C38BEE.ABFDC27C--


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf