Gentoo Archives: gentoo-hardened

From: "Anthony G. Basile" <basile@××××××××××××××.edu>
To: gentoo-hardened@l.g.o
Subject: Re: [gentoo-hardened] denied RWX mmap by layman
Date: Sun, 08 Jun 2014 13:22:14
Message-Id: 5394637F.50808@opensource.dyc.edu
In Reply to: Re: [gentoo-hardened] denied RWX mmap by layman by "Tóth Attila"
1 On 06/08/14 04:31, "Tóth Attila" wrote:
2 > 2014.Június 8.(V) 02:55 időpontban Anthony G. Basile ezt írta:
3 >> On 06/07/14 17:48, "Tóth Attila" wrote:
4 >>> 2014.Június 7.(Szo) 23:22 időpontban Alex Efros ezt írta:
5 >>>> Some time ago I noticed this in kernel logs:
6 >>>> kern.alert: grsec: denied RWX mmap of <anonymous mapping> by
7 >>>> /usr/lib64/python-exec/python2.7/layman[layman:9717] uid/euid:0/0
8 >>>> gid/egid:0/0, parent /bin/bash[sh:9695] uid/euid:0/0 gid/egid:0/0
9 >>>>
10 >>>> Looks like it doesn't break layman, but I still wonder why it happens
11 >>>> and
12 >>>> is it possible to fix this (without paxmarking python, of course)?
13 >>>
14 >>> I don't see this in my logs. The python executable has the "E" flag on
15 >>> my
16 >>> systems.
17 >>>
18 >>> Dw.
19 >>>
20 >>
21 >> Okay I need to document this loudly --- not sure how to do that except
22 >> to just keep repeating it until it becomes public knowledge:
23 >>
24 >> When running with a pax kernel, you must enable EMUTRAMP in your Kconfig
25 >> and you must paxmark your python exe's with E. Note: EMUTRAMP is on by
26 >> default and the ebuild automatically does the markings for you, so leave
27 >> the defaults alone.
28 >>
29 >> If you don't, python apps will hit rwx mmap denials by the pax kernel.
30 >> Things like libffi try to work around this by spitting out little
31 >> snippets of code to the filesystem when the mmap fails; but, if you have
32 >> strict TPE on, even this workaround fails and you get a pretty dead
33 >> system (all python apps badly crippled). There are various ways around
34 >> this but we've settled on the EMUTRAMP solution. See
35 >
36 > I see a problem here, that Alex has python binaries installed on his
37 > system with inconsistent PAX markings (PT: e, XATTR: E). I don't know his
38 > kernel config, but in my experience these flags can get misinterpreted
39 > instead of taking the XATTR:E flag or the default EMUTRAMP enabled.
40 > Despite it is not advised to keep both PT and XATTR markings on a system
41 > at the same time, some users may still have both and run into problems
42 > like Alex.
43 > I introduced kinda chpax init style logic as a workaround on my systems to
44 > double check sensitive binaries have correct PAX markings.
45 > Can we expect these symptoms to go away by the advent of the new hardened
46 > install helper?
47 >
48 > BR: Dw.
49 >
50
51 Remember that the kernel decides what markings to look at. So if you
52 have XATTR_PAX enabled in the kernel, that's what it will look at and it
53 will ignore the other markings. In userland, the safest thing to do so
54 far is to enable both XATTR and PT markings in make.conf using
55 PAX_MARKINGS="XT PT". This will make sure the eclass does both markings.
56
57 I've been slow (ie stuck) on how portage does wrapping but finally
58 figured out the issues. Today hopefully I'll have install-xattr wrapper
59 working with portage. Then its a matter of politicking it into portage.
60 At that point we will have end-to-end xattr support in portage and
61 people should be able to run a pure XATTR system.
62
63 --
64 Anthony G. Basile, Ph. D.
65 Chair of Information Technology
66 D'Youville College
67 Buffalo, NY 14201
68 (716) 829-8197

Replies

Subject Author
Re: [gentoo-hardened] denied RWX mmap by layman "Tóth Attila" <atoth@××××××××××.hu>