<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://bugs.webkit.org/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4.1"
          urlbase="https://bugs.webkit.org/"
          
          maintainer="admin@webkit.org"
>

    <bug>
          <bug_id>65316</bug_id>
          
          <creation_ts>2011-07-28 07:28:46 -0700</creation_ts>
          <short_desc>Potential NULL-pointer vulnerability in [RenderLayer::updateLayerPosition]</short_desc>
          <delta_ts>2024-08-05 18:43:13 -0700</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>WebKit</product>
          <component>Layout and Rendering</component>
          <version>528+ (Nightly build)</version>
          <rep_platform>All</rep_platform>
          <op_sys>All</op_sys>
          <bug_status>UNCONFIRMED</bug_status>
          <resolution></resolution>
          
          
          <bug_file_loc>http://www.gismeteo.ru/city/daily/4079/</bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords>EasyFix, GoodFirstBug, NeedsReduction</keywords>
          <priority>P3</priority>
          <bug_severity>Normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>0</everconfirmed>
          <reporter name="Alexey Utkin">alexey.utkin</reporter>
          <assigned_to name="Nobody">webkit-unassigned</assigned_to>
          <cc>abarth</cc>
    
    <cc>ap</cc>
    
    <cc>deepak.m1</cc>
    
    <cc>eric</cc>
    
    <cc>jaepark</cc>
    
    <cc>jchaffraix</cc>
    
    <cc>webkit.review.bot</cc>
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>443480</commentid>
    <comment_count>0</comment_count>
    <who name="Alexey Utkin">alexey.utkin</who>
    <bug_when>2011-07-28 07:28:46 -0700</bug_when>
    <thetext>Potential vulnerability in the method    
void RenderLayer::updateLayerPosition()
(file http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderLayer.cpp)

Code fragment (lines 660-676)

    if (!renderer()-&gt;isPositioned() &amp;&amp; renderer()-&gt;parent()) {
        // We must adjust our position by walking up the render tree looking for the
        // nearest enclosing object with a layer.
        RenderObject* curr = renderer()-&gt;parent();
        while (curr &amp;&amp; !curr-&gt;hasLayer()) {
            if (curr-&gt;isBox() &amp;&amp; !curr-&gt;isTableRow()) {
                // Rows and cells share the same coordinate space (that of the section).
                // Omit them when computing our xpos/ypos.
                localPoint += toRenderBox(curr)-&gt;locationOffsetIncludingFlipping();
            }
            curr = curr-&gt;parent();
        }
        if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) { // &lt;--- here the [curr] var can has a NULL value: check the [while] condition.
            // Put ourselves into the row coordinate space.
            localPoint -= toRenderBox(curr)-&gt;locationOffsetIncludingFlipping();
        }
    }

has NULL-pointer vulnerability.

In our port we have a GPF on transfer from 
    http://www.gismeteo.ru
to (click on St.Petersburg city)
    http://www.gismeteo.ru/city/daily/4079/  

Seems the problem has a relation with 
https://bugs.webkit.org/show_bug.cgi?id=62120</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>447141</commentid>
    <comment_count>1</comment_count>
    <who name="Alexey Utkin">alexey.utkin</who>
    <bug_when>2011-08-05 03:30:37 -0700</bug_when>
    <thetext>Stack trace:
WebCore::RenderLayer::updateLayerPosition()  Line 697	C++
WebCore::RenderLayer::updateLayerPositions(unsigned int flags, WebCore::IntPoint * cachedOffset)  Line 279	C++
WebCore::FrameView::layout(bool allowSubtree)  Line 974	C++
WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive()  Line 2452	C++
WebCore::FocusController::setActive(bool active)  Line 419	C++ //active==false
&lt;ProcessFocusEvent&gt;</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>447145</commentid>
    <comment_count>2</comment_count>
    <who name="Alexey Utkin">alexey.utkin</who>
    <bug_when>2011-08-05 03:38:13 -0700</bug_when>
    <thetext>Suggested fix in line 672 
(file http://trac.webkit.org/browser/trunk/Source/WebCore/rendering/RenderLayer.cpp):

-if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) {
+if (curr &amp;&amp; curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) {</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>743836</commentid>
    <comment_count>3</comment_count>
      <attachid>169084</attachid>
    <who name="Jae Hyun Park">jaepark</who>
    <bug_when>2012-10-16 21:36:45 -0700</bug_when>
    <thetext>Created attachment 169084
Patch</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>744736</commentid>
    <comment_count>4</comment_count>
      <attachid>169084</attachid>
    <who name="Adam Barth">abarth</who>
    <bug_when>2012-10-17 16:01:28 -0700</bug_when>
    <thetext>Comment on attachment 169084
Patch

Can you write a test that triggers this issue?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745079</commentid>
    <comment_count>5</comment_count>
    <who name="Alexey Utkin">alexey.utkin</who>
    <bug_when>2012-10-18 01:30:17 -0700</bug_when>
    <thetext>(In reply to comment #4)
&gt; (From update of attachment 169084 [details])
&gt; Can you write a test that triggers this issue?

Seems that is possible in custom ports only (JavaFX port as an example - the scenario was described in bug synopsis). That happen in slow message queue.

Any way that is a bug form static code analyzer - it have to be fixed.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>745339</commentid>
    <comment_count>6</comment_count>
    <who name="Julien Chaffraix">jchaffraix</who>
    <bug_when>2012-10-18 09:58:00 -0700</bug_when>
    <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; (From update of attachment 169084 [details] [details])
&gt; &gt; Can you write a test that triggers this issue?
&gt; 
&gt; Seems that is possible in custom ports only (JavaFX port as an example - the scenario was described in bug synopsis). That happen in slow message queue.

If the bug requires a custom port, it is possibly not a WebCore issue.

&gt; Any way that is a bug form static code analyzer - it have to be fixed.

No, it doesn&apos;t *have to* (see http://lists.webkit.org/pipermail/webkit-dev/2012-April/020365.html). I am not convinced the change is right as updateLayerPosition should be called only on an attached tree, which means that |curr| cannot be NULL as we are not called on the RenderView (renderer()-&gt;parent()) and the RenderView always has a RenderLayer.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>746153</commentid>
    <comment_count>7</comment_count>
    <who name="Alexey Utkin">alexey.utkin</who>
    <bug_when>2012-10-19 02:19:28 -0700</bug_when>
    <thetext>(In reply to comment #6)
&gt; (In reply to comment #5)
&gt; &gt; (In reply to comment #4)
&gt; &gt; &gt; (From update of attachment 169084 [details] [details] [details])
&gt; &gt; &gt; Can you write a test that triggers this issue?
&gt; &gt; 
&gt; &gt; Seems that is possible in custom ports only (JavaFX port as an example - the scenario was described in bug synopsis). That happen in slow message queue.
&gt; 
&gt; If the bug requires a custom port, it is possibly not a WebCore issue.
&gt; 
&gt; &gt; Any way that is a bug form static code analyzer - it have to be fixed.
&gt; 
&gt; No, it doesn&apos;t *have to* (see http://lists.webkit.org/pipermail/webkit-dev/2012-April/020365.html). I am not convinced the change is right as updateLayerPosition should be called only on an attached tree, which means that |curr| cannot be NULL as we are not called on the RenderView (renderer()-&gt;parent()) and the RenderView always has a RenderLayer.

Well, I am not a code owner or contributer. Code patching is out of competition. The only thing that I see is a code inconsistency. It could be not a WebCore issue, but code structure was contradictory. To be consistence the &quot;while&quot; circle need to be reduced to something like
    while (!curr-&gt;hasLayer())
, or insert an assertion about |curr| before 
    if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) {
line, or accept the patch and report your objection in upper level function.
That is my IMHO.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>746287</commentid>
    <comment_count>8</comment_count>
    <who name="Jae Hyun Park">jaepark</who>
    <bug_when>2012-10-19 07:12:54 -0700</bug_when>
    <thetext>(In reply to comment #7)
&gt; Well, I am not a code owner or contributer. Code patching is out of competition. The only thing that I see is a code inconsistency. It could be not a WebCore issue, but code structure was contradictory. To be consistence the &quot;while&quot; circle need to be reduced to something like
&gt;     while (!curr-&gt;hasLayer())
&gt; , or insert an assertion about |curr| before 
&gt;     if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) {
&gt; line, or accept the patch and report your objection in upper level function.
&gt; That is my IMHO.

I agree. The main reason I created this patch was because of that inconsistency.</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>981433</commentid>
    <comment_count>9</comment_count>
    <who name="Deepak Mittal">deepak.m1</who>
    <bug_when>2014-02-17 07:06:55 -0800</bug_when>
    <thetext>I think adding check for curr in 

if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow())  is required for consistency , as while loop will break when either curr is NULL or curr does not have the layer..

in first case crash will happen in 

if (curr-&gt;isBox() &amp;&amp; curr-&gt;isTableRow()) ..</thetext>
  </long_desc>
      
          <attachment
              isobsolete="0"
              ispatch="1"
              isprivate="0"
          >
            <attachid>169084</attachid>
            <date>2012-10-16 21:36:45 -0700</date>
            <delta_ts>2012-10-17 16:01:27 -0700</delta_ts>
            <desc>Patch</desc>
            <filename>bug-65316-20121017133553.patch</filename>
            <type>text/plain</type>
            <size>1629</size>
            <attacher name="Jae Hyun Park">jaepark</attacher>
            
              <data encoding="base64">U3VidmVyc2lvbiBSZXZpc2lvbjogMTMxNTI2CmRpZmYgLS1naXQgYS9Tb3VyY2UvV2ViQ29yZS9D
aGFuZ2VMb2cgYi9Tb3VyY2UvV2ViQ29yZS9DaGFuZ2VMb2cKaW5kZXggYTc5MTIyMDE1MWU0N2Ix
YTc0N2I4ZDFhNGRmNjU2MTliYWI4OTM0My4uOWY4YTAyYTgxZjNhMDFhNWIyMjFmOGVhMDdiZTIx
YjYzZDNjYjkyZSAxMDA2NDQKLS0tIGEvU291cmNlL1dlYkNvcmUvQ2hhbmdlTG9nCisrKyBiL1Nv
dXJjZS9XZWJDb3JlL0NoYW5nZUxvZwpAQCAtMSwzICsxLDE5IEBACisyMDEyLTEwLTE2ICBKYWUg
SHl1biBQYXJrICA8amFlLnBhcmtAY29tcGFueTEwMC5uZXQ+CisKKyAgICAgICAgUG90ZW50aWFs
IE5VTEwtcG9pbnRlciB2dWxuZXJhYmlsaX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GEvU291cmNlL1dlYkNvcmUvcmVuZGVyaW5nL1JlbmRlckxh
eWVyLmNwcAorKysgYi9Tb3VyY2UvV2ViQ29yZS9yZW5kZXJpbmcvUmVuZGVyTGF5ZXIuY3BwCkBA
IC04NTcsNyArODU3LDcgQEAgdm9pZCBSZW5kZXJMYXllcjo6dXBkYXRlTGF5ZXJQb3NpdGlvbigp
CiAgICAgICAgICAgICB9CiAgICAgICAgICAgICBjdXJyID0gY3Vyci0+cGFyZW50KCk7CiAgICAg
ICAgIH0KLSAgICAgICAgaWYgKGN1cnItPmlzQm94KCkgJiYgY3Vyci0+aXNUYWJsZVJvdygpKSB7
CisgICAgICAgIGlmIChjdXJyICYmIGN1cnItPmlzQm94KCkgJiYgY3Vyci0+aXNUYWJsZVJvdygp
KSB7CiAgICAgICAgICAgICAvLyBQdXQgb3Vyc2VsdmVzIGludG8gdGhlIHJvdyBjb29yZGluYXRl
IHNwYWNlLgogICAgICAgICAgICAgbG9jYWxQb2ludCAtPSB0b1JlbmRlckJveChjdXJyKS0+dG9w
TGVmdExvY2F0aW9uT2Zmc2V0KCk7CiAgICAgICAgIH0K
</data>
<flag name="review"
          id="182254"
          type_id="1"
          status="-"
          setter="abarth"
    />
          </attachment>
      

    </bug>

</bugzilla>