|
Helping ordinary people create extraordinary websites! |
Hardening your Kernel with OpenWallBy Tony Lawrence2005-05-12
Hardening your Kernel with OpenWall The Openwall Project provides security related kernel patches for Linux and BSD kernels. I read about this in Hardening Linux by James Turnbull. The patch that most interested me was to prevent executable code from running in the stack. That won't prevent all buffer overflow attacks, but it can stop some of them. I really don't understand why this isn't just the default nowadays - I know it can break some programs and debuggers, but it seems smart to me. I installed this on a RedHat ES system. That system was running a 2.4.21 kernel, and had never installed kernel source, so the first step was to go get a newer kernel. I cd'd to /usr/src and did a cd /usr/srcThis patched the 2.4.29 kernel with the Openwall enhancements. I then copied the existing RedHat kernel config file so that I wouldn't have to answer a zillion questions (most of which I probably wouldn't have half a clue how to answer). cd /usr/src/linuxThis did leave me with a few questions to answer for things new in the 29 kernel. I took the defaults until it got to the Openwall stuff. I then answered "y" for hardening the stack, but not for GCC trampolines because that's apparently for older 2.0 kernels. I also said "n" to the "Destroy shared memory segments" because of warnings in the FAQ that it can break some apps and the advice of the "Hardening Linux" book. I probably don't have anything here that would break, but I left it "n". This ended up with these settings: CONFIG_HARDEN_STACK=yI then ran the typical "make dep" etc. and after a long, long wait everything completed and I ran "make install". That broke, complaining grubby fatal error: unable to find a suitable templateGrubby? I had never heard of it, but "man" showed me that it is used to update /etc/lilo.conf or /etc/grub.conf. The man page mentioned templates, but didn't explain enough to tell me what its problem might be. However, looking in /boot, I could see that everything I needed had been installed there, so I went ahead and edited /etc/grub.conf by hand. Unfortunately, I fat fingered it and ended up with this: # NOTICE: You have a /boot partition. This means thatDo you see the mistake? It should have looked like this: # NOTICE: You have a /boot partition. This means thatThat gave me a lovely "file not found" when I attempted to boot. Not quite realizing what I had done, I then tried to boot the second kernel, and of course that failed with the same error. Looking more closely, I spotted my problem and used the "edit" capability of grub to point it at the right kernel. That got me back up again. Openwall includes the source code for a program to test the stack changes, so I compiled that and tried it out: cd /usr/src/linux-2.4.29-ow1/optionalI still haven't found out what template is needed for grubby, but I did find a patch for it: https://bugzilla.redhat.com/bugzilla/show_bug.cgi?id=83512 Tutorial Pages: » Hardening your Kernel with OpenWall © Copyright 2005 A.P. Lawrence
|
|