Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hardened compiler flags by default #12895

Merged
merged 563 commits into from
Aug 29, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
563 commits
Select commit Hold shift + click to select a range
710f4cf
wvstreams: use newer gcc
globin Feb 25, 2016
da9352e
haskell.compilers.ghc6104: turn off format hardening
globin Feb 25, 2016
e0200a5
ssvnc: turn off format hardening
globin Feb 25, 2016
7412bff
self: use default compiler
globin Feb 26, 2016
351173c
stunnel: 5.29 -> 5.30
globin Feb 26, 2016
46b0d51
flow: 0.18 -> 0.22
globin Feb 26, 2016
c045d2d
signing-party: 2.1 -> 2.2
globin Feb 26, 2016
b627995
openssh: enable pie hardening
globin Feb 26, 2016
310fa56
nginx: enable pie hardening
globin Feb 26, 2016
a737622
socat: enable pie hardening
globin Feb 26, 2016
631c09b
checksec: clean up
globin Feb 26, 2016
87e64f1
cron: enable pie hardening
globin Feb 26, 2016
62f65d1
chrony: enable pie hardening
globin Feb 26, 2016
e392824
dnsmasq: enable pie hardening
globin Feb 26, 2016
8b9eccb
radvd: enable pie hardening
globin Feb 26, 2016
1a31447
icecast: enable pie hardening
globin Feb 26, 2016
b4dadff
memcached: enable pie hardening
globin Feb 26, 2016
3477e66
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Feb 27, 2016
b3d9562
fix evaluation
globin Feb 27, 2016
5176e7a
mongodb: enable pie hardening
globin Feb 27, 2016
83bf03e
glibc: disable stackprotector hardening
globin Feb 27, 2016
0889372
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Feb 27, 2016
d3fb7ac
dietlibc: fix merge failure
globin Feb 27, 2016
14177f5
speed_dreams: remove obsolete variable
globin Feb 27, 2016
cfffac2
postfix: use hardening flags from stdenv
globin Feb 27, 2016
8615f02
v8_3_16_14: use default stdenv
globin Feb 27, 2016
3b4765c
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Feb 28, 2016
4d6db3c
perl520: fix bootstrap compilation by disabling fortify hardening
globin Feb 28, 2016
85515f0
clisp_2_44_1: disable format hardening
globin Feb 29, 2016
2d17e81
clang-analyzer: use default clang
globin Feb 29, 2016
4f0608a
perseus: disable stackprotector hardening
globin Feb 29, 2016
1bbb2f0
pdf2xml: disable format hardening
globin Mar 1, 2016
d47857c
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 1, 2016
9ba6bd4
caneda: disable format hardening
globin Mar 1, 2016
a6dae3b
gnu-efi: disable stackprotector hardening
globin Mar 1, 2016
a12ecfc
refind: disable stackprotector hardening
globin Mar 1, 2016
2f7e9f2
gummiboot: disable stackprotector hardening
globin Mar 1, 2016
33f7d0b
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 1, 2016
4c9c4c4
redmine: disable format hardening
globin Mar 1, 2016
fed4942
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 3, 2016
84cc00b
ceph: possible fix for zip timestamps
globin Mar 3, 2016
23d85c7
spark: fix hash
globin Mar 3, 2016
745fa2f
pharo-vm5: disable format hardening
globin Mar 3, 2016
c3096a4
memtest86+: disable pic/stackprotector hardening
fadenb Mar 4, 2016
e43a384
faac: disable format hardening
fadenb Mar 4, 2016
5a1a8b6
Merge pull request #13673 from mayflower/fix/disable_hardening
globin Mar 4, 2016
d4ece75
haskellPackages.epanet-haskell: Turn format hardening off
fpletz Feb 26, 2016
a2e449e
coreutils: Skip some tests (filenames too long)
fpletz Nov 14, 2015
aff1f4a
Use general hardening flag toggle lists
fpletz Feb 26, 2016
cb3d27d
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Mar 5, 2016
034b2ec
glibc: stackprotector is already disabled in default.nix
fpletz Mar 5, 2016
0cad2e7
vim: Disable hardening flag fortify
fpletz Mar 5, 2016
05a02c5
cc-wrapper: -pie is a ldflag
fpletz Mar 5, 2016
fb57bfb
php: enable PIE hardening
fpletz Mar 5, 2016
6473000
opendkim: enable PIE hardening
fpletz Mar 5, 2016
1fb09c1
dhcpcd: enable PIE hardening
fpletz Mar 5, 2016
1b4ec4b
linuxPackages.virtualbox: disable fortify/pic/stackprotector
globin Mar 6, 2016
2013614
vim-configurable: Disable hardening flag fortify
globin Mar 6, 2016
63f60b6
cc-wrapper: Disable pie when linking shared libraries
fpletz Mar 6, 2016
ab10928
cc-wrapper: Disable pie for linking static libs
fpletz Mar 6, 2016
b2b499e
cc-wrapper: Increase number of functions for stackprotector
fpletz Mar 7, 2016
baee91e
cc-wrapper: Check if ld supports -z, fixes darwin
fpletz Mar 7, 2016
e9fc4e7
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Mar 7, 2016
fedf316
nginx: Rmove custom hardening, now enabled by default
fpletz Mar 7, 2016
ac73835
quicktun: Remove custom hardening, now enabled by default
fpletz Mar 7, 2016
965abb6
libxml2: Disable bindnow hardening
fpletz Mar 8, 2016
9a5b070
hardening: debug with NIX_DEBUG
globin Mar 8, 2016
514a478
cc-wrapper: Fix if syntax
fpletz Mar 9, 2016
7e2e0df
cc-wrapper: Use stderr for NIX_DEBUG output
fadenb Mar 10, 2016
1a5acdb
cc-wrapper: Add additional NIX_DEBUG statements
fadenb Mar 11, 2016
a9b942c
cc-wrapper: treat hardeningDisable as string
globin Mar 14, 2016
3f45f09
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 15, 2016
f60c9df
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 28, 2016
7dea0e9
gcc/isl: move bootstrap hardening flags to new bootstrap env
globin Mar 28, 2016
247bc1a
libidn: disable format hardening
globin Mar 28, 2016
97782aa
opendkim: don't enable pie hardening
globin Mar 28, 2016
b8e0cb3
jbig2enc: fix merge
globin Mar 28, 2016
4c55a0d
qcmm: fix merge
globin Mar 28, 2016
0fc7905
dhcpcd: do not enable pie hardening
globin Mar 29, 2016
c9ebdd4
libaio.i686: disable stackprotector hardening
globin Mar 29, 2016
8f94246
linuxPackages.mxu11x0: disable pic hardening
globin Mar 29, 2016
ba3399b
linuxPackages.rtl8723bs: disable pic hardening
globin Mar 29, 2016
4666eca
linuxPackages.mba6x_bl: disable pic hardening
globin Mar 29, 2016
9c3518b
freeswitch: 1.2.3 -> 1.6.6
globin Mar 29, 2016
a4e65c3
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Mar 30, 2016
a56d90e
php: Disable bindnow hardening flag
fpletz Mar 30, 2016
753086c
wxPython: Fix build
fpletz Mar 31, 2016
2e08d82
Merge remote-tracking branch 'origin/master'
fpletz Mar 31, 2016
5df521a
gst-python: Disable bindnow hardening flag
fpletz Mar 31, 2016
696d85a
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Apr 3, 2016
d326ca4
stunnel: 5.30 -> 5.31
globin Apr 3, 2016
3437b52
qboot: turn off stackprotector and pic hardening
globin Apr 3, 2016
f3f9145
spidermonkey.i686-linux: turn off stackprotector hardening
globin Apr 3, 2016
025cedc
singular.i686-linux: turn off stackprotector hardening
globin Apr 3, 2016
1f978b7
Revert "abook: fix compiling with gcc5"
globin Apr 3, 2016
4ee2b2a
rr: set Wno-error and turn off fortify hardening
globin Apr 3, 2016
fbb8067
dietlibc.i686-linux: disable pic
globin Apr 3, 2016
5978109
syslinux: disable fortify hardening
globin Apr 3, 2016
df72d62
Revert "php: enable PIE hardening"
globin Apr 3, 2016
db6c023
Revert "libxml2: Disable bindnow hardening"
globin Apr 3, 2016
f519a25
xorg: switch off bindnow hardening for all packages
globin Apr 4, 2016
bbbaccf
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Apr 4, 2016
bdbce02
eggdrop: fix build
globin Apr 4, 2016
d007846
ccrypt: disable format hardening
globin Apr 5, 2016
d8d6f0b
grub4dos: disable stackprotector hardening
globin Apr 5, 2016
9893a43
gfortran-darwin: disable format hardening
globin Apr 5, 2016
4d4610a
gprolog.i686-linux: disable pic hardening
globin Apr 5, 2016
f791c10
lua.i686-linux: disable stackprotector hardening
globin Apr 5, 2016
ad9376d
hunspell: disable format hardening
globin Apr 5, 2016
057a899
haskellPackages.glib: disable fortify hardening
globin Apr 6, 2016
58a73d3
haskellPackages.lvmrun: disable format hardening
globin Apr 6, 2016
0086c6d
lrzsz: disable format hardening
globin Apr 6, 2016
8bdd732
wla-dx: disable format hardening
globin Apr 6, 2016
812e25c
mksh: disable format hardening
globin Apr 6, 2016
7a347f6
wml: disable format hardening
globin Apr 6, 2016
88b49cc
tinycc: disable fortify hardening
globin Apr 6, 2016
8d4443a
recutils: disable format hardening
globin Apr 6, 2016
5ca99ae
kernel.i686-linux: disable bindnow hardening
globin Apr 6, 2016
a73a28d
fix grammar errors
globin Apr 6, 2016
3e68106
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Apr 7, 2016
d020caa
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Apr 18, 2016
a36f51f
neovim: disable fortify hardening
globin Apr 19, 2016
b59a6aa
kernel: turn off bindnow hardening
globin Apr 19, 2016
fd77c5c
haskellPackages.gio: turn off fortify hardening
globin Apr 19, 2016
33ef14f
haskellPackages: clean up unnecessary overrides
globin Apr 19, 2016
9a8a9c4
haskellPackages.pango: turn off fortify hardening
globin Apr 19, 2016
0fdde5e
rowhammer-test.isi686-linux: no Werror for format
globin Apr 19, 2016
c92bca5
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin May 2, 2016
9fbc20e
fix merge (webdsl removal)
globin May 3, 2016
f8d4817
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz May 18, 2016
527a605
dar: disable format hardening
globin May 9, 2016
eb6809e
emacs25pre: disable format hardening
globin May 9, 2016
3653798
gcl: disable bindnow hardening
globin May 9, 2016
2d382f3
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin May 30, 2016
2382084
haskellPackages.gtk{,3}: disable fortify hardening
globin May 31, 2016
a78316c
milu: disable format hardening
globin May 31, 2016
878e24b
linuxPackages.dpdk: disable pic hardening
globin May 31, 2016
e7be116
picat: disable format hardening
globin May 31, 2016
8f1e9d9
subtitleeditor: disable format hardening
globin May 31, 2016
2a5e64b
maude: disable stackprotector hardening
globin May 31, 2016
8031cba
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jun 10, 2016
851446e
fix merge failure
globin Jun 11, 2016
56b56c2
fix merge failure (2)
globin Jun 13, 2016
99cc3fa
systemd: Disable stackprotector hardening flag
fpletz May 31, 2016
06ed235
gcc6: disable format hardening flag
globin Jun 14, 2016
2fa0312
libdwg: disable format hardening flag
globin Jun 14, 2016
d9e5fd3
gnome3_20.nautilus: disable format hardening flag
globin Jun 18, 2016
0761573
gnome3_20.libgda: disable format hardening flag
globin Jun 18, 2016
26dd9ac
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Jul 9, 2016
0cee9fe
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Jul 13, 2016
f597e97
atlas: Fix hardening
fpletz Jul 13, 2016
5185bc1
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jul 15, 2016
6539901
Merge remote-tracking branch 'upstream/hardened-stdenv' into hardened…
globin Jul 15, 2016
203846b
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jul 19, 2016
04d873a
osx-private-sdk: Fix hash
globin Jul 16, 2016
cc54084
linuxPackages.wireguard: disable pic
globin Jul 21, 2016
1f04b4a
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jul 21, 2016
f222d98
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jul 25, 2016
43ba8d2
nvidia-x11: disable pic/format hardening
globin Jul 31, 2016
63c7b4f
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Jul 31, 2016
1be4907
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Aug 2, 2016
68a953c
nedit: disable format hardening
fpletz Jul 28, 2016
1005f46
xpdf: disable format hardening
fpletz Jul 28, 2016
44b24cc
motif: disable format hardening
globin Aug 2, 2016
15b8491
seabios: disable fortify hardening
fpletz Aug 2, 2016
cbc8fc2
zgv: disable format hardening
globin Aug 2, 2016
b9152cf
yabar: disable format hardening
globin Aug 2, 2016
c0830c1
wasm: disable format hardening
globin Aug 2, 2016
0eb6023
libjson_rpc_cpp: disable format hardening
globin Aug 2, 2016
b0d748e
bitkeeper: disable fortify hardening
fpletz Aug 2, 2016
f2a66d4
criu: fix merge fail
fpletz Aug 2, 2016
0751027
wxPython: Disable format hardening
fpletz May 31, 2016
c22c137
ruby_2_0: disable format hardening
fpletz Aug 2, 2016
fbbd50d
unicon-lang: disable fortify hardening
fpletz Aug 2, 2016
f0d0164
tracefilesim: disable fortify hardening
fpletz Aug 2, 2016
c1f1fd6
gegl_0_3: disable format hardening, add autoreconfHook
fpletz Aug 2, 2016
98473cd
x42-plugins: fix unpacking
globin Aug 3, 2016
3f9e860
vxl: remove obsolete patch
globin Aug 3, 2016
1b979d8
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Aug 3, 2016
a132aa4
gjay: disable format hardening
globin Aug 3, 2016
c95ab0a
gnumake380: disable format hardening
globin Aug 3, 2016
08928dc
kconfig-frontends: disable format hardening
globin Aug 3, 2016
e266c6a
eboard: disable format hardening
globin Aug 3, 2016
847f999
gnugo: disable format hardening
globin Aug 3, 2016
7423e02
convertlit: disable format hardening
globin Aug 3, 2016
708653a
kino: disable format hardening
globin Aug 3, 2016
bfa5a27
pfixtools: set -Wno-error=unused-result
globin Aug 3, 2016
a3a2d52
rman: disable format hardening
globin Aug 3, 2016
4f6bd09
spidermonkey_1_8_0rc1: disable format hardening
globin Aug 3, 2016
552a8c4
talkfilters: disable format hardening
globin Aug 3, 2016
7ab971a
scummvm: disable format hardening
globin Aug 3, 2016
4632389
ctpp2: use default gcc
globin Aug 4, 2016
7e81a42
dlx: disable format hardening
globin Aug 4, 2016
a748f31
fakenes: disable format hardening
globin Aug 4, 2016
a2ce153
fondu: disable fortify hardening
globin Aug 4, 2016
56e69fc
iptraf: disable fortify hardening
globin Aug 4, 2016
e2844fc
fontmatrix: disable fortify hardening
globin Aug 4, 2016
3bff873
libgksu: disable fortify hardening
globin Aug 4, 2016
78fc5dd
mmv: disable fortify hardening
globin Aug 4, 2016
dd7e091
bip: set -Wno-error=unused-result, remove --disable-pie
globin Aug 4, 2016
05dbbae
vlan: disable format hardening
fpletz Aug 4, 2016
1f06067
x2x: disable format hardening
fpletz Aug 4, 2016
b898fda
xmlroff: disable format hardening
fpletz Aug 4, 2016
f993dff
trackballs: disable format hardening
fpletz Aug 4, 2016
56f0316
reiser4progs: disable format hardening
fpletz Aug 4, 2016
8b7dc1a
ploticus: disable format hardening
fpletz Aug 4, 2016
0c7f045
tex4ht: disable format hardening
fpletz Aug 4, 2016
1f1637f
lprof: disable format hardening
fpletz Aug 4, 2016
19f5e2a
x2vnc: disable format hardening
globin Aug 5, 2016
bc025e8
uclibc: disable stackprotector hardening
globin Aug 5, 2016
b7787d9
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Aug 12, 2016
f7da99c
xorg.xorgserver: disable relro hardening
globin Aug 12, 2016
d1b2c34
qrcode: enable fortify hardening, disable warning
fpletz Aug 12, 2016
55966c2
doc: complete the hardening documentation
fpletz Aug 12, 2016
7a56781
dvdisaster: remove obsolete fortify disabling
globin Aug 12, 2016
572490b
udftools: remove obsolete gcc5 patch
globin Aug 12, 2016
bea8972
nixos.tests.boot-stage1: disable pic for kernel module
globin Aug 13, 2016
af04b6d
hardening docs: fix typo
globin Aug 13, 2016
0f274be
linuxPackages.ena: disable pic
globin Aug 13, 2016
7d9d2d6
linuxPackages.broadcom_sta: disable pic hardening
fpletz Aug 13, 2016
a8deb8d
linuxPackages.frandom: disable pic hardening
fpletz Aug 13, 2016
f5c9f99
linuxPackages.ati_drivers_x11: disable pic & format hardening
fpletz Aug 13, 2016
d836b81
linuxPackages.cryptodev: 1.6 -> 1.8, disable pic hardening
fpletz Aug 13, 2016
5e085b7
linuxPackages.e1000e: disable pic hardening
fpletz Aug 13, 2016
f55fd87
linuxPackages.ixgbevf: disable pic hardening
fpletz Aug 13, 2016
62e6bc0
linuxPackages.prl-tools: disable pic hardening
fpletz Aug 13, 2016
73a9ce2
linuxPackages.psmouse_alps: remove, driver in kernel since 3.9
fpletz Aug 13, 2016
5103e70
linuxPackages.nvidiabl: disable pic hardening
fpletz Aug 13, 2016
9e7d118
linuxPackages.nvidia-x11: disable pic & format hardening
fpletz Aug 13, 2016
b2c6d28
linuxPackages.ndiswrapper: disable pic hardening (still broken)
fpletz Aug 13, 2016
fa3a35b
linuxPackages.fusionio-vsl: disable pic hardening (still broken)
fpletz Aug 13, 2016
bd4490e
Merge branch 'master' into hardened-stdenv
fpletz Aug 13, 2016
2676cf9
linuxPackages.lttng-modules: fix build
globin Aug 13, 2016
8071caf
linuxPackages.rtl8812au: fix build
globin Aug 13, 2016
27b9f5d
xorg.*: disable relro/bindnow hardening
globin Aug 14, 2016
99cb230
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Aug 14, 2016
1747d28
glibc: add patch to fix segfault in forkpty
globin Aug 15, 2016
33e1c78
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
globin Aug 16, 2016
e0f124a
calamares/tarball test: fix eval error
obadz Aug 17, 2016
b4cc9bd
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Aug 17, 2016
335d009
cc-wrapper: add-{flags,hardening} -> add-{flags,hardening}.sh
globin Aug 23, 2016
07604ad
add-hardening.sh: fix quotation
globin Aug 23, 2016
3a18f06
Revert "lsh: remove last references"
globin Aug 23, 2016
7413278
Revert "Remove lsh, broken & unmaintained"
globin Aug 23, 2016
8ab4009
lsh: fix gcc5 build
joachifm Mar 28, 2016
9e21120
czmq: fix build
globin Aug 23, 2016
3c06e5f
cc-wrapper: check ld hardening capabilities in stdenv
fpletz Aug 23, 2016
17234ca
ccl: fix hash
fpletz Aug 23, 2016
8576aea
cc-wrapper: fix detection of unsupported linker flags
fpletz Aug 24, 2016
c0fa26e
Merge remote-tracking branch 'origin/master' into hardened-stdenv
fpletz Aug 24, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 1 addition & 1 deletion doc/languages-frameworks/python.md
Original file line number Diff line number Diff line change
Expand Up @@ -632,7 +632,7 @@ Given a `default.nix`:
src = ./.; }

Running `nix-shell` with no arguments should give you
the environment in which the package would be build with
the environment in which the package would be built with
`nix-build`.

Shortcut to setup environments with C headers/libraries and python packages:
Expand Down
203 changes: 203 additions & 0 deletions doc/stdenv.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1360,6 +1360,209 @@ in the default system locations.</para>

</section>

<section xml:id="sec-hardening-in-nixpkgs"><title>Hardening in Nixpkgs</title>

<para>There are flags available to harden packages at compile or link-time.
These can be toggled using the <varname>stdenv.mkDerivation</varname> parameters
<varname>hardeningDisable</varname> and <varname>hardeningEnable</varname>.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not a single flag hardening = (true|false)? Seems strange to have two Boolean arguments that are each other's opposite.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, they're not Booleans.

</para>

<para>The following flags are enabled by default and might require disabling
if the program to package is incompatible.
</para>

<variablelist>

<varlistentry>
<term><varname>format</varname></term>
<listitem><para>Adds the <option>-Wformat -Wformat-security
-Werror=format-security</option> compiler options. At present,
this warns about calls to <varname>printf</varname> and
<varname>scanf</varname> functions where the format string is
not a string literal and there are no format arguments, as in
<literal>printf(foo);</literal>. This may be a security hole
if the format string came from untrusted input and contains
<literal>%n</literal>.</para>

<para>This needs to be turned off or fixed for errors similar to:</para>

<programlisting>
/tmp/nix-build-zynaddsubfx-2.5.2.drv-0/zynaddsubfx-2.5.2/src/UI/guimain.cpp:571:28: error: format not a string literal and no format arguments [-Werror=format-security]
printf(help_message);
^
cc1plus: some warnings being treated as errors
</programlisting></listitem>
</varlistentry>

<varlistentry>
<term><varname>stackprotector</varname></term>
<listitem>
<para>Adds the <option>-fstack-protector-strong
--param ssp-buffer-size=4</option>
compiler options. This adds safety checks against stack overwrites
rendering many potential code injection attacks into aborting situations.
In the best case this turns code injection vulnerabilities into denial
of service or into non-issues (depending on the application).</para>

<para>This needs to be turned off or fixed for errors similar to:</para>

<programlisting>
bin/blib.a(bios_console.o): In function `bios_handle_cup':
/tmp/nix-build-ipxe-20141124-5cbdc41.drv-0/ipxe-5cbdc41/src/arch/i386/firmware/pcbios/bios_console.c:86: undefined reference to `__stack_chk_fail'
</programlisting></listitem>
</varlistentry>

<varlistentry>
<term><varname>fortify</varname></term>
<listitem>
<para>Adds the <option>-O2 -D_FORTIFY_SOURCE=2</option> compiler
options. During code generation the compiler knows a great deal of
information about buffer sizes (where possible), and attempts to replace
insecure unlimited length buffer function calls with length-limited ones.
This is especially useful for old, crufty code. Additionally, format
strings in writable memory that contain '%n' are blocked. If an application
depends on such a format string, it will need to be worked around.
</para>

<para>Addtionally, some warnings are enabled which might trigger build
failures if compiler warnings are treated as errors in the package build.
In this case, set <option>NIX_CFLAGS_COMPILE</option> to
<option>-Wno-error=warning-type</option>.</para>

<para>This needs to be turned off or fixed for errors similar to:</para>

<programlisting>
malloc.c:404:15: error: return type is an incomplete type
malloc.c:410:19: error: storage size of 'ms' isn't known
</programlisting>
<programlisting>
strdup.h:22:1: error: expected identifier or '(' before '__extension__'
</programlisting>
<programlisting>
strsep.c:65:23: error: register name not specified for 'delim'
</programlisting>
<programlisting>
installwatch.c:3751:5: error: conflicting types for '__open_2'
</programlisting>
<programlisting>
fcntl2.h:50:4: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT or O_TMPFILE in second argument needs 3 arguments
</programlisting>
</listitem>
</varlistentry>

<varlistentry>
<term><varname>pic</varname></term>
<listitem>
<para>Adds the <option>-fPIC</option> compiler options. This options adds
support for position independant code in shared libraries and thus making
ASLR possible.</para>
<para>Most notably, the Linux kernel, kernel modules and other code
not running in an operating system environment like boot loaders won't
build with PIC enabled. The compiler will is most cases complain that
PIC is not supported for a specific build.
</para>

<para>This needs to be turned off or fixed for assembler errors similar to:</para>

<programlisting>
ccbLfRgg.s: Assembler messages:
ccbLfRgg.s:33: Error: missing or invalid displacement expression `private_key_len@GOTOFF'
</programlisting>
</listitem>
</varlistentry>

<varlistentry>
<term><varname>strictoverflow</varname></term>
<listitem>
<para>Signed integer overflow is undefined behaviour according to the C
standard. If it happens, it is an error in the program as it should check
for overflow before it can happen, not afterwards. GCC provides built-in
functions to perform arithmetic with overflow checking, which are correct
and faster than any custom implementation. As a workaround, the option
<option>-fno-strict-overflow</option> makes gcc behave as if signed
integer overflows were defined.
</para>

<para>This flag should not trigger any build or runtime errors.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><varname>relro</varname></term>
<listitem>
<para>Adds the <option>-z relro</option> linker option. During program
load, several ELF memory sections need to be written to by the linker,
but can be turned read-only before turning over control to the program.
This prevents some GOT (and .dtors) overwrite attacks, but at least the
part of the GOT used by the dynamic linker (.got.plt) is still vulnerable.
</para>

<para>This flag can break dynamic shared object loading. For instance, the
module systems of Xorg and OpenCV are incompatible with this flag. In almost
all cases the <varname>bindnow</varname> flag must also be disabled and
incompatible programs typically fail with similar errors at runtime.</para>
</listitem>
</varlistentry>

<varlistentry>
<term><varname>bindnow</varname></term>
<listitem>
<para>Adds the <option>-z bindnow</option> linker option. During program
load, all dynamic symbols are resolved, allowing for the complete GOT to
be marked read-only (due to <varname>relro</varname>). This prevents GOT
overwrite attacks. For very large applications, this can incur some
performance loss during initial load while symbols are resolved, but this
shouldn't be an issue for daemons.
</para>

<para>This flag can break dynamic shared object loading. For instance, the
module systems of Xorg and PHP are incompatible with this flag. Programs
incompatible with this flag often fail at runtime due to missing symbols,
like:</para>

<programlisting>
intel_drv.so: undefined symbol: vgaHWFreeHWRec
</programlisting>
</listitem>
</varlistentry>

</variablelist>

<para>The following flags are disabled by default and should be enabled
for packages that take untrusted input, like network services.
</para>

<variablelist>

<varlistentry>
<term><varname>pie</varname></term>
<listitem>
<para>Adds the <option>-fPIE</option> compiler and <option>-pie</option>
linker options. Position Independent Executables are needed to take
advantage of Address Space Layout Randomization, supported by modern
kernel versions. While ASLR can already be enforced for data areas in
the stack and heap (brk and mmap), the code areas must be compiled as
position-independent. Shared libraries already do this with the
<varname>pic</varname> flag, so they gain ASLR automatically, but binary
.text regions need to be build with <varname>pie</varname> to gain ASLR.
When this happens, ROP attacks are much harder since there are no static
locations to bounce off of during a memory corruption attack.
</para>
</listitem>
</varlistentry>

</variablelist>

<para>For more in-depth information on these hardening flags and hardening in
general, refer to the
<link xlink:href="https://wiki.debian.org/Hardening">Debian Wiki</link>,
<link xlink:href="https://wiki.ubuntu.com/Security/Features">Ubuntu Wiki</link>,
<link xlink:href="https://wiki.gentoo.org/wiki/Project:Hardened">Gentoo Wiki</link>,
and the <link xlink:href="https://wiki.archlinux.org/index.php/DeveloperWiki:Security">
Arch Wiki</link>.
</para>

</section>

</chapter>

1 change: 1 addition & 0 deletions nixos/modules/config/gnu.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ with lib;
services.openssh.enable = false;
services.lshd.enable = true;
programs.ssh.startAgent = false;
services.xserver.startGnuPGAgent = true;

# TODO: GNU dico.
# TODO: GNU Inetutils' inetd.
Expand Down
4 changes: 2 additions & 2 deletions nixos/modules/system/boot/loader/grub/grub.nix
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ in
default = false;
type = types.bool;
description = ''
Whether GRUB should be build against libzfs.
Whether GRUB should be built against libzfs.
ZFS support is only available for GRUB v2.
This option is ignored for GRUB v1.
'';
Expand All @@ -351,7 +351,7 @@ in
default = false;
type = types.bool;
description = ''
Whether GRUB should be build with EFI support.
Whether GRUB should be built with EFI support.
EFI support is only available for GRUB v2.
This option is ignored for GRUB v1.
'';
Expand Down
1 change: 1 addition & 0 deletions nixos/tests/boot-stage1.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import ./make-test.nix ({ pkgs, ... }: {
kdev = config.boot.kernelPackages.kernel.dev;
kver = config.boot.kernelPackages.kernel.modDirVersion;
ksrc = "${kdev}/lib/modules/${kver}/build";
hardeningDisable = [ "pic" ];
} ''
echo "obj-m += $name.o" > Makefile
echo "$source" > "$name.c"
Expand Down
5 changes: 4 additions & 1 deletion pkgs/applications/audio/aacgain/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,16 @@

stdenv.mkDerivation {
name = "aacgain-1.9.0";

src = fetchFromGitHub {
owner = "mulx";
repo = "aacgain";
rev = "7c29dccd878ade1301710959aeebe87a8f0828f5";
sha256 = "07hl432vsscqg01b6wr99qmsj4gbx0i02x4k565432y6zpfmaxm0";
};

hardeningDisable = [ "format" ];

configurePhase = ''
cd mp4v2
./configure
Expand All @@ -28,7 +31,7 @@ stdenv.mkDerivation {
make LDFLAGS=-static

cd ..
make
make
'';

installPhase = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/cdparanoia/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ stdenv.mkDerivation rec {
sha256 = "1pv4zrajm46za0f6lv162iqffih57a8ly4pc69f7y0gfyigb8p80";
};

hardeningDisable = [ "format" ];

preConfigure = "unset CC";

patches = stdenv.lib.optionals stdenv.isDarwin [
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/csound/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ stdenv.mkDerivation {

enableParallelBuilding = true;

hardeningDisable = [ "format" ];

src = fetchurl {
url = mirror://sourceforge/csound/Csound6.04.tar.gz;
sha256 = "1030w38lxdwjz1irr32m9cl0paqmgr02lab2m7f7j1yihwxj1w0g";
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/freewheeling/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ stdenv.mkDerivation {

patches = [ ./am_path_sdl.patch ./xml.patch ];

hardeningDisable = [ "format" ];

meta = {
description = "A live looping instrument with JACK and MIDI support";
longDescription = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/gjay/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ stdenv.mkDerivation {

buildInputs = [ mpd_clientlib dbus_glib audacious gtk gsl libaudclient ];

hardeningDisable = [ "format" ];

meta = with stdenv.lib; {
description = "Generates playlists such that each song sounds good following the previous song";
homepage = http://gjay.sourceforge.net/;
Expand Down
4 changes: 3 additions & 1 deletion pkgs/applications/audio/jack-capture/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ stdenv.mkDerivation rec {
cp jack_capture $out/bin/
'';

meta = with stdenv.lib; {
hardeningDisable = [ "format" ];

meta = with stdenv.lib; {
description = "A program for recording soundfiles with jack";
homepage = http://archive.notam02.no/arkiv/src;
license = licenses.gpl2;
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/lingot/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ stdenv.mkDerivation {
sha256 = "0ygras6ndw2fylwxx86ac11pcr2y2bcfvvgiwrh92z6zncx254gc";
};

hardeningDisable = [ "format" ];

buildInputs = [ pkgconfig intltool gtk alsaLib libglade ];

configureFlags = "--disable-jack";
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/mi2ly/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ stdenv.mkDerivation {

sourceRoot=".";

hardeningDisable = [ "format" ];

buildPhase = "./cc";
installPhase = ''
mkdir -p "$out"/{bin,share/doc/mi2ly}
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/mp3info/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ stdenv.mkDerivation rec {

buildInputs = [ ncurses pkgconfig gtk ];

hardeningDisable = [ "format" ];

configurePhase =
'' sed -i Makefile \
-e "s|^prefix=.*$|prefix=$out|g ;
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/mp3val/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ stdenv.mkDerivation rec {
install -Dv mp3val "$out/bin/mp3val"
'';

hardeningDisable = [ "fortify" ];

meta = {
description = "A tool for validating and repairing MPEG audio streams";
longDescription = ''
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/mpg321/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ stdenv.mkDerivation rec {
sha256 = "0ki8mh76bbmdh77qsiw682dvi8y468yhbdabqwg05igmwc1wqvq5";
};

hardeningDisable = [ "format" ];

configureFlags = [
("--enable-alsa=" + (if stdenv.isLinux then "yes" else "no"))
];
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/musescore/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ stdenv.mkDerivation rec {
sha256 = "067f4li48qfhz2barj70zpf2d2mlii12npx07jx9xjkkgz84z4c9";
};

hardeningDisable = [ "relro" "bindnow" ];

makeFlags = [
"PREFIX=$(out)"
];
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/pd-plugins/cyclone/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ stdenv.mkDerivation rec {

buildInputs = [ puredata ];

hardeningDisable = [ "format" ];

patchPhase = ''
for file in `grep -r -l g_canvas.h`
do
Expand Down
2 changes: 2 additions & 0 deletions pkgs/applications/audio/pd-plugins/maxlib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ stdenv.mkDerivation rec {

buildInputs = [ puredata ];

hardeningDisable = [ "format" ];

patchPhase = ''
for i in ${puredata}/include/pd/*; do
ln -s $i .
Expand Down
Loading