Hello, While trying to use dev-python/cryptography I got segfaults, which lead me to various of ffi bugs which recommend of setting E bit on executable that use ffi, however doing so on python is not something I expect nor willing to apply. Will be happy to know if there is an actual solution of using cffi in hardened environment. I checked both stable and non stable. I CC cffi, libffi and pax maintainers, feel free to remove your-self if non relevant. Thanks! Tests of dev-python/cffi fails with pax is enabled: --- Sep 03 13:21:01 [kernel] grsec: denied RWX mmap of <anonymous mapping> by /usr/lib64/python-exec/python3.4/emerge[emerge:10853] uid/euid:0/0 gid/egid:0/0, parent /var/tmp/portage/app-shells/bash-4.3_p39/image/bin/bash[bash:14801] uid/euid:0/0 gid/egid:0/0 Sep 03 13:21:10 [kernel] grsec: denied RWX mmap of <anonymous mapping> by /usr/bin/python3.4[python3.4:11275] uid/euid:250/250 gid/egid:250/250, parent /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11196] uid/euid:250/250 gid/egid:250/250 Sep 03 13:21:13 [kernel] grsec: denied RWX mmap of <anonymous mapping> by /usr/bin/python2.7[python2.7:11356] uid/euid:250/250 gid/egid:250/250, parent /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11196] uid/euid:250/250 gid/egid:250/250 Sep 03 13:21:19 [kernel] grsec: denied RWX mmap of <anonymous mapping> by /usr/lib64/python-exec/python3.4/py.test[py.test:11527] uid/euid:250/250 gid/egid:250/250, parent /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11482] uid/euid:250/250 gid/egid:250/250 - Last output repeated twice - Sep 03 13:21:22 [kernel] py.test[11527]: segfault at c ip 00000374916795bb sp 00000388ee2541a0 error 6 in libffi.so.6.0.4[37491673000+8000] --- # emerge --info Portage 2.2.20.1 (python 3.4.1-final-0, hardened/linux/amd64/no-multilib, gcc-4.8.5, glibc-2.20-r2, 4.1.4-hardened x86_64) ================================================================= System uname: Linux-4.1.4-hardened-x86_64-Intel-R-_Core-TM-_i7-3520M_CPU_@_2.90GHz-with-gentoo-2.2 KiB Mem: 12004260 total, 4456888 free KiB Swap: 8388604 total, 7323408 free Timestamp of repository gentoo: Tue, 01 Sep 2015 00:45:02 +0000 sh dash 0.5.8.2 ld GNU ld (Gentoo 2.24 p1.4) 2.24 app-shells/bash: 4.3_p39::gentoo dev-java/java-config: 2.2.0::gentoo dev-lang/perl: 5.20.2::gentoo dev-lang/python: 2.7.9-r1::gentoo, 3.4.1::gentoo dev-util/cmake: 3.2.2::gentoo sys-apps/baselayout: 2.2::gentoo sys-apps/openrc: 0.17::gentoo sys-apps/sandbox: 2.6-r1::gentoo sys-devel/autoconf: 2.13::gentoo, 2.69::gentoo sys-devel/automake: 1.11.6-r1::gentoo, 1.12.6::gentoo, 1.13.4::gentoo, 1.15::gentoo sys-devel/binutils: 2.24-r3::gentoo sys-devel/gcc: 4.8.5::gentoo sys-devel/gcc-config: 1.7.3::gentoo sys-devel/libtool: 2.4.6::gentoo sys-devel/make: 4.1-r1::gentoo sys-kernel/linux-headers: 3.18::gentoo (virtual/os-headers) sys-libs/glibc: 2.20-r2::gentoo Repositories: gentoo location: /var/gentoo/portage sync-type: webrsync sync-uri: rsync://rsync.gentoo.org/gentoo-portage priority: -1000 Installed sets: @alonbl-all, @alonbl-ovirt ACCEPT_KEYWORDS="amd64" ACCEPT_LICENSE="@FSF-APPROVED @FSF-APPROVED-OTHER freedist Artistic as-is BSD-1" CBUILD="x86_64-pc-linux-gnu" CFLAGS="-O2 -march=native -fomit-frame-pointer -pipe" CHOST="x86_64-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/config /usr/share/gnupg/qualified.txt /usr/share/maven-bin-3.0/conf /usr/share/themes/oxygen-gtk/gtk-2.0 /var/lib/hsqldb" CONFIG_PROTECT_MASK="/etc/ca-certificates.conf /etc/env.d /etc/fonts/fonts.conf /etc/gconf /etc/gentoo-release /etc/revdep-rebuild /etc/sandbox.d /etc/terminfo" CXXFLAGS="-O2 -march=native -fomit-frame-pointer -pipe" DISTDIR="/var/gentoo/distfiles" EMERGE_DEFAULT_OPTS="--quiet-build=n" FCFLAGS="-O2 -pipe" FEATURES="assume-digests binpkg-logs cgroup config-protect-if-modified distlocks ebuild-locks fixlafiles ipc-sandbox merge-sync network-sandbox news parallel-fetch preserve-libs protect-owned sandbox sfperms strict unknown-features-warn unmerge-logs unmerge-orphans userfetch userpriv usersandbox usersync webrsync-gpg xattr" FFLAGS="-O2 -pipe" GENTOO_MIRRORS="http://mirror.isoc.org.il/pub/gentoo http://gentoo.mirrors.pair.com" INSTALL_MASK="/lib/systemd /lib32/systemd /lib64/systemd /usr/lib/systemd /usr/lib32/systemd /usr/lib64/systemd /etc/systemd" LANG="he_IL.UTF-8" LDFLAGS="-Wl,-O1 -Wl,--as-needed" MAKEOPTS="-j6" PKGDIR="/var/gentoo/packages" PORTAGE_CONFIGROOT="/" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --omit-dir-times --compress --force --whole-file --delete --stats --human-readable --timeout=180 --exclude=/distfiles --exclude=/local --exclude=/packages" PORTAGE_TMPDIR="/var/tmp" USE="X acl alsa amd64 bidi bluetooth bzip2 caps cli cracklib dri egl fam fontforge hardened iconv ipv6 joystick jpeg jpeg2k justify kde kerberos logrotate lzma mmx mmxext modules mp3 mpeg ncurses nls nptl ogg opengl openmp pam pax_kernel pcre pie plasma png qt4 readline samba seccomp session sse sse2 ssl ssp svg tcpd tiff unicode urandom vim-syntax vorbis xattr xtpax xv zlib" ABI_X86="64" ALSA_CARDS="ali5451 als4000 atiixp atiixp-modem bt87x ca0106 cmipci emu10k1x ens1370 ens1371 es1938 es1968 fm801 hda-intel intel8x0 intel8x0m maestro3 trident usb-audio via82xx via82xx-modem ymfpci" APACHE2_MODULES="authn_core authz_core socache_shmcb unixd actions alias auth_basic authn_alias authn_anon authn_dbm authn_default authn_file authz_dbm authz_default authz_groupfile authz_host authz_owner authz_user autoindex cache cgi cgid dav dav_fs dav_lock deflate dir disk_cache env expires ext_filter file_cache filter headers include info log_config logio mem_cache mime mime_magic negotiation rewrite setenvif speling status unique_id userdir usertrack vhost_alias proxy proxy_http proxy_ajp" CALLIGRA_FEATURES="author braindump flow karbon kexi krita sheets stage words" CAMERAS="ptp2" COLLECTD_PLUGINS="df interface irq load memory rrdtool swap syslog" CPU_FLAGS_X86="aes avx mmx mmxext popcnt sse sse2 sse3 sse4_1 sse4_2 ssse3" ELIBC="glibc" GPSD_PROTOCOLS="ashtech aivdm earthmate evermore fv18 garmin garmintxt gpsclock itrax mtk3301 nmea ntrip navcom oceanserver oldstyle oncore rtcm104v2 rtcm104v3 sirf superstar2 timing tsip tripmate tnt ublox ubx" INPUT_DEVICES="evdev" KERNEL="linux" LCD_DEVICES="bayrad cfontz cfontz633 glk hd44780 lb216 lcdm001 mtxorb ncurses text" LIBREOFFICE_EXTENSIONS="presenter-console presenter-minimizer" LINGUAS="en he" OFFICE_IMPLEMENTATION="libreoffice" PHP_TARGETS="php5-5" PYTHON_SINGLE_TARGET="python2_7" PYTHON_TARGETS="python2_7 python3_4" QEMU_SOFTMMU_TARGETS="x86_64 mips mipsel ppc" RUBY_TARGETS="ruby19 ruby20" USERLAND="GNU" VIDEO_CARDS="intel" XTABLES_ADDONS="quota2 psd pknock lscan length2 ipv4options ipset ipp2p iface geoip fuzzy condition tee tarpit sysrq steal rawnat logmark ipmark dhcpmac delude chaos account" Unset: CC, CPPFLAGS, CTARGET, CXX, LC_ALL, PORTAGE_BUNZIP2_COMMAND, PORTAGE_COMPRESS, PORTAGE_CO
(In reply to Alon Bar-Lev from comment #0) > Hello, > > While trying to use dev-python/cryptography I got segfaults, which lead me > to various of ffi bugs which recommend of setting E bit on executable that > use ffi, however doing so on python is not something I expect nor willing to > apply. > > Will be happy to know if there is an actual solution of using cffi in > hardened environment. > > I checked both stable and non stable. > > I CC cffi, libffi and pax maintainers, feel free to remove your-self if non > relevant. > > Thanks! > > Tests of dev-python/cffi fails with pax is enabled: > --- > Sep 03 13:21:01 [kernel] grsec: denied RWX mmap of <anonymous mapping> by > /usr/lib64/python-exec/python3.4/emerge[emerge:10853] uid/euid:0/0 > gid/egid:0/0, parent > /var/tmp/portage/app-shells/bash-4.3_p39/image/bin/bash[bash:14801] > uid/euid:0/0 gid/egid:0/0 > Sep 03 13:21:10 [kernel] grsec: denied RWX mmap of <anonymous mapping> by > /usr/bin/python3.4[python3.4:11275] uid/euid:250/250 gid/egid:250/250, > parent /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11196] > uid/euid:250/250 gid/egid:250/250 > Sep 03 13:21:13 [kernel] grsec: denied RWX mmap of <anonymous mapping> by > /usr/bin/python2.7[python2.7:11356] uid/euid:250/250 gid/egid:250/250, > parent /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11196] > uid/euid:250/250 gid/egid:250/250 > Sep 03 13:21:19 [kernel] grsec: denied RWX mmap of <anonymous mapping> by > /usr/lib64/python-exec/python3.4/py.test[py.test:11527] uid/euid:250/250 > gid/egid:250/250, parent > /usr/lib64/portage/python3.4/ebuild.sh[ebuild.sh:11482] uid/euid:250/250 > gid/egid:250/250 > - Last output repeated twice - > Sep 03 13:21:22 [kernel] py.test[11527]: segfault at c ip 00000374916795bb > sp 00000388ee2541a0 error 6 in libffi.so.6.0.4[37491673000+8000] We allready set E on python and CONFIG_PAX_EMUTRAMP should be default on. There is no way around the mmap thing.
(In reply to Magnus Granberg from comment #1) > We allready set E on python and CONFIG_PAX_EMUTRAMP should be default on. > There is no way around the mmap thing. So... where do we go from here? Do we need to set some additional PaX marking (disable mprotect)? Do we mask cffi on hardend? Do we just close this bug as CANTFIX?
Alon Bar-Lev check youre kernel config and the pax flags. Have been working fine for me.
(In reply to Magnus Granberg from comment #3) > Alon Bar-Lev check youre kernel config and the pax flags. > Have been working fine for me. thanks! indeed enabling CONFIG_PAX_EMUTRAMP solved this issue, I had this off for three years or so without any issue(?!?). I also read the help string which added by our team, maybe if it is that important add a test for this in libffi as we do with other packages that requires special kernel settings? thanks for the help!
(In reply to Alon Bar-Lev from comment #4) > I also read the help string which added by our team, maybe if it is that > important add a test for this in libffi as we do with other packages that > requires special kernel settings? Feel free to file a bug if you want to see that.