[prev in list] [next in list] [prev in thread] [next in thread] 

List:       strace
Subject:    Re: [PATCH 1/2] sock: fix bitwise OR operation short circuit
From:       JingPiao Chen <chenjingpiao () gmail ! com>
Date:       2016-12-23 0:34:23
Message-ID: CA+AqBCGvA5+b_1cpzTcavraVSdzM1=ZHaGCL=q4wXqZh=w4xQg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


>This cannot be the right fix:
>if umove returned an error, ifc.ifc_buf is undefined.

Yes, I make the same mistake. How to fix this bug? Thanks.

--
JingPiao Chen

2016-12-23 7:03 GMT+08:00 Dmitry V. Levin <ldv@altlinux.org>:

> On Mon, Dec 19, 2016 at 11:33:46PM +0800, JingPiao Chen wrote:
> > sock.c: 150
> >
> > 150         if (syserror(tcp) || umove(tcp, addr, &ifc) < 0) {
> > 151                 if (ifc.ifc_buf)
> > 152                         tprints("}");
> > 153                 else
> > 154                         printaddr(addr);
> > 155                 return RVAL_DECODED | 1;
> > 156         }
> >
> > Second enter function decode_ifconf(), if syserror(tcp) is true,
> > variable ifc is garbage value. "if (ifc.ifc_buf)" may be wrong.
>
> Congratulations, you've found a bug. :)
>
> > From 5b2d4f12d61e5a03212de948508e830c9aeeef87 Mon Sep 17 00:00:00 2001
> > From: JingPiao Chen <chenjingpiao@gmail.com>
> > Date: Mon, 19 Dec 2016 23:08:09 +0800
> > Subject: [PATCH 1/2] sock: fix bitwise OR operation short circuit
> >
> > * sock.c (decode_ifconf): Exchange the place of syserror() and umove().
> > ---
> >  sock.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/sock.c b/sock.c
> > index cf13896..0bdb7a9 100644
> > --- a/sock.c
> > +++ b/sock.c
> > @@ -147,7 +147,7 @@ decode_ifconf(struct tcb *tcp, const long addr)
> >   return 1;
> >   }
> >
> > - if (syserror(tcp) || umove(tcp, addr, &ifc) < 0) {
> > + if (umove(tcp, addr, &ifc) < 0 || syserror(tcp)) {
> >   if (ifc.ifc_buf)
> >   tprints("}");
>
> This cannot be the right fix:
> if umove returned an error, ifc.ifc_buf is undefined.
>
>
> --
> ldv
>
> ------------------------------------------------------------
> ------------------
> Developer Access Program for Intel Xeon Phi Processors
> Access to Intel Xeon Phi processor-based developer platforms.
> With one year of Intel Parallel Studio XE.
> Training and support from Colfax.
> Order your platform today.http://sdm.link/intel
> _______________________________________________
> Strace-devel mailing list
> Strace-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/strace-devel
>
>

[Attachment #5 (text/html)]

<div dir="ltr"><div>&gt;This cannot be the right fix:</div><div>&gt;if umove returned \
an error, ifc.ifc_buf is undefined.</div><div><br></div><div>Yes, I make the same \
mistake. How to fix this bug? Thanks.</div><div><br></div><div>--</div><div>JingPiao \
Chen</div></div><div class="gmail_extra"><br><div class="gmail_quote">2016-12-23 7:03 \
GMT+08:00 Dmitry V. Levin <span dir="ltr">&lt;<a href="mailto:ldv@altlinux.org" \
target="_blank">ldv@altlinux.org</a>&gt;</span>:<br><blockquote class="gmail_quote" \
style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span \
class="">On Mon, Dec 19, 2016 at 11:33:46PM +0800, JingPiao Chen wrote:<br> &gt; \
sock.c: 150<br> &gt;<br>
&gt; 150              if (syserror(tcp) || umove(tcp, addr, &amp;ifc) &lt; 0) {<br>
&gt; 151                          if (ifc.ifc_buf)<br>
&gt; 152                                      tprints(&quot;}&quot;);<br>
&gt; 153                          else<br>
&gt; 154                                      printaddr(addr);<br>
&gt; 155                          return RVAL_DECODED | 1;<br>
&gt; 156              }<br>
&gt;<br>
&gt; Second enter function decode_ifconf(), if syserror(tcp) is true,<br>
&gt; variable ifc is garbage value. &quot;if (ifc.ifc_buf)&quot; may be wrong.<br>
<br>
</span>Congratulations, you&#39;ve found a bug. :)<br>
<span class=""><br>
&gt; From 5b2d4f12d61e5a03212de948508e83<wbr>0c9aeeef87 Mon Sep 17 00:00:00 2001<br>
&gt; From: JingPiao Chen &lt;<a \
href="mailto:chenjingpiao@gmail.com">chenjingpiao@gmail.com</a>&gt;<br> &gt; Date: \
Mon, 19 Dec 2016 23:08:09 +0800<br> &gt; Subject: [PATCH 1/2] sock: fix bitwise OR \
operation short circuit<br> &gt;<br>
&gt; * sock.c (decode_ifconf): Exchange the place of syserror() and umove().<br>
&gt; ---<br>
&gt;   sock.c | 2 +-<br>
&gt;   1 file changed, 1 insertion(+), 1 deletion(-)<br>
&gt;<br>
&gt; diff --git a/sock.c b/sock.c<br>
&gt; index cf13896..0bdb7a9 100644<br>
&gt; --- a/sock.c<br>
&gt; +++ b/sock.c<br>
&gt; @@ -147,7 +147,7 @@ decode_ifconf(struct tcb *tcp, const long addr)<br>
&gt;     return 1;<br>
&gt;     }<br>
&gt;<br>
&gt; - if (syserror(tcp) || umove(tcp, addr, &amp;ifc) &lt; 0) {<br>
&gt; + if (umove(tcp, addr, &amp;ifc) &lt; 0 || syserror(tcp)) {<br>
&gt;     if (ifc.ifc_buf)<br>
&gt;     tprints(&quot;}&quot;);<br>
<br>
</span>This cannot be the right fix:<br>
if umove returned an error, ifc.ifc_buf is undefined.<br>
<span class="HOEnZb"><font color="#888888"><br>
<br>
--<br>
ldv<br>
</font></span><br>------------------------------<wbr>------------------------------<wbr>------------------<br>
 Developer Access Program for Intel Xeon Phi Processors<br>
Access to Intel Xeon Phi processor-based developer platforms.<br>
With one year of Intel Parallel Studio XE.<br>
Training and support from Colfax.<br>
Order your platform today.<a href="http://sdm.link/intel" rel="noreferrer" \
target="_blank">http://sdm.link/intel</a><br>______________________________<wbr>_________________<br>
 Strace-devel mailing list<br>
<a href="mailto:Strace-devel@lists.sourceforge.net">Strace-devel@lists.<wbr>sourceforge.net</a><br>
 <a href="https://lists.sourceforge.net/lists/listinfo/strace-devel" rel="noreferrer" \
target="_blank">https://lists.sourceforge.net/<wbr>lists/listinfo/strace-devel</a><br>
 <br></blockquote></div><br></div>



------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today.http://sdm.link/intel

_______________________________________________
Strace-devel mailing list
Strace-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/strace-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic