Forums

Skip to content

Advanced search
  • Quick links
    • Unanswered topics
    • Active topics
    • Search
  • FAQ
  • Login
  • Register
  • Board index Assistance Unsupported Software
  • Search

2.6.24-zen4-pax "speed meets security Redux"

This forum covers all Gentoo-related software not officially supported by Gentoo. Ebuilds/software posted here might harm the health and stability of your system(s), and are not supported by Gentoo developers. Bugs/errors caused by ebuilds from overlays.gentoo.org are covered by this forum, too.
Post Reply
Advanced search
17 posts • Page 1 of 1
Author
Message
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

2.6.24-zen4-pax "speed meets security Redux"

  • Quote

Post by kernelOfTruth » Sun Mar 02, 2008 10:21 am

Hi ladies & gentlement,

(this is split out of the zen-sources thread):
kernelOfTruth wrote:anyone interested in an pax-patch for 2.6.24-zen4 ?

update:

sorry, no patch :roll: , the patch I created was 140 MB big :lol:


so here's the zen-sources tarball with grsecurity's pax-patch (http://www.grsecurity.com/test/pax-linu ... st31.patch) [February 29 2008 12:15:15],
zen-sources' state should be from commit: 04d280d4e981b4a2b3a14eae36aa7a0796566163

kudos to spender for his great work for making linux more secure, waninkoko, rmh3093, and all the others involved in zen-sources

"speed meets security Redux"



:arrow: Link to the tarball: linux-2.6.24-zen4_pax.tbz2


Instruction:

1.) compile in softmode-support, then
if you need to install apps, scan something with xsane ,etc etc which doesn't work with pax:

temporarily disable pax by echoing "1" to
/proc/sys/kernel/pax/softmode

Code: Select all

echo "1" > /proc/sys/kernel/pax/softmode
output of paxtest with pax enabled:
Executable anonymous mapping : Killed
Executable bss : Killed
Executable data : Killed
Executable heap : Killed
Executable stack : Killed
Executable anonymous mapping (mprotect) : Killed
Executable bss (mprotect) : Killed
Executable data (mprotect) : Killed
Executable heap (mprotect) : Killed
Executable stack (mprotect) : Killed
Executable shared library bss (mprotect) : Killed
Executable shared library data (mprotect): Killed
Writable text segments : Killed
Anonymous mapping randomisation test : 33 bits (guessed)
Heap randomisation test (ET_EXEC) : 40 bits (guessed)
Heap randomisation test (ET_DYN) : 40 bits (guessed)
Main executable randomisation (ET_EXEC) : 33 bits (guessed)
Main executable randomisation (ET_DYN) : 33 bits (guessed)
Shared library randomisation test : 33 bits (guessed)
Stack randomisation test (SEGMEXEC) : No randomisation
Stack randomisation test (PAGEEXEC) : 40 bits (guessed)
Return to function (strcpy) : Killed
Return to function (memcpy) : Killed
Return to function (strcpy, RANDEXEC) : Killed
Return to function (memcpy, RANDEXEC) : Killed
Executable shared library bss : Killed
Executable shared library data : Killed
output of paxtest with softmode enabled:
Executable anonymous mapping : Killed
Executable bss : Killed
Executable data : Killed
Executable heap : Killed
Executable stack : Killed
Executable anonymous mapping (mprotect) : Vulnerable
Executable bss (mprotect) : Vulnerable
Executable data (mprotect) : Vulnerable
Executable heap (mprotect) : Vulnerable
Executable stack (mprotect) : Vulnerable
Executable shared library bss (mprotect) : Vulnerable
Executable shared library data (mprotect): Vulnerable
Writable text segments : Vulnerable
Anonymous mapping randomisation test : 29 bits (guessed)
Heap randomisation test (ET_EXEC) : No randomisation
Heap randomisation test (ET_DYN) : No randomisation
Main executable randomisation (ET_EXEC) : 33 bits (guessed)
Main executable randomisation (ET_DYN) : 29 bits (guessed)
Shared library randomisation test : 29 bits (guessed)
Stack randomisation test (SEGMEXEC) : 40 bits (guessed)
Stack randomisation test (PAGEEXEC) : 40 bits (guessed)
Return to function (strcpy) : Killed
Return to function (memcpy) : Killed
Return to function (strcpy, RANDEXEC) : Killed
Return to function (memcpy, RANDEXEC) : Killed
Executable shared library bss : Killed
Executable shared library data : Killed
2.) if you have problems with nvidia-drivers try the following:

http://forums.gentoo.org/viewtopic-t-57 ... ight-.html

3.) to find out, which files were altered by me:

go to the directory where the tarball got extracted then:

Code: Select all

find . | grep .rej


have fun :)

Disclaimer:

I take no responsibility if it kills your data, your kittens, pulls away your girlfriend or anything else
I've tested it on amd64 system with gcc 4.2.3 hardened gcc and glibc 2.7 & currently am using it for all my sensitive data, so it should be fine
no guarantee it will work on x86 however [if it works on amd64 it however should at least boot on x86]
Last edited by kernelOfTruth on Sun Mar 02, 2008 10:29 am, edited 2 times in total.
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Sun Mar 02, 2008 10:22 am

example kernel-config for amd64
(P5W DH Deluxe, with some cflags, ldflags, etc optimizations)

http://phpfi.com/299908
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
lightseeker
n00b
n00b
Posts: 18
Joined: Sat Jun 23, 2007 11:12 pm
Location: Smederevo, Serbia

  • Quote

Post by lightseeker » Mon Mar 03, 2008 4:18 am

Hi!

I've managed to compile and install "Redux" :D, but I have problems starting X when using ati-drivers 8.02 (and yes, I've
disabled pax like you suggested).

Xorg.0.log says

Code: Select all

(II) Loading /usr/lib/xorg/modules//glesx.so
dlopen: /usr/lib/xorg/modules//glesx.so: cannot make segment writable for relocation: Permission denied
(EE) Failed to load /usr/lib/xorg/modules//glesx.so
Any hints ?

Many thanks in advance.
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Mon Mar 03, 2008 10:26 am

lightseeker wrote:Hi!

I've managed to compile and install "Redux" :D, but I have problems starting X when using ati-drivers 8.02 (and yes, I've
disabled pax like you suggested).

Xorg.0.log says

Code: Select all

(II) Loading /usr/lib/xorg/modules//glesx.so
dlopen: /usr/lib/xorg/modules//glesx.so: cannot make segment writable for relocation: Permission denied
(EE) Failed to load /usr/lib/xorg/modules//glesx.so
Any hints ?

Many thanks in advance.
nice :)

I actually never really got ati-drivers to work in the last years with pax

you need to

Code: Select all

emerge chpax paxctl
then you can play with those files producing problems:
paxctl --help
PaX control v0.5
Copyright 2004,2005,2006,2007 PaX Team <pageexec@freemail.hu>

usage: paxctl <options> <files>

options:
-p: disable PAGEEXEC -P: enable PAGEEXEC
-e: disable EMUTRMAP -E: enable EMUTRMAP
-m: disable MPROTECT -M: enable MPROTECT
-r: disable RANDMMAP -R: enable RANDMMAP
-x: disable RANDEXEC -X: enable RANDEXEC
-s: disable SEGMEXEC -S: enable SEGMEXEC

-v: view flags -z: restore default flags
-q: suppress error messages -Q: report flags in short format
-c: convert PT_GNU_STACK into PT_PAX_FLAGS (see manpage!)
-C: create PT_PAX_FLAGS (see manpage!)
e.g.

Code: Select all

paxctl -pEmrxs
or
chpax --help
chpax 0.7 .::. Manage PaX flags for binaries
Usage: chpax OPTIONS FILE1 FILE2 FILEN ...
-P enforce paging based non-executable pages
-p do not enforce paging based non-executable pages
-E emulate trampolines
-e do not emulate trampolines
-M restrict mprotect()
-m do not restrict mprotect()
-R randomize mmap() base [ELF only]
-r do not randomize mmap() base [ELF only]
-X randomize ET_EXEC base [ELF only]
-x do not randomize ET_EXEC base [ELF only]
-S enforce segmentation based non-executable pages
-s do not enforce segmentation based non-executable pages
-v view current flag mask
-z zero flag mask (next flags still apply)

The flags only have effect when running the patched Linux kernel.

Code: Select all

chpax -pEmrxs
you can try to disable all of them in the beginning, but often disabling mprotect (

Code: Select all

chpax -m
) or (

Code: Select all

paxctl -m
) should suffice

if you're not running hardened profile you might need to recompile your system with PIC-support

references:
http://www.gentoo.org/proj/en/hardened/
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
lightseeker
n00b
n00b
Posts: 18
Joined: Sat Jun 23, 2007 11:12 pm
Location: Smederevo, Serbia

  • Quote

Post by lightseeker » Tue Mar 04, 2008 1:55 pm

Hi!

Thanks for the reply kernelOfThruth.

I am running hardened, well, sort of. I'm not using hardened profile, but hardened toolchain (gcc 4.2.2 pie/ssp and stuff from Kevin Quinn's overlay) and ~x86.

Anyway, I've played with paxctl, but X still refuses to start. I've managed to disable all flags for Xorg, but I get the same error as before. As for /usr/lib/xorg/modules/glesx.so paxctl refuses to do anything, complaining that file does not have vaild ELF header an refuses to convert it or apply any changes to the binary.

Thanks anyway man :D , I've learned a lot of usefull new stuff about gentoo, and will try to "convert" my laptop later this week.

Cheers 8)
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Thu Mar 13, 2008 11:46 pm

update:

new kernel-release

2.6.24-zen4_pax-r2

http://d01.megashares.com/?d01=03ceee6
Filename
linux-2.6.24-zen4_pax-r2.tbz2
Filesize
199.83 MB
Description
2.6.24-zen4_pax-r2
(sorry, it's a little big, I found no time to make a nice little patch out of it, there are probably some unneeded additionally files from git but it should compile & work fine, updated to latest state of 2.6.24-zen4, as of 14th of March 2008)
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
obrut<-
Apprentice
Apprentice
User avatar
Posts: 183
Joined: Fri Apr 01, 2005 5:52 pm
Location: near hamburg, germany

  • Quote

Post by obrut<- » Tue Apr 01, 2008 4:47 pm

hi!
unfortunately your link is now invalid. can i get it elsewhere?
tia
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Tue Apr 01, 2008 7:00 pm

obrut<- wrote:hi!
unfortunately your link is now invalid. can i get it elsewhere?
tia
Hi,

here you go:

mirror1: hosting by 2shared.com (takes some time until download-link appears :roll: )

mirror2: directory of zen-sources_pax (thanks to MrGreen for hosting !)
Last edited by kernelOfTruth on Wed Apr 02, 2008 4:46 pm, edited 1 time in total.
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
obrut<-
Apprentice
Apprentice
User avatar
Posts: 183
Joined: Fri Apr 01, 2005 5:52 pm
Location: near hamburg, germany

  • Quote

Post by obrut<- » Tue Apr 01, 2008 11:36 pm

muchas gracias!
mirror1 works, mirror2 doesn't. it gives me
Forbidden
You don't have permission to access /zen-sources_pax/linux-2.6.24-zen4_pax-r2.tbz2 on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Wed Apr 02, 2008 12:13 am

obrut<- wrote:muchas gracias!
mirror1 works, mirror2 doesn't. it gives me
Forbidden
You don't have permission to access /zen-sources_pax/linux-2.6.24-zen4_pax-r2.tbz2 on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
fixed :)

thanks for reporting
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
lightseeker
n00b
n00b
Posts: 18
Joined: Sat Jun 23, 2007 11:12 pm
Location: Smederevo, Serbia

  • Quote

Post by lightseeker » Wed Apr 02, 2008 7:35 pm

Hi!
I'm still using your "older" release on my laptop and it works like a charm :D

But today I tried compilng this new hot stuff and it gave me this

Code: Select all

ERROR: "sqlzma_fin" [fs/squashfs/squashfs.ko] undefined!
ERROR: "sqlzma_un" [fs/squashfs/squashfs.ko] undefined!
ERROR: "sqlzma_init" [fs/squashfs/squashfs.ko] undefined!
Squashfs/lzma compiles ok on "pure" zen sources checkout (from last week or so)

Many thanks in advance man. :D
Top
obrut<-
Apprentice
Apprentice
User avatar
Posts: 183
Joined: Fri Apr 01, 2005 5:52 pm
Location: near hamburg, germany

  • Quote

Post by obrut<- » Wed Apr 02, 2008 8:06 pm

my laptop just won't boot. kernel displays nothing but command line, kernel and initrd size and address (?) and hangs. tomorrow i'll look into it hoping to find the error.
Top
lightseeker
n00b
n00b
Posts: 18
Joined: Sat Jun 23, 2007 11:12 pm
Location: Smederevo, Serbia

  • Quote

Post by lightseeker » Thu Apr 03, 2008 12:15 am

Ok, silly me. :D
I just saw that "redux" is based on 2.6.24-zen4 (squashfs/lzma was broken there too, right ? :wink: ). I have zen5, and squashfs works there. No biggie :P

@kernelOfTruth are you still using this pax patch: http://www.grsecurity.com/test/pax-linu ... st31.patch ?
I'd like to try to apply it myself.

Thanks.

@obrut<-: Good luck, man. Older version works fine for me.
Top
obrut<-
Apprentice
Apprentice
User avatar
Posts: 183
Joined: Fri Apr 01, 2005 5:52 pm
Location: near hamburg, germany

  • Quote

Post by obrut<- » Fri Apr 04, 2008 12:19 pm

i tried disabling some things i've never found in gentoo-sources (automatic optimisation for example), but i won't get a "kernel alive" after grub loaded the kernel. :( i hoped i could test pax without waiting for hardened 2.6.24. older kernels wouldn't work because i need xts cipher mode for my encrypted harddisk. want to see if my 4.2.3 gcc with hardened patches does what it should. ;)

@ lightseeker:
thanks
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Fri Apr 04, 2008 12:53 pm

@kernelOfTruth are you still using this pax patch: http://www.grsecurity.com/test/pax-linu ... st31.patch ?
I'd like to try to apply it myself.
@lightseeker:
yeah, I'm still using that patch :)
just go ahead :P

beware: googleearth and some other 32bit- opengl apps don't work under amd64 (yet <-- I don't have the time to investigate what pax-flags need to be relaxed)
i tried disabling some things i've never found in gentoo-sources (automatic optimisation for example), but i won't get a "kernel alive" after grub loaded the kernel. :( i hoped i could test pax without waiting for hardened 2.6.24. older kernels wouldn't work because i need xts cipher mode for my encrypted harddisk. want to see if my 4.2.3 gcc with hardened patches does what it should. ;)
sorry, no idea what might prevent your system from booting, like lightseeker suggest, please try the earlier release

good luck :)
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
kernelOfTruth
Watchman
Watchman
User avatar
Posts: 6111
Joined: Tue Dec 20, 2005 10:34 pm
Location: Vienna, Austria; Germany; hello world :)
Contact:
Contact kernelOfTruth
Website

  • Quote

Post by kernelOfTruth » Sun Apr 06, 2008 10:06 pm

here a set of "testing" flags for zen-sources (copy & paste !):

Code: Select all

#
# Custom flags
#
CONFIG_CUSTOM_CFLAGS="-O2 -ftree-pre -ftree-ch -fomit-frame-pointer -freorder-blocks -freorder-blocks-and-partition -fearly-inlining -ffunction-cse -fgcse-sm -fgcse-las -fgcse-after-reload -fno-ident -fstack-protector -march=native -fforce-addr -maccumulate-outgoing-args -msse3 -minline-all-stringops -mno-align-stringops -combine -s -pipe --param max-gcse-passes=8 -fmodulo-sched -freschedule-modulo-scheduled-loops -ftree-loop-im -ftree-loop-ivcanon -fivopts -funroll-loops -fsplit-ivs-in-unroller -fvariable-expansion-in-unroller -fpeel-loops -funswitch-loops -fprefetch-loop-arrays -fpie -D_FORTIFY_SOURCE=2"
CONFIG_CUSTOM_LDFLAGS="-Wl,-O1 -Wl,--enable-new-dtags -Wl,--sort-common -pie"
CONFIG_CUSTOM_AFLAGS=""
CONFIG_CUSTOM_MAKEFLAGS="-S"
adjust flags to your liking but leave -pie, -fstack-protector and FORTIFY_SOURCE=2 in it (== randomisation)

this way you'll always get the latest & greatest of zen-sources and still have (semi-)maximum protection (without pax or grsecurity ! :D ),
in this case even flash, googleearth, mono-apps & wine-apps, 32-bit 3D-apps work 8)

only requirement is a hardened gcc-compiler / toolchain
Executable anonymous mapping : Killed
Executable bss : Killed
Executable data : Killed
Executable heap : Killed
Executable stack : Killed
Executable anonymous mapping (mprotect) : Vulnerable
Executable bss (mprotect) : Vulnerable
Executable data (mprotect) : Vulnerable
Executable heap (mprotect) : Vulnerable
Executable stack (mprotect) : Vulnerable
Executable shared library bss (mprotect) : Vulnerable
Executable shared library data (mprotect): Vulnerable
Writable text segments : Vulnerable
Anonymous mapping randomisation test : 28 bits (guessed)
Heap randomisation test (ET_EXEC) : 28 bits (guessed)
Heap randomisation test (ET_DYN) : 28 bits (guessed)
Main executable randomisation (ET_EXEC) : 28 bits (guessed)
Main executable randomisation (ET_DYN) : 28 bits (guessed)
Shared library randomisation test : 28 bits (guessed)
Stack randomisation test (SEGMEXEC) : 28 bits (guessed)
Stack randomisation test (PAGEEXEC) : 28 bits (guessed)
Return to function (strcpy) : Killed
Return to function (memcpy) : Killed
Return to function (strcpy, RANDEXEC) : Killed
Return to function (memcpy, RANDEXEC) : Killed
Executable shared library bss : Killed
Executable shared library data : Killed
https://github.com/kernelOfTruth/ZFS-fo ... scCD-4.9.0
https://github.com/kernelOfTruth/pulsea ... zer-ladspa

Hardcore Gentoo Linux user since 2004 :D
Top
lightseeker
n00b
n00b
Posts: 18
Joined: Sat Jun 23, 2007 11:12 pm
Location: Smederevo, Serbia

  • Quote

Post by lightseeker » Sun Apr 13, 2008 2:12 pm

Hi!

@kernelOfTruth: I don't quite understand :D . Wouldn't that just "harden" the kernel itself, not the userland and stuff ?

BTW, I've managed to apply pax patch to zen5 (man that was hard), so if anyone's interested I can upload it somewhere. 8)

:bye:
--- "Sungod, bless me with your rays..." ---
Top
Post Reply

17 posts • Page 1 of 1

Return to “Unsupported Software”

Jump to
  • Assistance
  • ↳   News & Announcements
  • ↳   Frequently Asked Questions
  • ↳   Installing Gentoo
  • ↳   Multimedia
  • ↳   Desktop Environments
  • ↳   Networking & Security
  • ↳   Kernel & Hardware
  • ↳   Portage & Programming
  • ↳   Gamers & Players
  • ↳   Other Things Gentoo
  • ↳   Unsupported Software
  • Discussion & Documentation
  • ↳   Documentation, Tips & Tricks
  • ↳   Gentoo Chat
  • ↳   Gentoo Forums Feedback
  • ↳   Duplicate Threads
  • International Gentoo Users
  • ↳   中文 (Chinese)
  • ↳   Dutch
  • ↳   Finnish
  • ↳   French
  • ↳   Deutsches Forum (German)
  • ↳   Diskussionsforum
  • ↳   Deutsche Dokumentation
  • ↳   Greek
  • ↳   Forum italiano (Italian)
  • ↳   Forum di discussione italiano
  • ↳   Risorse italiane (documentazione e tools)
  • ↳   Polskie forum (Polish)
  • ↳   Instalacja i sprzęt
  • ↳   Polish OTW
  • ↳   Portuguese
  • ↳   Documentação, Ferramentas e Dicas
  • ↳   Russian
  • ↳   Scandinavian
  • ↳   Spanish
  • ↳   Other Languages
  • Architectures & Platforms
  • ↳   Gentoo on ARM
  • ↳   Gentoo on PPC
  • ↳   Gentoo on Sparc
  • ↳   Gentoo on Alternative Architectures
  • ↳   Gentoo on AMD64
  • ↳   Gentoo for Mac OS X (Portage for Mac OS X)
  • Board index
  • All times are UTC
  • Delete cookies

© 2001–2026 Gentoo Foundation, Inc.

Powered by phpBB® Forum Software © phpBB Limited

Privacy Policy

 

 

magic