Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 448818 - dev-python/pypy USE=jit does no pax-marking
Summary: dev-python/pypy USE=jit does no pax-marking
Status: RESOLVED FIXED
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Development (show other bugs)
Hardware: All Linux
: Normal normal (vote)
Assignee: Nirbheek Chauhan (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2012-12-27 11:44 UTC by WANG Xuerui
Modified: 2013-05-09 00:00 UTC (History)
3 users (show)

See Also:
Package list:
Runtime testing required: ---


Attachments
Apply "pax-mark m" on the generated pypy executable (pypy-2.0_beta2.ebuild-pax-fix,918 bytes, patch)
2013-05-08 11:09 UTC, Olaf Leidinger
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description WANG Xuerui gentoo-dev 2012-12-27 11:44:56 UTC
Happy Holidays to all developers still reading bug reports at this time~~!

I just debugged a pypy crash on a box running on Hardened Gentoo amd64; the reason is that MPROTECT is not disabled on the pypy executable.

Since the ebuilds do not check for "jit" USE flag and turn off MPROTECT in that case, weird MemoryError's (actually mmap() calls failing with -EPERM) are going to happen to the users who explicitly turned on JIT to emerge pypy. Clearly not so smooth an experience for PyPy users running on PaX...

We should inherit pax-utils and pax-mark the pypy-c executable in src_install, if USE flag jit is set. I can prepare the patch if you don't really have the time (actually I myself is busy preparing for end-term exams, haha), thanks in advance.
Comment 1 Mike Gilbert gentoo-dev 2012-12-27 14:29:36 UTC
@hardened: Ok to add pax-mark m here?
Comment 2 Olaf Leidinger 2013-02-26 09:38:39 UTC
A pax related error, probably the same: 

emerge fails during the install phase  of pypy on a hardened machine. Therefore I created a binary on a non-hardened gentoo and transfered the package to the very hardened box. Obviously installing works, yet running doesn't. A "memory error" is reported - the very same error due to which install fails.

I had to manually run

paxctl -pemrxs /usr/bin/pypy-c2.0

in order to get pypy to work, as mentioned in the gentoo hardened faq.
Comment 3 WANG Xuerui gentoo-dev 2013-02-26 10:06:14 UTC
(In reply to comment #2)
> A pax related error, probably the same: 
> 
> emerge fails during the install phase  of pypy on a hardened machine.
> Therefore I created a binary on a non-hardened gentoo and transfered the
> package to the very hardened box. Obviously installing works, yet running
> doesn't. A "memory error" is reported - the very same error due to which
> install fails.
> 
> I had to manually run
> 
> paxctl -pemrxs /usr/bin/pypy-c2.0
> 
> in order to get pypy to work, as mentioned in the gentoo hardened faq.

Just checked the pypy ebuild for this installation problem, and yes the error is the same. In pypy-2.0_beta1.ebuild:103-110 the fresh PyPy binary is being executed for the pickles, which would immediately die with -EPERM the moment it tries to do JIT.


PS: Actually only MPROTECT needs to be disabled for the executable, that is -m. In my case PyPy is used to run the development branch of a Django site, and I have not yet seen any breakage with all the other PaX features on.
Comment 4 Olaf Leidinger 2013-05-08 11:09:00 UTC
Created attachment 347738 [details, diff]
Apply "pax-mark m" on the generated pypy executable

Apply with patch -p5 < pypy-2.0_beta2.ebuild-pax-fix in /usr/portage/dev-python/pypy
Comment 5 Mike Gilbert gentoo-dev 2013-05-09 00:00:06 UTC
+  08 May 2013; Mike Gilbert <floppym@gentoo.org> pypy-2.0_beta2.ebuild:
+  Disable MPROTECT if jit is enabled, bug 448818.