LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices


Reply
  Search this Thread
Old 10-29-2016, 08:32 AM   #1
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Automatically building grsec-patched kernel (grsec-slackware)


After the recent COW stuff, I decided to finally get around to looking into grsecurity. Unfortunately the releases for the stable kernel can't be obtained, so there's only the test release for the public. Anyway, I built it on my Thinkpad X200 and it works well, so I thought I would try scripting up something to automatically pull the latest version of grsec and the relevant kernel, and build it. You can find my effort here. The script doesn't actually install anything on the system, just downloads the source and builds it in /tmp (as well as creating a slackpkg).

Be advised that I basically learnt this stuff on the fly (largely out of interest), and I can't guarantee anything. That said, the script doesn't need root access, and I've tested it on a couple of systems without issue. The kernel config is based on the Slackware 14.2 one, and I've disabled RBAC by default (but you still get PaX and all that nice stuff). The script gives you the chance to change whatever settings you want, and I think it makes it easier to at least try grsec. If you want to test it;
Code:
git clone https://github.com/drgibbon/grsec-slackware.git
cd grsec-slackware
./grsec-slackware.SlackBuild
There's also some info in the readme.

Last edited by drgibbon; 10-29-2016 at 08:36 AM.
 
Old 10-31-2016, 05:38 AM   #2
mlangdn
Senior Member
 
Registered: Mar 2005
Location: Kentucky
Distribution: Slackware64-current
Posts: 1,844

Rep: Reputation: 452Reputation: 452Reputation: 452Reputation: 452Reputation: 452
Not sure how to recover from this:

Code:
Checking kernel signature
gpg: assuming signed data in 'linux-4.7.10.tar'
gpg: Signature made Sat 22 Oct 2016 05:08:37 AM CDT using RSA key ID 6092693E
gpg: Can't check signature: No public key
Bad signature. Exiting
 
Old 10-31-2016, 05:58 AM   #3
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Original Poster
Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
It's looking for the public GPG kernel signing key of Greg Kroah-Hartman (the person who signed that kernel source release). If you don't have it, then gpg has no way of verifying that the archive has not been modified since it was released (i.e., that the archive was signed with Greg's private key). The part in the script that is failing is doing this;
Code:
gpg2 --verify linux-4.7.10.tar.sign
You can try that from the command line (where the source is); you will get the same error. The signatures page on kernel.org explains the process and has the info you need. If you want to quickly fix it you can do;
Code:
gpg2 --keyserver hkp://keys.gnupg.net --recv-keys 38DBBDC86092693E
but it's really worth reading the kernel.org page on it.
 
2 members found this post helpful.
Old 10-31-2016, 06:04 AM   #4
GazL
LQ Veteran
 
Registered: May 2008
Posts: 6,897

Rep: Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018Reputation: 5018
That's Greg K-H's kernel signing key

Run this:
Code:
gpg --recv-keys 6092693E
And then when you've got it, check the fingerprint against my copy:
Code:
src@ws1:~$ gpg --fingerprint 6092693E
pub   4096R/6092693E 2011-09-23
      Key fingerprint = 647F 2865 4894 E3BD 4571  99BE 38DB BDC8 6092 693E
uid                  Greg Kroah-Hartman (Linux kernel stable release signing key) <greg@kroah.com>
sub   4096R/76D54749 2011-09-23
I've had this quite a while and have used it to validate git tags and kernel sources many times, so if your fingerprint matches, you can be fairly sure you've got a good copy of the key. (assuming you can trust what I've written here hasn't been tampered with... but then we are really getting into tin-foil-hat land! )

edit: apologies to drgibbon for the cross-post.

Last edited by GazL; 10-31-2016 at 06:14 AM.
 
1 members found this post helpful.
Old 10-31-2016, 06:26 AM   #5
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Original Poster
Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
@GazL, all good, you provided some extra info and made a reference to tin-foil-hats, so that's fine by me ;P
 
Old 10-31-2016, 06:42 AM   #6
mlangdn
Senior Member
 
Registered: Mar 2005
Location: Kentucky
Distribution: Slackware64-current
Posts: 1,844

Rep: Reputation: 452Reputation: 452Reputation: 452Reputation: 452Reputation: 452
It is extracting the kernel source now. I had to import the key for grsec also - it failed there as well.
Thanks guys! It seems all is well now.
 
Old 10-31-2016, 05:34 PM   #7
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Original Poster
Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by mlangdn View Post
It is extracting the kernel source now. I had to import the key for grsec also - it failed there as well.
That failure is a good thing Otherwise you could be getting a tampered source archive and installing something very nasty into your system. The signing process is designed to stop that from happening. No public key = no go (as GazL pointed out though, you have to make sure you have the right public key). In theory the script could download the public keys, but I think it's better that the user handles that.

I do need to make an update incorporating the use of kernel patches where possible (instead of always downloading full source archives). If anyone has any other ideas for improvements, feel free to contribute something using git, I'd quite like to expand my knowledge with it.

Last edited by drgibbon; 10-31-2016 at 05:37 PM.
 
Old 11-23-2016, 06:54 AM   #8
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Original Poster
Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
In case anyone is using this, I realised that there was a packaging bug where two symlinks were not set correctly (in /lib/modules, resulting in failing compilations for new kernel modules, like VirtualBox). I've fixed that, and also changed the default config to use KVM, since I've not had any luck getting VirtualBox to work with grsec. You can still find it on Github.

There are also a number of PaX flags that need to be set, so I need to get around to making a paxctld Slackware set. In the meantime, some necessary flags can be found here.
 
Old 02-20-2017, 11:15 AM   #9
bamunds
Member
 
Registered: Sep 2013
Location: Mounds View MN
Distribution: Slackware64-14.2-Multilib XDM/FVWM3
Posts: 780

Rep: Reputation: 260Reputation: 260Reputation: 260
I'm wanting to install grsec-slackware kernel 4.9.11.
Is there any reason that I can't use this script with slackware64-current?
It appears I modify the slackbuild to kernel version 4.9.11 in KVERSION?
It appears the script will pull down the latest version of grsec?
Do I change GVERSION to "-201702181444"?
How do I add the RBAC so I can apply the PaX and iptable patches?
For security shouldn't fakeroot be rempved after using this script?
Can the script be run from root without installing fakeroot?
Cheers, BrianA_MN
 
Old 02-20-2017, 06:25 PM   #10
drgibbon
Senior Member
 
Registered: Nov 2014
Distribution: Slackware64 15.0
Posts: 1,217

Original Poster
Rep: Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942Reputation: 942
Quote:
Originally Posted by bamunds View Post
I'm wanting to install grsec-slackware kernel 4.9.11.
Is there any reason that I can't use this script with slackware64-current?
Should be more likely to work with current than with stable
Quote:
Originally Posted by bamunds View Post
It appears I modify the slackbuild to kernel version 4.9.11 in KVERSION?
It appears the script will pull down the latest version of grsec?
Do I change GVERSION to "-201702181444"?
You only need to change those variables if for some reason the automatic download/version detection doesn't work. Basically once you run it, the script will grab the grsec patch and kernel source required (no script modification needed).
Quote:
Originally Posted by bamunds View Post
How do I add the RBAC so I can apply the PaX and iptable patches?
The script will run the kernel config for you. If you want to save time, rename "config-4.8.11-grsec-3.1" to "config-4.9.11-grsec-3.1" (then the script will run make oldconfig on that). Then you should configure grsec appropriately for your system. E.g., Security Options -> Grsecurity -> Customize -> Role Based Access Control Options.
Quote:
Originally Posted by bamunds View Post
For security shouldn't fakeroot be rempved after using this script?
No, fakeroot is not a security risk. It doesn't escalate privileges, it just fakes root permissions. Without actually being root, nothing can be done that root cannot do (in other words, fakeroot is just used to build the packages with proper privileges, but you need to actually be root to install them/modify the system).
Quote:
Originally Posted by bamunds View Post
Can the script be run from root without installing fakeroot?
Sure. Comment out the stuff that checks for root/fakeroot (lines 29--34). Then just remove 'fakeroot' from line 298. I personally prefer running SlackBuilds as an unprivileged user.

The script works fine, but it's kind of basic. I will have the chance to improve it later on this year.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Longterm and Grsec on Slackware 13.0 letalangel Linux - Kernel 4 09-18-2011 05:01 PM
[SOLVED] LFS + Chroot on Grsec kernel + Apache = fail fmillion Linux - Server 2 12-03-2010 09:49 AM
devfs not mounted (kernel 2.6.24.5-grsec) Marko L Linux - Kernel 0 06-24-2008 02:52 PM
ALSA & kernel with grsec drenal Linux - Software 0 01-26-2004 05:34 PM
grsec+kernel 2.4.23+iptables f1uke Linux - Newbie 0 12-07-2003 12:36 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware

All times are GMT -5. The time now is 08:12 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration