Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 607990 - app-editors/emacs-25.1 on hardened: ./temacs --batch --load loadup bootstrap - Segmentation fault
Summary: app-editors/emacs-25.1 on hardened: ./temacs --batch --load loadup bootstrap ...
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Current packages (show other bugs)
Hardware: All Linux
: Normal normal
Assignee: GNU Emacs project
URL:
Whiteboard:
Keywords:
: 622146 (view as bug list)
Depends on: 608870
Blocks:
  Show dependency tree
 
Reported: 2017-02-02 09:29 UTC by Anton Kochkov
Modified: 2017-06-26 11:48 UTC (History)
3 users (show)

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


Attachments
full build log (emacs-25.build.log,160.24 KB, text/plain)
2017-02-02 09:29 UTC, Anton Kochkov
Details
emerge --info output (emerge_info.log,17.10 KB, text/plain)
2017-02-02 09:32 UTC, Anton Kochkov
Details
Revert to paxctl/setfattr logic of Emacs 24.5. (emacs-25.1-paxctl.patch,3.44 KB, patch)
2017-02-07 12:00 UTC, Ulrich Müller
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Anton Kochkov 2017-02-02 09:29:51 UTC
Created attachment 462226 [details]
full build log

/bin/mkdir -p ../etc
setfattr -n user.pax.flags -v er temacs
make -C ../lisp update-subdirs
make[2]: Entering directory '/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/lisp'
for file in . ./calc ./calendar ./emacs-lisp ./emulation ./erc ./eshell ./gnus ./international ./language ./mail ./mh-e ./net ./nxml ./obsolete ./org ./play ./progmodes ./term ./textmodes ./url ./vc; do \
   ./../build-aux/update-subdirs $file; \
done;
make[2]: Leaving directory '/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/lisp'
./temacs --batch --load loadup bootstrap
make[1]: *** [Makefile:737: bootstrap-emacs] Segmentation fault
make[1]: Leaving directory '/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/src'
make: *** [Makefile:398: src] Error 2
 [31;01m*[0m ERROR: app-editors/emacs-25.1::gentoo failed (compile phase):
 [31;01m*[0m   emake failed
 [31;01m*[0m 
 [31;01m*[0m If you need support, post the output of `emerge --info '=app-editors/emacs-25.1::gentoo'`,
 [31;01m*[0m the complete build log and the output of `emerge -pqv '=app-editors/emacs-25.1::gentoo'`.
 [31;01m*[0m The complete build log is located at '/var/tmp/portage/app-editors/emacs-25.1/temp/build.log'.
 [31;01m*[0m The ebuild environment file is located at '/var/tmp/portage/app-editors/emacs-25.1/temp/environment'.
 [31;01m*[0m Working directory: '/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1'
 [31;01m*[0m S: '/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1'
Comment 1 Anton Kochkov 2017-02-02 09:32:18 UTC
Created attachment 462228 [details]
emerge --info output

Looks similar to those bugs for older versions of emacs: https://bugs.gentoo.org/show_bug.cgi?id=285778 and https://bugs.gentoo.org/show_bug.cgi?id=456970
Comment 2 Ulrich Müller gentoo-dev 2017-02-06 16:40:14 UTC
What are the values of XATTR_PAX_FLAGS and PT_PAX_FLAGS in your kernel configuration?
Comment 3 Karl-Johan Karlsson 2017-02-06 18:37:44 UTC
I'm seeing the same error, and I have:

# grep PAX_FLAGS /boot/config-$(uname -r)
CONFIG_PAX_PT_PAX_FLAGS=y
CONFIG_PAX_XATTR_PAX_FLAGS=y

# grep PAX /etc/portage/make.conf
PAX_MARKINGS="XT PT"

# paxctl-ng -v /var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/src/temacs
/var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/src/temacs:
        PT_PAX    : -e---
        XATTR_PAX : -e-r-

If I disable all PaX flags on temacs:

# paxctl-ng -pemrs /var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1/src/temacs

and continue the build, it completes successfully:

# ebuild /usr/portage/app-editors/emacs/emacs-25.1.ebuild compile
[...]
>>> Compiling source in /var/tmp/portage/app-editors/emacs-25.1/work/emacs-25.1 ...
[...]
./temacs --batch --load loadup bootstrap
Loading loadup.el (source)...
[...]
>>> Source compiled.
Comment 4 Ulrich Müller gentoo-dev 2017-02-06 19:28:57 UTC
(In reply to Karl-Johan Karlsson from comment #3)
> I'm seeing the same error, and I have:
> 
> # grep PAX_FLAGS /boot/config-$(uname -r)
> CONFIG_PAX_PT_PAX_FLAGS=y
> CONFIG_PAX_XATTR_PAX_FLAGS=y

According to the hardened team, this is not a supported configuration, see bug 497498 comment #13.
Comment 5 Agostino Sarubbo gentoo-dev 2017-02-07 09:29:35 UTC
(In reply to Ulrich Müller from comment #4)
> According to the hardened team, this is not a supported configuration, see
> bug 497498 comment #13.

Ulrich,

I understand that the problem does not reside in emacs, but the fact is that the auto config for grsecurity enables both. So all hardened users will have the same problem.
Comment 6 Ulrich Müller gentoo-dev 2017-02-07 12:00:09 UTC
Created attachment 462772 [details, diff]
Revert to paxctl/setfattr logic of Emacs 24.5.

(In reply to Agostino Sarubbo from comment #5)
> I understand that the problem does not reside in emacs, but the fact is that
> the auto config for grsecurity enables both.

I wonder why that is so, because when asking I was told this:
<ulm> is PT_PAX_FLAGS _and_ XATTR_PAX_FLAGS a supported configuration?
<Zorry> you should only use one of them
<Zorry> and the missmatch check in the kernel i think is removed in newer
        kernel or set softer
<ulm> Zorry: do you know since what kernel version?
<Zorry> i think it was 3.12.6-r2
<blueness> ulm, as Zorry said, use only one

Anyway, please try if attached patch fixes the problem.
Comment 7 Ulrich Müller gentoo-dev 2017-02-07 12:04:11 UTC
CCing hardened team. 

Can you please comment if enabling both of CONFIG_PAX_PT_PAX_FLAGS and CONFIG_PAX_XATTR_PAX_FLAGS is a supported configuration?

Also I was told in 2014 that PT_PAX_FLAGS would go away at some time. That seems not to be the case?
Comment 8 Ulrich Müller gentoo-dev 2017-02-08 10:36:58 UTC
Consultation in #gentoo-hardened confirmed that only one of PT_PAX and XATTR_PAX should be enabled in the kernel.

In fact, the PaX Quickstart Guide https://wiki.gentoo.org/wiki/Hardened/PaX_Quickstart says:

"One final caveat about the two supported methods of doing PaX markings: the PaX kernel allows both PT_PAX and XATTR_PAX to be enabled, however if both features have been enabled PaX will not impose the markings unless the same flags are found in both locations. For this reason, the Hardened Project not recommend enabling both features at the same time, even for migration which is described below."

The two example kernel configurations that follow below this each have only one of the two options enabled.


So I tend to close this bug as INVALID again. I'll also change the build-time dependency to depend only on one of sys-apps/attr and sys-apps/paxctl.

That is, unless someone comes up with a compelling reason why we should revert the Emacs build system to use both setfattr and paxctl (and confirms that the patch from attachment 462772 [details, diff] works).
Comment 9 Jason Zaman gentoo-dev 2017-02-09 14:52:15 UTC
(In reply to Ulrich Müller from comment #8)
> So I tend to close this bug as INVALID again. I'll also change the
> build-time dependency to depend only on one of sys-apps/attr and
> sys-apps/paxctl.
> 
> That is, unless someone comes up with a compelling reason why we should
> revert the Emacs build system to use both setfattr and paxctl (and confirms
> that the patch from attachment 462772 [details, diff] [details, diff] works).

You should just use the pax-utils eclass which will set things properly according to what the user has set in make.conf and fall back to other tools to mark with if the best arnt available. dont just use only one of them.
Comment 10 Ulrich Müller gentoo-dev 2017-02-09 17:48:40 UTC
(In reply to Jason Zaman from comment #9)
> You should just use the pax-utils eclass which will set things properly
> according to what the user has set in make.conf and fall back to other tools
> to mark with if the best arnt available. dont just use only one of them.

Sorry, but that won't work. PaX marking is done purely as an intermediate step during the build process, before the final emacs binary is dumped. The files that are being installed don't need any PaX settings, therefore pax-utils.eclass won't help there.
Comment 11 Jason Zaman gentoo-dev 2017-02-10 13:41:02 UTC
(In reply to Ulrich Müller from comment #10)
> (In reply to Jason Zaman from comment #9)
> > You should just use the pax-utils eclass which will set things properly
> > according to what the user has set in make.conf and fall back to other tools
> > to mark with if the best arnt available. dont just use only one of them.
> 
> Sorry, but that won't work. PaX marking is done purely as an intermediate
> step during the build process, before the final emacs binary is dumped. The
> files that are being installed don't need any PaX settings, therefore
> pax-utils.eclass won't help there.

Oh, in that case use edit the makefile to use /usr/sbin/paxmark.sh (from sys-apps/elfix) instead. Its designed for that case and it implements all the same fallback logic as the eclass.
Comment 12 Agostino Sarubbo gentoo-dev 2017-02-10 14:20:28 UTC
We clarified that this is an unsupported configuration. So this can be closed as invalid.
Comment 13 Ulrich Müller gentoo-dev 2017-06-26 11:48:29 UTC
*** Bug 622146 has been marked as a duplicate of this bug. ***