All Projects → hardenedlinux → grsecurity-reproducible-build

hardenedlinux / grsecurity-reproducible-build

Licence: LGPL-3.0 license
Some scripts to create a reproducible build for grsecurity

Programming Languages

shell
77523 projects
c
50402 projects - #5 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to grsecurity-reproducible-build

linux-grsec
Arch Linux package for the Linux Kernel and modules with grsecurity/PaX patches.
Stars: ✭ 19 (-32.14%)
Mutual labels:  linux-kernel, pax, grsecurity
Linux Baytrail Flexx10
Install GNU/Linux on NextBook Flexx 10.1
Stars: ✭ 73 (+160.71%)
Mutual labels:  debian, linux-kernel
Pi64
A 64-bit OS for the Raspberry Pi 3
Stars: ✭ 720 (+2471.43%)
Mutual labels:  debian, linux-kernel
Linux Kernel Utilities
👷 Utilities to compile and / or update linux kernels for Debian and derivatives (e.g. Ubuntu, LinuxMint, etc.)
Stars: ✭ 166 (+492.86%)
Mutual labels:  debian, linux-kernel
archlinux-repro
Tools to reproduce arch linux packages
Stars: ✭ 103 (+267.86%)
Mutual labels:  reproducible-builds
host-flash
Updates the Linux hosts file to block access to reported bad (malicious) hosts, ad server hosts and custom set hosts. Bad hosts list freshly compiled each run from the lists released by hosts-file.net and mvps.org. Also features custom blocklist, whitelist, undo and restore options. This hosts file update program is interactive.
Stars: ✭ 14 (-50%)
Mutual labels:  debian
The-Debian-Gotham-Needs
The sanest page for downloading a Debian ISO
Stars: ✭ 36 (+28.57%)
Mutual labels:  debian
linux
Adding support for the Rust language to the Linux kernel.
Stars: ✭ 3,070 (+10864.29%)
Mutual labels:  linux-kernel
ansible-tinc
Role to install tinc in a star/ring topology (w/ leaf/spine) (based on your variables)
Stars: ✭ 15 (-46.43%)
Mutual labels:  debian
Nginx-builder
A tool to build deb or rpm package of required Nginx version from the source code, with the ability to connect third-party modules. Nginx parameters are set in the yaml configuration file.
Stars: ✭ 143 (+410.71%)
Mutual labels:  debian
edi-raspbian
edi configuration for emulated raspbian and raspbian cross compilation.
Stars: ✭ 16 (-42.86%)
Mutual labels:  debian
dpdk engineer manual
【冲破内核瓶颈,让I/O性能飙升】DPDK工程师手册,官方文档,最新视频,开源项目,实战案例,论文,大厂内部ppt,知名工程师一览表
Stars: ✭ 535 (+1810.71%)
Mutual labels:  linux-kernel
Linux-Kernel-notes
🌟 Notes and codes for Linux Kernel (SJTU-CS353)
Stars: ✭ 21 (-25%)
Mutual labels:  linux-kernel
MassVulScan
Bash script which quickly identifies open network ports and any associated vulnerabilities / Script Bash qui permet d'identifier rapidement les ports réseaux ouverts et les éventuelles vulnérabilités associées.
Stars: ✭ 56 (+100%)
Mutual labels:  debian
vagrant-templates
Vagrantfiles for self-contained development/test environments.
Stars: ✭ 28 (+0%)
Mutual labels:  debian
ssa
Web panel for small Debian and Ubuntu servers.
Stars: ✭ 16 (-42.86%)
Mutual labels:  debian
8821au
Linux Driver for USB WiFi Adapters that are based on the RTL8811AU and RTL8821AU Chipsets
Stars: ✭ 67 (+139.29%)
Mutual labels:  debian
yosild
Yosild is a single shell script that builds a full, minimal Linux distribution based on BusyBox.
Stars: ✭ 97 (+246.43%)
Mutual labels:  debian
apt-update-indicator
Apt Update Indicator
Stars: ✭ 38 (+35.71%)
Mutual labels:  debian
Aton
Open web computer laboratory administrator
Stars: ✭ 15 (-46.43%)
Mutual labels:  debian

Maintainer: Icenowy Zheng [email protected]

Thanks to:

  • PaX/Grsecurity
  • Mempo project
  • Debian GNU/Linux Community
  • Shawn C[a.k.a "Citypw"]
  • Linux From Scratch

Copyright (c) TYA infotech ltd http://tya.company/

License

This project is released under GPLv3.

Reproducible builds for PaX/Grsecurity

These scripts are intended to do reproducible builds for Linux kernel with Grsecurity patch set.

Dependencies

The kernel building script will need the standard kernel building dependencies to be install.

Debian-derived distributions

Use the command below to install the dependencies needed.

sudo apt-get install build-essential bc flex bison gnupg dirmngr libssl-dev

Basic Usage

To build the kernel deterministically, a certain kernel build directory is necessary. Currently /kbuild is chosen to be the fixed directory. So you should at first create it and grant rwx permission of the directory for the UNIX user you used to build the kernel.

As a directory under /, root access will be needed to create this directory.

sudo mkdir /kbuild
# Assume we're using the kernelbuild user
sudo chown kernelbuild /kbuild

Most of the source tarballs downloaded by the script is signed by GnuPG. If you do not have the necessary GPG public key imported to verify the signature of GNU things and the Linux Kernel, you can run

./import-keys.sh

or you can just set VERIFY_GPG environment variable to 0, thus signature verifying will be disabled. (IT'S NOT RECOMMENDED!)

After preparing the directory and have the keys imported, you can place a kernel config file named "config" in this directory, and then just run:

./run.sh

Some kernel configs modified to enable PaX and being deterministic is placed under configs/, include:

  • configs/paxed-allnoconfig: an all-no config with PaX and module support enabled, only for testing purpose.

  • configs/paxed-defconfig: defconfig with PaX enabled, can be used as a basis to customify the config.

  • configs/paxed-mint-config: a config file from Linux Mint 18 with PaX enabled, can be directly used on Debian-derived distributions without modification.

Then the output kernel (bzImage, vmlinux, modules, DPKG packages and build fingerprint) is located at out/

Reproduce

To reproduce a kernel build, there's some ways shown below:

  • Manually extract the fingerprint.sh and config from the build, and then use run.sh. (run.sh will check whether a fingerprint.sh or config exists)

  • Use the debian package prefixed linux-image- as the parameter of run.sh. (The image should be one generated by the script, otherwise it won't do a reproduce)

  • To just test build-kernel.sh, the script named "try-reproduce.sh" can be used. It will automatically run "build-kernel.sh" twice, and check the results. (NOTE: It requires the toolchain to be built at first.)

DPKG packages notice

Currently, we cannot ensure DPKG packages to be reproducible. However, we can promise the content of all the packages are reproducible.

A shell script named "deb-diff.sh" is present to compare the content of two DPKG packages. It will simply extract files from the package, and then use "diff" command to check the difference of them.

Config options to be noted

CONFIG_MODULE_SIG (Module signature verification)

When this option is enabled, there will be a key embedded into the kernel, which is used to sign modules.

The key is either generated at build time (from /dev/random, which made the key not reproducible), or pre-generated.

To enable reproducible builds of this option, the CONFIG_MODULE_SIG_KEY config should be modified to specify a pem file with absolute path, and you should manually keep a copy of the pem file and place it at the same place when reproduce. (It won't be cared by the building system.)

An auxillary script is written as "gen-x509-key.sh" to ease the key generation process. It needs two arguments: the first is the digest algorithm (sha1, sha224, sha256, sha384, sha512), and the second is the output file name.

CONFIG_PAX_LATENT_ENTROPY (Generate some entropy during boot and runtime)

When this option is enabled, the generated binary code will contain some random bits generated by GCC at build time, as entropy.

Enabling this option will lead to irreproducible builds.

So the option should be DISABLED now.

CONFIG_GRKERNSEC_RANDSTRUCT (Randomize layout of sensitive kernel structures)

When this option is enabled, the generated binary will have sensitive kernel structures randomized.

It uses a seed from /dev/urandom at build time, however, currently the scripts have already hacked the seed generation process. Now the seed is part of the build fingerprint.

So the option is now safe to ENABLE.

Out-of-tree kernel modules notes

As the build system used a "x86_64 to x86_64 cross-compiler", the modules cannot be built with the host compiler.

So if an out-of-tree module needs to be built, you should use the linux kernel source tree under /kbuild/linux-4.6.5, and add "CROSS_COMPILE=/kbuild/tools/bin/x86_64-kernelonly-linux-gnu-" argument to the make command.

For example, to build the acpi-call kernel module (which uses KDIR variable to indicate the kernel source tree):

acpi-call-1.1.0 # make KDIR=/kbuild/linux-4.6.5 CROSS_COMPILE=/kbuild/tools/bin/x86_64-kernelonly-linux-gnu-

Currently, some modules can be automatically built if they're placed into modules/ directory. A sample module is present, only to show how it works.

The module should use the build system described in linux/Documentation/kbuild/modules.txt.

Signature siging for Secure Boot

There are 3 parameters in ver.sh:

  • SECUREBOOT, "ENABLE": ENABLE the signature signing in build systems. If you don't need it, just ignore it.
  • DB_KEY/DB_CERT, the Authorized Signatures Database should be located in this path

Be aware of that only the signed file( e.g: vmlinuz-4.9.15-grsec.efi.signed) should be not reproducible. You build server may be compromised if you find other files being different.

Reference

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].