📜 ⬆️ ⬇️

Hardened Gentoo: Installation

The installation of Hardened Gentoo (more precisely, the upgrade of the current Gentoo system in Hardened) looks like this:

  1. switch to hardened toolchain and rebuild the whole system with it so that all binaries use PIE and SSP (after that the system becomes protected by SSP)
  2. install hardened-sources (they contain PaX + GrSecurity + SeLinux + additional patches from Gentoo) and compile them with support for PaX, GrSecurity and GrSecurity / RBAC
  3. we are overloaded with the new kernel (after that, the system is also protected by PaX + PIE and GrSecurity)
  4. for some time we set up and debug access restrictions (after which the system is also protected by GrSecurity / RBAC)

Expected problems:

Here we go… :)

Too strong optimization (-O3) together with hardened toolchain can lead to different glitches and compilation failures, so you need to replace -O3 with -O2 in /etc/make.conf and remove all other -f * optimizer flags.

Go to hardened profile. (Theoretically, instead, one could simply add to the USE flags: “hardened pie ssp”.)
ln -snf ../usr/portage/profiles/hardened/x86/2.6/ /etc/make.profile 

After switching the profile to hardened / x86 / 2.6 /, several USE flags I needed turned off, which are automatically enabled in regular profiles - I added them to make.conf (you may have other flags, just remember to track this point):
 avi encode gtk2 jpeg mpeg oss quicktime spell truetype xv bitmap-fonts truetype-fonts type1-fonts 

Compiling hardened-toolchain and rebuilding it for all other packages:
 emerge binutils gcc glibc emerge -e world dispatch-conf 

Next, you need to put some more packages:
 emerge paxtest paxctl gradm 

paxtest could have been put before, before switching to hardened toolchain. This utility tries to do various dangerous operations (such as stack overflow with code execution), which are usually performed by exploits. If the system is protected, then all its attempts will be stopped, as it will inform. In general, you can drive it before installing the hardened toolchain, after as well after rebooting with the kernel where PaX is enabled, for fun. :)
')
paxtest as its dependency will also install the prog chpax - this is the old way to manage PaX, instead of which it is better to use paxctl. But some programs distributed without source code are compiled so that paxctl cannot work with them, and you have to use chpax.

Well, gradm is needed to configure RBAC in GrSecurity - the very same rights restrictions for processes and users.

As for the kernel settings. To begin with, I configured everything as described in the Gentoo and GrSecurity dock - not all protections are included, but most software will work with such settings. In the process of analyzing the settings, several theoretical assumptions arose:

Start. To be continued ...

Source: https://habr.com/ru/post/13095/


All Articles