Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 331183 - sys-libs/glibc-2.11.2 kills programs trying to run with SEGMEXEC disabled
Summary: sys-libs/glibc-2.11.2 kills programs trying to run with SEGMEXEC disabled
Status: RESOLVED OBSOLETE
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All Linux
: High normal
Assignee: The Gentoo Linux Hardened Team
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-08-04 11:13 UTC by Hugo Mildenberger
Modified: 2017-09-06 23:12 UTC (History)
1 user (show)

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


Attachments
/proc/config.gz unzipped, from linux-2.6.34-hardened-r1 (config,64.33 KB, text/plain)
2010-08-04 11:29 UTC, Hugo Mildenberger
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Hugo Mildenberger 2010-08-04 11:13:03 UTC
The system exhibiting the problem I'm going to describe below has an old Pention IV chip, so it can't make use the nx bit for performance reasons. Hence it had been configured with CONFIG_PAX_SEGMEXEC=y and PAGEEXEC disabled. 

Now, while looking for the reason why gdb-7.1 does not calculate breakpoint addresses correctly (I remember it once worked with 6.8 on x86 at least), I tried to selectively disable paxflags. When I disabled the SEGMEXEC feature via "pax -zs", the program didn't run at all. Nothing but one line was printed: "Killed", even though core dumps are both enabled and known to work reliably. Generally, this only happens when a program is terminated via signal 9. 

$ gdb ./test1
  GNU gdb (Gentoo 7.1 p1) 7.1
  [...]
  Reading symbols from /home/hm/test1...done.
  (gdb) run
  Starting program: /home/hm/test1 
  During startup program terminated with signal SIGKILL, Killed.
  (gdb)q

Here is a script for those who may want to perform a quick check if this maybe a local problem only:

  echo "int main(){return 0;}" | gcc -x c - -o test1 \
   && echo "program test1 created" || echo "compile failed: error $?"
  echo "running ldd ./test1:" && ldd ./test1
  echo -n "standard pax flags of test1 are: " \
   && paxctl -vQ test1 2>&1 | grep test1 
  echo -n "running ./test1 with standard pax flags: " \
   && ./test1 && echo "ok" || echo "error $?"
  echo -n "now disabling PaX SEGMEXEC: " \
   && paxctl -s test1 && paxctl -vQ test1 2>&1 | grep test1 
  echo -n "running ./test1: " && ./test1  && echo "ok" || echo "error $?"
  echo -n "again running ldd  on ./test1: " \
   && ldd ./test1 && echo "ok" || echo "error $?"
  echo  "whereas running '/lib/ld-linux.so.2 --list ./test1' always works:" \
   && /lib/ld-linux.so.2 --list ./test1

This script produces the following output:

$ sh reproduce.sh 
  program test1 created
  running ldd ./test1:
        linux-gate.so.1 =>  (0x5173d000)
        libc.so.6 => /lib/libc.so.6 (0x515d6000)
        /lib/ld-linux.so.2 (0x5173e000)
  standard pax flags of test1 are: - PaX flags: -------x-e-- [test1]
  running ./test1 with standard pax flags: ok
  now disabling PaX SEGMEXEC: - PaX flags: ---s---x-e-- [test1]
  running ./test1: reproduce.sh: line 6: 27433 Killed                  ./test1
  error 137
  again running ldd  on ./test1: /usr/bin/ldd: line 126: 27438 Killed
  LD_TRACE_LOADED_OBJECTS=1 LD_WARN= LD_BIND_NOW=
  LD_LIBRARY_VERSION=$verify_out LD_VERBOSE= "$@"
  error 1
  whereas running '/lib/ld-linux.so.2 --list ./test1' always works:
          linux-gate.so.1 =>  (0x515d6000)
          libc.so.6 => /lib/libc.so.6 (0x5146c000)
          /lib/ld-linux.so.2 (0x515d7000)


As ldd and ld-linux.so are part of glibc, I'm attributing this problem to sys-libs/glibc for now. Feel free to change the topic. Currently it does not look like as if it would depend on several hardened/grsec kernel versions I tested, and it also does not depend on two tested binutils versions (2.20, 2.20.1). Finally, it may be not a bug at all. However, as I understand PaX, it should always be possible to disable features selectively. Perhaps this is simply an inconsistent use case. With PAGEEXEC not configured and SEGMEXEC dynamically disabled, no means remain which could enforce MPROTECT.
Comment 1 Hugo Mildenberger 2010-08-04 11:29:25 UTC
Created attachment 241395 [details]
/proc/config.gz unzipped, from linux-2.6.34-hardened-r1
Comment 2 PaX Team 2012-11-02 17:56:38 UTC
(In reply to comment #0)
> Finally, it may be not a bug at all. However, as I understand PaX,
> it should always be possible to disable features selectively. Perhaps this
> is simply an inconsistent use case. With PAGEEXEC not configured and
> SEGMEXEC dynamically disabled, no means remain which could enforce MPROTECT.

this is exactly the case, you ended up with an invalid combination of PaX flags, hence the sigkill. disable mprotect in addition to segmexec and you should be fine. also i wonder why nobody picked up this bug for so long, i've just run across it completely by accident...
Comment 3 Andreas K. Hüttel archtester gentoo-dev 2017-09-03 17:47:39 UTC
So can there anything be done here?
Comment 4 Magnus Granberg gentoo-dev 2017-09-06 23:12:52 UTC
Hardened-sources is no longer supported so ask upstream.