Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 49014 - hardened-dev-sources-2.6.5-r3 hangs on boot
Summary: hardened-dev-sources-2.6.5-r3 hangs on boot
Status: RESOLVED INVALID
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: Hardened (show other bugs)
Hardware: All All
: High normal (vote)
Assignee: Joshua Brindle (RETIRED)
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-04-26 01:34 UTC by Jetchko Jekov
Modified: 2004-11-16 14:47 UTC (History)
1 user (show)

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


Attachments
kernel config file (config-2.6.5-hardened-r3,21.57 KB, text/plain)
2004-04-26 01:36 UTC, Jetchko Jekov
Details
kernel config for vanilla-2.6.5 + pax-linux-2.6.5-200404281425 (config-vanilla-2.6.5+pax,21.25 KB, text/plain)
2004-04-30 06:39 UTC, Jetchko Jekov
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Jetchko Jekov 2004-04-26 01:34:25 UTC
h-d-s-2.6.5-r3 hangs on "Freeing unused memory"
compiled with selinux+pax only
if compiled without pax (selinux only) it boots


Portage 2.0.50-r6 (x86, gcc-3.3.3, glibc-2.3.3_pre20040207-r0, 2.6.3-hardened)
=================================================================
System uname: 2.6.3-hardened i686 Pentium II (Deschutes)
Gentoo Base System version 1.4.9
distcc 2.12.1 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
Autoconf: sys-devel/autoconf-2.58-r1
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="x86"
AUTOCLEAN="yes"
CFLAGS="-march=pentium2 -O3 -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/kde/2/share/config /usr/kde/3/share/config /usr/share/config /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-march=pentium2 -O3 -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs ccache loadpolicy sandbox sfperms strict"
GENTOO_MIRRORS="http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://gentoo.internet-bg.net/gentoo-portage"
USE="acl berkdb crypt imap innodb maildir mbox mcal memlimit ncurses nls nptl pam pic pie python readline sasl selinux ssl tcpd x86 zlib"


gcc -v
Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: /var/tmp/portage/gcc-3.3.3-r2/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++ --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-clocale=generic --enable-__cxa_atexit --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --disable-nls --disable-multilib
Thread model: posix
gcc version 3.3.3 20040217 (Gentoo Hardened Linux 3.3.3-r2, ssp-3.3-7, pie-8.5.3)
Comment 1 Jetchko Jekov 2004-04-26 01:36:16 UTC
Created attachment 30066 [details]
kernel config file
Comment 2 Paper 2004-04-29 15:34:38 UTC
Happened here too. If I compile the kernel with grsecurity but *not* PaX, it runs fine. If I add also PaX it segfault when starting init. I see that init segfault because grsec log the attempt to core dump (RLIMIT_CORE=0 resource overstep).

Portage 2.0.50-r6 (default-x86-1.4, gcc-3.3.3, glibc-2.3.3_pre20040420-r0, 2.6.5-hardened-r3)
=================================================================
System uname: 2.6.5-hardened-r3 i686 Mobile Intel(R) Pentium(R) 4 - M CPU 2.20GHz
Gentoo Base System version 1.4.10
distcc 2.13 i686-pc-linux-gnu (protocols 1 and 2) (default port 3632) [disabled]
ccache version 2.3 [enabled]
Autoconf: sys-devel/autoconf-2.59-r3
Automake: sys-devel/automake-1.8.3
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-mcpu=pentium4 -march=pentium4 -O3 -pipe -mmmx -msse -msse2 -mfpmath=sse,387 -fstack-protector -ftracer -momit-leaf-frame-pointer -fprefetch-loop-arrays -frerun-cse-after-loop -frerun-loop-opt -funroll-loops -fforce-addr -falign-functions=4"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /etc/tomcat /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config /usr/kde/3.2/share/config /usr/kde/3/share/config /usr/lib/mozilla/defaults/pref /usr/share/config /usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/ /usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/ /usr/share/texmf/xdvi/ /var/qmail/alias /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/terminfo /etc/env.d"
CXXFLAGS="-mcpu=pentium4 -march=pentium4 -O3 -pipe -mmmx -msse -msse2 -mfpmath=sse,387 -fstack-protector -ftracer -momit-leaf-frame-pointer -fprefetch-loop-arrays -frerun-cse-after-loop -frerun-loop-opt -funroll-loops -fforce-addr -falign-functions=4"
DISTDIR="/home/backup/distfiles"
FEATURES="autoaddcvs ccache sandbox"
GENTOO_MIRRORS="http://ftp.snt.utwente.nl/pub/os/linux/gentoo http://linux.rz.ruhr-uni-bochum.de/download/gentoo-mirror/ http://gentoo.oregonstate.edu http://distro.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/home/backup/portage/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage /usr/local/portage-bmg-main /usr/local/portage-bmg-gnome-current"
SYNC="rsync://rsync.asia.gentoo.org/gentoo-portage"
USE="X X509 aalib acl acpi acpi4linux alsa apache2 apm arts avi berkdb bonobo breakme cdr crypt cups curl dga directfb divx dvd encode esd ethereal evo f77 faad fam fbcon firebird flac foomaticdb gcj gd gdbm ggi gif gimpprint ginac gnome gphoto2 gpm gstreamer gtk gtk2 gtkhtml hardened imap imlib innodb jack jack-caps jack-tmpfs java joystick jpeg junit lcd ldap libg++ libgda libwww lirc mad maildir mbox mikmod mmx motif mozilla moznocompose moznoirc moznomail mpeg mysql ncurses nls nntp nptl nvidia odbc oggvorbis opengl oss pam pax pcmcia pda pdflib perl pic pie plotutils png pnp postgres ppds prelude python qhull qt qtmt quicktime readline samba scanner sdl skey slang slp snmp socks5 speex spell sse ssl svga tcltk tcpd tetex tiff transcode truetype trusted usb wmf x86 xine xinerama xml xml2 xosd xv xvid zlib"


gcc -v

Reading specs from /usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/specs
Configured with: /home/backup/portage/tmp/portage/gcc-3.3.3-r3/work/gcc-3.3.3/configure --prefix=/usr --bindir=/usr/i686-pc-linux-gnu/gcc-bin/3.3 --includedir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include --datadir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3 --mandir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/man --infodir=/usr/share/gcc-data/i686-pc-linux-gnu/3.3/info --enable-shared --host=i686-pc-linux-gnu --target=i686-pc-linux-gnu --with-system-zlib --enable-languages=c,c++,java --enable-threads=posix --enable-long-long --disable-checking --enable-cstdio=stdio --enable-version-specific-runtime-libs --with-gxx-include-dir=/usr/lib/gcc-lib/i686-pc-linux-gnu/3.3.3/include/g++-v3 --with-local-prefix=/usr/local --enable-shared --enable-nls --without-included-gettext --x-includes=/usr/X11R6/include --x-libraries=/usr/X11R6/lib --enable-interpreter --enable-java-awt=xlib --with-x --disable-multilib --disable-libunwind-exceptions --enable-__cxa_atexit --enable-clocale=generic
Thread model: posix
gcc version 3.3.3 20040412 (Gentoo Hardened Linux 3.3.3-r3, ssp-3.3-7, pie-8.5.3)
Comment 3 Joshua Brindle (RETIRED) gentoo-dev 2004-04-30 03:56:39 UTC
Ok, the PaX team requests that you try with only PaX enabled, no grsec or selinux and see if it happens still.
Comment 4 Joshua Brindle (RETIRED) gentoo-dev 2004-04-30 03:59:38 UTC
Correction, the PaX team requests that you try a vanilla 2.6.5 kernel with this patch http://pax.grsecurity.net/pax-linux-2.6.5-200404281425.patch applied (and only this patch) with the config that caused the problem.
Comment 5 Jetchko Jekov 2004-04-30 06:36:43 UTC
ok, tested vanilla 2.6.5 + pax-linux-2.6.5-200404281425.patch - same behavior:
kernel hangs at "Freeing unused kernel memory".
my config is attached below.
that behavior seems is CPU speciffic

CPU on that box is:
vendor_id       : GenuineIntel
cpu family      : 6
model           : 5
model name      : Pentium II (Deschutes)
stepping        : 2
cpu MHz         : 400.981
cache size      : 512 KB
fdiv_bug        : no
hlt_bug         : no
f00f_bug        : no
coma_bug        : no
fpu             : yes
fpu_exception   : yes
cpuid level     : 2
wp              : yes
flags           : fpu vme de pse tsc msr pae mce cx8 sep mtrr pge mca cmov pat pse36 mmx fxsr

I tested almost same kernel config in my vmware testbox (only differences are included SCSI Disk support & BusLogic low level SCSI driver for VMware emulated SCSI host controller) and it works.
CPU on host machine is Pentium4

I made try to izolate what is problematic option and disabled "Enforce non-executable pages":
on my Pentium II box kernel hangs again, but with some more messages after "Freeing unused ...":
init: must be superuser.
Kernel panic: Attempted to kill init!
Same kernel works on vmware box.
 
Comment 6 Jetchko Jekov 2004-04-30 06:39:50 UTC
Created attachment 30392 [details]
kernel config for vanilla-2.6.5 + pax-linux-2.6.5-200404281425
Comment 7 PaX Team 2004-05-01 03:31:34 UTC
could you try it without enabling selinux? also, could you determine which pax feature you have to enable to trigger the hang?
Comment 8 Jetchko Jekov 2004-05-03 02:48:41 UTC
tested without selinux enabled:
hangs again at "Freeing unused ..." with following config:
#
# Security options
#

#
# PaX
#
CONFIG_PAX=y

#
# PaX Control
#
CONFIG_PAX_SOFTMODE=y
# CONFIG_PAX_EI_PAX is not set
CONFIG_PAX_PT_PAX_FLAGS=y
CONFIG_PAX_NO_ACL_FLAGS=y
# CONFIG_PAX_HAVE_ACL_FLAGS is not set
# CONFIG_PAX_HOOK_ACL_FLAGS is not set

#
# Non-executable pages
#
CONFIG_PAX_NOEXEC=y
# CONFIG_PAX_PAGEEXEC is not set
CONFIG_PAX_SEGMEXEC=y
# CONFIG_PAX_EMUTRAMP is not set
# CONFIG_PAX_MPROTECT is not set

#
# Address Space Layout Randomization
#
# CONFIG_PAX_ASLR is not set
# CONFIG_SECURITY is not set

Comment 9 PaX Team 2004-05-03 12:55:14 UTC
can you try it while disabling SEGMEXEC as well?
Comment 10 Jetchko Jekov 2004-05-04 00:02:14 UTC
with disabled CONFIG_PAX_SEGMEXEC kernel boots
Comment 11 PaX Team 2004-05-04 05:41:15 UTC
in comment #5 you said that disabling non-exec pages would still kill init and now when you did the same it works? what's the difference between these two configs? also could you try to enable PAGEEXEC instead of SEGMEXEC (MPROTECT is optional) and see if anything changes? another thing to test is 2.4.26 and PaX with these configs? for now it seems to be a problem in PaX either on this P2 CPU or with 2.6, but i don't see any obvious place in the code that would cause this.
Comment 12 Jetchko Jekov 2004-05-04 05:53:05 UTC
no
in comment #5 config is as attached config but with CONFIG_PAX_NOEXEC disabled
Comment 13 Jetchko Jekov 2004-05-04 05:57:11 UTC
config with what kernel boots is that in comment #8 but with disabled SEGMEXEC
Comment 14 PaX Team 2004-05-04 06:22:20 UTC
i understand but those two are the same, NOEXEC enabled alone doesn't do anything if neither of PAGEEXEC/SEGMEXEC is enabled (which was your case in #10, right?).
Comment 15 Jetchko Jekov 2004-05-04 06:37:52 UTC
in comment #5  CONFIG_PAX_NOEXEC is disabled but CONFIG_PAX_ASLR and some options under ASLR are enabled
in comment #10 both CONFIG_PAX_ASLR  and CONFIG_PAX_NOEXEC are disabled
Comment 16 PaX Team 2004-05-04 06:55:40 UTC
ok, so we might have a problem with ASLR then. if you have time, could you disable those one by one and see when it begins to work (and keep NOEXEC disabled for now)?
Comment 17 Jetchko Jekov 2004-05-04 06:57:51 UTC
With that config kernel boots. I will try now with CONFIG_PAX_ASLR enabled

#
# Non-executable pages
#
CONFIG_PAX_NOEXEC=y
CONFIG_PAX_PAGEEXEC=y
# CONFIG_PAX_SEGMEXEC is not set
CONFIG_PAX_EMUTRAMP=y
CONFIG_PAX_MPROTECT=y
# CONFIG_PAX_NOELFRELOCS is not set

#
# Address Space Layout Randomization
#
# CONFIG_PAX_ASLR is not set
# CONFIG_SECURITY is not set
Comment 18 Jetchko Jekov 2004-05-04 08:21:44 UTC
ok, the problematic option under PAX_ASLR is PAX_RANDKSTACK.
with PAX_RANDKSTACK disabled kernel boots.
Comment 19 PaX Team 2004-05-04 08:31:55 UTC
ok, that's not so much of a surprise, depending on the stack usage of various drivers your kernel has the randomization may trigger overflows. i take it that everything else can be enabled and works fine, right? (in which case this bug can be closed)
Comment 20 Jetchko Jekov 2004-05-04 08:39:18 UTC
well compiled with SEGMEXEC doesn't work
Comment 21 PaX Team 2004-05-04 08:46:08 UTC
ok, so that was two bugs... now that RANDKSTACK is off, do you get the same hang/messages when init starts?
Comment 22 Jetchko Jekov 2004-05-04 08:48:07 UTC
:)
comment #8
Comment 23 PaX Team 2004-05-04 08:59:48 UTC
what about 2.4.26?
Comment 24 Jetchko Jekov 2004-05-04 09:09:57 UTC
i'm looking at 2.6 kernels.
That box is running 2.6.3-hardened selinux + pax enabled
kernel is compiled with SEGMEXEC enabled and works 
Comment 25 PaX Team 2004-05-04 09:12:38 UTC
i'd like to know if the problem is inherent to SEGMEXEC or SEGMEXEC on 2.6.
Comment 26 PaX Team 2004-05-04 10:00:32 UTC
xorg-x11-6.7.0/work/xc/lib/font/X-TrueType/module links to the X server and something else (FontDefaultFormat and the like), no -z defs for now.
Comment 27 PaX Team 2004-05-04 10:01:39 UTC
oops, wrong bug, ignore #26 ;-).
Comment 28 Jetchko Jekov 2004-05-04 10:20:49 UTC
tested vanilla-2.4.26+pax-linux-2.4.26-200404281425, but kernel hangs with "Kernel too old" and try to kill init, even without PAX enabled at all, maybe something with selinux patched init ...
Comment 29 PaX Team 2004-05-04 10:38:01 UTC
oh, silly me, you have the nptl use flag which creates a glibc that cannot run with pre-2.6 kernels. on the other hand i'm wondering if that could be the culprit as i don't have nptl here (and no problems either). a question: could you enable NOVSYSCALL for a test?
Comment 30 Jetchko Jekov 2004-05-04 23:37:45 UTC
oh yes, i enabled nptl for testing and forgot about that ;/
but it is enabled in my vmware test box also and i dont have problems with SEGMEXEC nor with RANDKSTACK - both are enabled and kernel works fine.

about NOVSYSCALL, i will enable it for testing.
you wanna know only that kernel boots or something more?
Comment 31 PaX Team 2004-05-05 01:34:22 UTC
well, as they say, if it boots it works ;-). seriously, from my point of view, if init and others run then as far as PaX is concerned it should be ok, other issues are specific to such apps not PaX directly. as for why all this works under vmware, no idea, for me it always worked both ways (without nptl).
Comment 32 Jetchko Jekov 2004-05-05 01:57:43 UTC
ok then, vanilla + pax + selinux boots without problems
NOVSYSCALL enabled, PAGEEXEC enabled, RANDKSTACK disabled.
now will try hardened-2.6.5 with same config
Comment 33 Jetchko Jekov 2004-05-05 02:45:57 UTC
hardened-dev-sources-2.6.5-r3 works too with that kernel config
Comment 34 PaX Team 2004-05-05 02:49:56 UTC
what about SEGMEXEC (and with NOVSYSCALL)?
Comment 35 Jetchko Jekov 2004-05-05 10:38:45 UTC
yes, it boots SEGMEXEC and NOVSYSCALL
Comment 36 PaX Team 2004-05-05 11:45:54 UTC
after having looked at the glibc sources i've got another question: have you by any chance enabled prelink on your system? if so, could you send me your ld-linux.so and libc.so to pageexec at freemail.hu please? what i suspect could happen is that prelink 'remembers' the syscall stub address from the vsyscall page - but at a time when SEGMEXEC wasn't active, so later when you try to run these apps under SEGMEXEC glibc would end up calling syscalls at an invalid address (invalid under SEGMEXEC, that is). alternatively, if you don't mind risking to blow up your system for good, you could prelink your system while SEGMEXEC is active then reboot with a kernel that has NOVSYSCALL disabled and it should work (but then a non-PaX kernel or one with only PAGEEXEC won't work).
Comment 37 PaX Team 2004-05-05 12:07:18 UTC
ok, further looking at the glibc sources makes me think that prelink is irrelevant in fact, ld.so will use the entry point field of the fake vsyscall library as the kernel provided syscall address, overriding what the kernel told via AT_SYSINFO... that's complete crap IMHO. the code in question is in glibc/elf/rtld.c:dl_main():

  if (GL(dl_sysinfo_dso) != NULL)
    {
      /* We have a prelinked DSO preloaded by the system.  */
      GL(dl_sysinfo) = GL(dl_sysinfo_dso)->e_entry;

i think this should look something like:
  if (GL(dl_sysinfo_dso) != NULL)
    {
      if (!GL(dl_sysinfo))
        /* We have a prelinked DSO preloaded by the system.  */
        GL(dl_sysinfo) = GL(dl_sysinfo_dso)->e_entry;
Comment 38 PaX Team 2004-05-05 14:31:10 UTC
ok, the suggested patch won't work as it is, the if() should be more like:

if (GL(dl_sysinfo) == DL_SYSINFO_DEFAULT)

but best is to ask the glibc guys and have them fix it properly ;-).
Comment 39 Joshua Brindle (RETIRED) gentoo-dev 2004-11-16 14:47:51 UTC
old bug, shouldn't be an issue anymore