<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "http://bugs.gentoo.org/bugzilla.dtd">

<bugzilla version="2.22.7"
          urlbase="http://bugs.gentoo.org/"
          maintainer="bugzilla@gentoo.org"
>

    <bug>
          <bug_id>201250</bug_id>
          
          <creation_ts>2007-12-04 18:20 0000</creation_ts>
          <short_desc>x11-libs/wxGTK-2.6.3.3/2.6.4.0-r1 &apos;fatal error: had to relocate PCH&apos;</short_desc>
          <delta_ts>2007-12-06 02:40:51 0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>Gentoo Linux</product>
          <component>Hardened</component>
          <version>unspecified</version>
          <rep_platform>x86</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>RESOLVED</bug_status>
          <resolution>FIXED</resolution>
          
          
          
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          
          <everconfirmed>1</everconfirmed>
          <reporter>bluethegrappler@gmail.com</reporter>
          <assigned_to>wxwidgets@gentoo.org</assigned_to>
          <cc>hardened@gentoo.org</cc>
    
    <cc>pageexec@freemail.hu</cc>

      

      
          <long_desc isprivate="0">
            <who>bluethegrappler@gmail.com</who>
            <bug_when>2007-12-04 18:20:19 0000</bug_when>
            <thetext>according to the PaX team, &quot;precompiled header support (PCH) is not compatible with ASLR, or rather, there&apos;s a botched up attempt at handling it but it&apos;s not compatible with SEGMEXEC&quot; When I used EXTRA_ECONF=&quot;--disable-precomp-headers&quot; I was able to successfully compile wxGTK-2.6.4.0-r1 (I suspect the same works for 2.6.3.3). This seems to be controlled by the PCH useflag in the newer (hardmasked) ebuilds. This needs to be added to the stable ebuild. Also, perhaps the ebuild should check if PaX is enabled to disable PCH.

Reproducible: Always

Steps to Reproduce:
1. Use a kernel with PaX enabled.
2. emerge wxGTK (2.6.3.3 or 2.6.4.0-r1, maybe others)
    FAIL
3. Try again, with EXTRA_ECONF=&quot;--disable-precomp-headers&quot;
    Success :-)

Actual Results:  
Compile succeeds only with EXTRA_ECONF=&quot;--disable-precomp-headers&quot;

Expected Results:  
There should be a useflag for toggling PCH. Also, it would be good if the ebuild could check for PaX and disable PCH.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>rbu@gentoo.org</who>
            <bug_when>2007-12-04 18:25:03 0000</bug_when>
            <thetext>reassigning to hardened. if this is relevant to security, please assign back to us.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-12-04 19:32:33 0000</bug_when>
            <thetext>Is this limited to PaX-ASLR only or could mainlines kernel.randomize_va_space 
also cause problems?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>pageexec@freemail.hu</who>
            <bug_when>2007-12-04 20:52:19 0000</bug_when>
            <thetext>(In reply to comment #2)
&gt; Is this limited to PaX-ASLR only or could mainlines kernel.randomize_va_space 
&gt; also cause problems?

it&apos;s not so much related to randomization but to the halved address space and a bad choice in gcc. what happens is that the data structures/files used by PCH contain absolute addresses, i.e., they are not relocatable (it&apos;s a design choice that noone&apos;s fixing afaik). this means that gcc has to mmap the PCH files at a fixed address but using MAP_FIXED is dangerous since it could replace some already existing mapping, so they just use a hinted mmap request and see if they get the mapping there. PaX/ASLR doesn&apos;t honour this hint (as it&apos;s just a hint) and maps the file at a random address regardless. so far so good, gcc sees this and attempts to deal with the situation by trying to use a per-arch hardcoded address that, in their wisdom, is most likely unmapped (after all most of the gcc address space is unused so it&apos;s not unreasonable to guess such a big enough hole). except the choice for i386 happens to fall above the SEGMEXEC_TASK_SIZE limit, therefore it fails under SEGMEXEC.

so there are two possible fixes: disable the use of PCH if SEGMEXEC is active on gcc, or choose another hardcoded address for i386 (perhaps by keeping the current one and trying a second, SEGMEXEC friendly one when that fails).

short term, you can just disable PCH on this package, but longer term patching gcc would be better.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>leio@gentoo.org</who>
            <bug_when>2007-12-04 21:00:26 0000</bug_when>
            <thetext>As wxWindows team member, I don&apos;t see what we should be doing here. How are we unique in triggering this problem? Could potentially all PCH using packages be affected?
We had all this discussion over half a year ago with PaX and I thought we had this settled.. :)

We now currently have it behind a pch USE flag, but we might want to reconsider at some point..</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>pageexec@freemail.hu</who>
            <bug_when>2007-12-04 22:19:54 0000</bug_when>
            <thetext>(In reply to comment #4)
&gt; As wxWindows team member, I don&apos;t see what we should be doing here. How are we
&gt; unique in triggering this problem? Could potentially all PCH using packages be
&gt; affected?

yes, all are.

&gt; We had all this discussion over half a year ago with PaX and I thought we had
&gt; this settled.. :)

heh, i knew i must have seen this already but didn&apos;t remember ;-).

&gt; We now currently have it behind a pch USE flag, but we might want to reconsider
&gt; at some point..

it&apos;s fine for now, but longer term gcc should be fixed to have a fallback address that work under SEGMEXEC as well.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>bluethegrappler@gmail.com</who>
            <bug_when>2007-12-05 00:20:27 0000</bug_when>
            <thetext>(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; As wxWindows team member, I don&apos;t see what we should be doing here. How are we
&gt; &gt; unique in triggering this problem? Could potentially all PCH using packages be
&gt; &gt; affected?
&gt; 
&gt; yes, all are.
&gt; 
&gt; &gt; We had all this discussion over half a year ago with PaX and I thought we had
&gt; &gt; this settled.. :)
&gt; 
&gt; heh, i knew i must have seen this already but didn&apos;t remember ;-).
&gt; 
&gt; &gt; We now currently have it behind a pch USE flag, but we might want to reconsider
&gt; &gt; at some point..
&gt; 
&gt; it&apos;s fine for now, but longer term gcc should be fixed to have a fallback
&gt; address that work under SEGMEXEC as well.
&gt; 

(In reply to comment #5)
&gt; (In reply to comment #4)
&gt; &gt; As wxWindows team member, I don&apos;t see what we should be doing here. How are we
&gt; &gt; unique in triggering this problem? Could potentially all PCH using packages be
&gt; &gt; affected?
&gt; 
&gt; yes, all are.
&gt; 
&gt; &gt; We had all this discussion over half a year ago with PaX and I thought we had
&gt; &gt; this settled.. :)
&gt; 
&gt; heh, i knew i must have seen this already but didn&apos;t remember ;-).
&gt; 
&gt; &gt; We now currently have it behind a pch USE flag, but we might want to reconsider
&gt; &gt; at some point..
&gt; 
&gt; it&apos;s fine for now, but longer term gcc should be fixed to have a fallback
&gt; address that work under SEGMEXEC as well.
&gt; 

The current stable ebuild doesn&apos;t listen to the pch USE flag, perhaps this should be changed. Currently, all wxGTK ebuilds that listen to the pch USE flag are hardmasked. With an ebuild that does listen to the pch USE flag, will it default to not using pch, at least on hardened systems? Is there a reason not to do this?

Yes, fixing gcc does seem like the ideal solution, does another bug need to be filed for that, or what?
</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dirtyepic@gentoo.org</who>
            <bug_when>2007-12-05 00:27:23 0000</bug_when>
            <thetext>wxGTK-2.6.4.0-r2 and wxGTK-2.8.7.1 have a pch USE flag, but they are masked until eselect-wxwidgets gets keyworded properly.

I have no problem with adding the flag to 2.6.4.0-r1 as well, as it doesn&apos;t affect the final product IIUC.  Would this be satisfactory?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-12-05 00:38:59 0000</bug_when>
            <thetext>Adding that flag and having hardened use.mask the pch USE= flag seems 
the ideal solution for now.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>pageexec@freemail.hu</who>
            <bug_when>2007-12-05 11:13:53 0000</bug_when>
            <thetext>just for reference, the gcc code in question is gcc/config/host-linux.c:linux_gt_pch_get_address() and the unfortunate define is 

#elif defined(__i386)
# define TRY_EMPTY_VM_SPACE    0x60000000

this can/will also fail on kernel configs where the user/kernel split is not 3:1 but lower.</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>dirtyepic@gentoo.org</who>
            <bug_when>2007-12-06 02:17:00 0000</bug_when>
            <thetext>okay, USE flag added to wxGTK-2.6.4.0-r1.  should i close this or do you guys want it open?</thetext>
          </long_desc>
          <long_desc isprivate="0">
            <who>solar@gentoo.org</who>
            <bug_when>2007-12-06 02:40:51 0000</bug_when>
            <thetext>For now we are not going to use.mask the pch flag as the support it 
depends on is an optional config option in the kernel. we wont enable it by default or anything. If it continues to be a problem it will use.masked.

Closing bug as FIXED (avoiding bug spam). 

thanks a lot guys.</thetext>
          </long_desc>
      
    </bug>

</bugzilla>