Conversation
|
What does enabling grsecurity in Firefox and Chromium do? And what's the effect on systems that don't have grsecurity enabled? |
|
The patches I wrote just disable the PAX_MPROTECT feature for the firefox, firefox's pluginwrapper and chromium binaries (you can see what PAX_MPROTECT does here: http://pax.grsecurity.net/docs/mprotect.txt , but basically, it prevents code execution in a variety of situations). We need to disable this feature for these binaries when running grsecurity kernels, otherwise the kernel will kill these processes when they are starting up, as these binaries do JIT code execution as part of their normal operation (Java will also need this, BTW, but I haven't had time to do it yet). We disable the feature by running "paxctl -c -m" on the binary, which converts an ELF section into a format expected by PaX (I don't know the exact details) and then disables the PAX_MPROTECT flag. This is what Gentoo hardened does as well, BTW. However, paxctl is only ran when nixpkgs.config.grsecurity is true, so on non-grsecurity enabled systems (i.e. by default) my patch doesn't change anything in Firefox and Chromium compilation. The only noteworthy but minor exception is that in Chromium, now we explicitely compile mksnapshot before compiling chrome, instead of compiling it implicitely, but this shouldn't have any effect in the result. |
|
Added a new patch, which allows some KDE applications to run as well. |
|
@wizeman, what effect do these changes have on systems that don't use grsecurity? Are there any performance or usability impacts? |
|
@peti There should be no noticeable negative impact for systems that don't use grsecurity. As for Firefox and Chromium, paxctl is only ran when nixpkgs.config.grsecurity is true. If it's false (the default) we don't modify the binaries. As for the qimageblitz patch, it's just declaring that the stack does not contain executable code. On non-grsecurity systems, it should behave the same in terms of performance and functionality, except you may have better protection against exploits on programs that use this library if your CPU supports the NX bit (as most x64 CPUs do). |
|
Added the grsecurity patch for 3.11.x kernels (the latest stable). |
|
+1 |
|
Updated grsecurity patches to latest versions. |
|
Added support for polkit, whose latest version now includes a Javascript JIT compiler (sigh...) |
|
Fixed firefox changes due to master removing 'let optional = stdenv.lib.optional' definition |
|
Updated to latest grsec patches |
|
I think that the PaX marking phases should be run always (regardless of the option). It's supposed just to set some flags in ELF and have no effect if you don't run a supporting kernel. Now most of X-depending stuff has a changed hash if you specify the option (e.g. through polkit). |
|
@vcunat I'm fine with that. BTW, we also need to PaX mark a couple of gcc binaries for -RANDMMAP, otherwise gcc will segfault when using precompiled headers (I have a patch for this, but I'm still testing it). Does that mean 'paxctl' will need to be included in bootstrap-tools, in order to build gcc? What if we leave it as an option, would we still need to include it in bootstrap-tools? |
|
Rebased and factored out grsecurity patch updates into a separate pull request. |
|
Bootstrap-tools inclusion: I haven't investigated deeper, but I think we won't need that (apart from the fact that bootstrapping on PaX-enabled systems doesn't seem a priority). It should be enough to mark the needed files from bootstrap-tools by paxctl (i.e. update gcc in bootstrap-utils). Then this version of gcc can be used to build paxctl and use it in the bootstrapping process. I would also think that there is a catch in compiling gcc on PaX-enabled kernel -- maybe it will be necessary to mark files during the build process. |
|
|
@vcunat It's not a problem to compile gcc on a PaX-enabled kernel, that's what I did before it was properly PaX-marked. If not properly marked, gcc only segfaults under a PaX kernel when using precompiled headers, and AFAICT gcc does not use that feature when compiling itself. |
|
What's the status of this? Update to apply and merge these markings on those packages (whether with grsecurity kernels or not)? |
|
@vcunat Please don't merge it yet, instead I prefer to merge some improvements that I have made in my personal tree, and I also want to make a few more (mostly to reduce duplicate code). As soon as I finish I will update this pull request and add a comment to let you know. If you wish, feel free to close this pull request in the mean time. |
|
I wouldn't merge it, as it doesn't apply anyway. I think it's better to remain in this thread. |
|
I've rebased and added a few more changes and fixes, most importantly:
One significant problem is that under PaX/grsecurity, mesa needs to use a readonly text segment for libGL, however, it looks like it causes a slight performance degradation. I'm still in the process of testing these changes, but I've updated the pull request now because it seems that @thoughtpolice is also working on grsecurity and I want to spare him from again duplicating work that I've already done... :-) |
|
Mesa: only the libGL found in /run/opengl-drivers* is ever used, and that symlink often differs from what's the original linkage. I suggest we only change that one and the one in build deps can be in any state (e.g. marked, slow one). I'll do this change after I get some time to review the rest and merge it. |
|
This is a stdenv-changing thing anyway, and I think it will be better to let Hydra rebuild before merging it. Can someone create a job(set) for this PR? @edolstra ? |
There was a problem hiding this comment.
How is this involved in grsecurity? (same for llvm-3.4)
There was a problem hiding this comment.
If we don't explicitly ask to build the tests, then they won't get built during the build phase, they will be built during the check phase instead.
The problem is that if the tests are built during the check phase, we can't easily pax-mark the tests in-between when they are built and when they are ran...
|
I just pushed a minor bugfix, sorry... In file I changed line 76 to: Because paxmark is not accumulative, it's idempotent... |
pkgs/top-level/all-packages.nix
Outdated
There was a problem hiding this comment.
Any reason why this cannot be a shell function (e.g. defined as a setup hook)? I.e. so you can just write
postInstall =
''
paxmark m $out/bin/foo
'';
There was a problem hiding this comment.
No reason... in fact, in Gentoo it's implemented as a shell function.
Would you like me to change it?
There was a problem hiding this comment.
Well, on second thought, I guess I'm not sure how I would call "stdenv.needsPax" from a stdenv setup hook?
Although that function is quite trivial currently, so I guess I could duplicate it in bash as long as I could find out which OS I'm running under (which I'm not sure how to do either?)...
|
I wonder if it would also make sense to add paxctl to Linux's stdenv so that we don't need to add paxctl to nativeBuildInputs all the time... |
Patch taken from Hardened Gentoo
This is needed for grsecurity kernels to be able to build stuff (e.g. pango). With grsec the libGL is slower, but we don't care much at build time, so we can share binaries among grsec and nogrsec. This adds 2-3 MB to nogrsec closures that use mesa drivers (libGL is doubled).
|
OK, current updates: the Hydra job for pr-1187 seemed to go through fairly smoothly, but it wasn't the full build. I have now rebased this branch on top of the current master, and it is available in Shea will run a full Nixpkgs build soon. |
|
PaX marking cannot be disabled with nixpkgs.config? One may not want pax, and use some other security frameworks. |
|
PaX markings have no effect when grsecurity is disabled.
|
|
@lethalman As @fread2281 said, PaX markings in binutils have no affect on non-grsecurity kernels. The problem is The binutils changes mean that expressions will now only need to have the right flags set ELF header in the expression via |
Tested building firefox, kdelibs, evince on x86_64-linux.
|
Added to my stdenv choice again. IIRC it was only "untestedness" that was blocking merge right before release. |
No description provided.