Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
[howto] grsecurity
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools)
View previous topic :: View next topic  
Author Message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Wed Apr 28, 2004 10:37 am    Post subject: [howto] grsecurity Reply with quote

Non tutti conoscono le grsecurity (io le ho scoperta da pochissimo, quindi mi limiterò a spiegare come si patcha).


Controlliamo che sistema stiamo usando

Controlliamo prima che kernel abbiamo per evitare errori.
il metodo più veloce è questo:
Code:

#uname -r


Restituirà una cosa del tipo:
Code:
 $ uname -r
2.6.5-gentoo-r1


I valori che ci interessano sono i primi due cioè 2.6 (o 2.4 a seconda della voistra scelta).


Prendiamo la patch adatta

Dobbiamo recarci sul sito www.grsecurity.net/ e prendere nella sezione download l'ultima versione della patch.


Prepariamo la directory...

Dato che le grsecurity hanno bisogno del kernel per cui sono state create dobbiamo assicurarci che il nostro sia adatto. Ad esempio oggi mercoledì, 28 aprile 2004 il kernel stabile è il 2.6.5 e la patch di conseguenza è per il 2.6.5 .
Dentro la directory dei kernel (normalmente /usr/src/ )
Abbiamo in genere un link simbolico di nome linux al kernel che stiamo usando e uno o più kernel.
Modifichiamo momentaneamente il link simbolico per permettere alla patch di funzionare:
Code:
#mv /usr/src/linux /usr/src/linux-2.6.5



spostiamo le patch

Mettiamo le patch nel posto giusto cioè in /usr/src


Patchiamo!

Momento cruciale:
Code:
patch -p0 < grsecurity-2.0-2.6.5.patch


Se tutto andrà a buon fine darà un output similare a questo:
Code:
# patch -p0 < grsecurity-2.0-2.6.5.patch
patching file linux-2.6.5/Makefile
patching file linux-2.6.5/arch/alpha/kernel/osf_sys.c
patching file linux-2.6.5/arch/alpha/kernel/ptrace.c
patching file linux-2.6.5/arch/alpha/mm/fault.c
patching file linux-2.6.5/arch/i386/Kconfig
patching file linux-2.6.5/arch/i386/kernel/apm.c
patching file linux-2.6.5/arch/i386/kernel/cpu/common.c
patching file linux-2.6.5/arch/i386/kernel/entry.S
patching file linux-2.6.5/arch/i386/kernel/head.S
patching file linux-2.6.5/arch/i386/kernel/ioport.c
patching file linux-2.6.5/arch/i386/kernel/ldt.c
patching file linux-2.6.5/arch/i386/kernel/process.c
patching file linux-2.6.5/arch/i386/kernel/ptrace.c
-snip-
(Tagliamo corto)
-snip-
patching file linux-2.6.5/security/security.c


E' normale che alcuni messaggi di HUNK o reject appaiano dato che i gentoo-dev-sources sono già patchati in alcune parti.
In ogni caso controllate quali file sono stati rigettati, questo potrebbe influire sul corretto funzionamento della patch.
Altrimenti usate i vanilla.


Risistemiamo la directory

A questo punto risistemiamo la directory con:
Code:
#mv linux-2.6.5 linux



Make

Adesso verifichiamo se è stato patchato a dovere!
Code:
# cd /usr/src/linux


Salviamo il nostro .config in una locazione sicura...
Code:
#cp .config ~/config


Diamo un mrproper
Code:
#make mrproper


Riprendiamo il .config
Code:
#cp ~/config /usr/src/linux/.config


Diamo un make oldconfig per controllare se c'è roba che va sistemata nel config (si sa mai)
Code:
#make oldconfig


Controlliamo la presenza della patch
Code:
#make menuconfig


Quindi scorrete verso il menu
Code:
   Security options  --->


E controllate se c'è la voce
Code:
    Grsecurity  --->   
Da qui in poi tocca a voi ;) Configurare il grsecurity e ricompilare tutto Buon lavoro!


Per rimuovere la patch

Per rimuovere la patch rieseguite le operazioni di preparazione precedenti e date il comando
Code:
patch -p0 < grsecurity-2.0-2.6.5.patch -R





koma
(ps spero di aver fatto un buon lavoro è il primo howto che scrivo)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD


Last edited by koma on Wed Apr 28, 2004 1:40 pm; edited 6 times in total
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Wed Apr 28, 2004 11:06 am    Post subject: Reply with quote

Era un pezzo che mi chiedevo quando sarebbero uscite le grsec pe ril 2.6
Mitico koma!
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
randomaze
Bodhisattva
Bodhisattva


Joined: 21 Oct 2003
Posts: 9985

PostPosted: Wed Apr 28, 2004 11:12 am    Post subject: Re: [howto] grsecurity Reply with quote

Il lavoro é ottimo, ma ti segnalo un paio di cose....
koma wrote:
Controlliamo prima che kernel abbiamo per vitare errori.


evitare non vitare :-P

koma wrote:
patch -p0 < patch -p0 < grsecurity-2.0-2.6.5.patch


perché usi due volte il comando patch?

koma wrote:
Da qui in poi tocca a voi ;) Buon lavoro!


Lo cambierei con qualcosa tipo:
"Da qui in poi tocca a voi, compilate il kernel e installate tutto ;) Buon lavoro!"

EDIT:
koma wrote:
E' normale che alcuni messaggi di HUNK o reject appaiano dato che i gentoo-dev-sources sono già patchati in alcune parti.


Aggiungerei: In ogni caso controllate quali file sono stati rigettati, questo potrebbe influire sul corretto funzionamento della patch.
Altrimenti usate i vanilla.
_________________
Ciao da me!
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Wed Apr 28, 2004 11:23 am    Post subject: Reply with quote

Ho aggiunto le cose che mi avete fatto notare ;)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
federico
Advocate
Advocate


Joined: 18 Feb 2003
Posts: 3272
Location: Italy, Milano

PostPosted: Wed Apr 28, 2004 11:31 am    Post subject: Reply with quote

Se poi ti senti proprio figo e vuoi scrivere "la guida definitiva alla configurazione di grsec" saro' il primo a leggerla ;)
_________________
Sideralis www.sideralis.org
Pic http://blackman.amicofigo.com/gallery
Arduino http://www.arduino.cc
Chi aveva potuto aveva spaccato
2000 pezzi buttati là
Molti saluti,qualche domanda
Semplice come musica punk
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Wed Apr 28, 2004 11:36 am    Post subject: Reply with quote

ahhahaah non credo di essere sufficientemente bravo per una cosa simile l'unica cosa che posso conigliare è un medium level per il grsec ;)
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
maiosyet
Apprentice
Apprentice


Joined: 14 Oct 2003
Posts: 188
Location: /Italy/Milan

PostPosted: Wed Apr 28, 2004 11:54 am    Post subject: Reply with quote

Woh, non è che hai qualche link (magari in italiano) sulle grsecurity, che l'unica cosa che ho trovato è un pezzo su hackerjournal e chissà perchè non mi ispira molto... :wink:
Back to top
View user's profile Send private message
koma
Advocate
Advocate


Joined: 06 Jun 2003
Posts: 2702
Location: Italy

PostPosted: Wed Apr 28, 2004 1:36 pm    Post subject: Reply with quote

http://www.grsecurity.net/papers.php <- qui ma in italiano nn so :\
_________________
http://www.youtube.com/watch?v=_yoJI-Tl94g GLORY GLORY HYPNOTOAD
Back to top
View user's profile Send private message
primero.gentoo
Guru
Guru


Joined: 23 Dec 2003
Posts: 402

PostPosted: Wed Apr 28, 2004 1:55 pm    Post subject: Reply with quote

Questi non sono degli How-To ma degli articoli su grsecurity, comquneu interessanti

http://www.securityfocus.com/infocus/1551

Ovviamente www.gentoo.org/proj/en/hardened/grsecurity.xml

http://www.samag.com/documents/s=8859/sam0309g/sam0309g.htm

PDF http://www.cs.virginia.edu/~jcg8f/GrsecuritySELinuxCaseStudy.pdf

Ne avevo anche altri ... poi li cerco e ti faccio sapere :)

Ciao
_________________
"Linux, the choice of a GNU generation"
==Micro$oft - just say NO==
(L#USER 353039)
Back to top
View user's profile Send private message
motaboy
Developer
Developer


Joined: 15 Dec 2003
Posts: 1483

PostPosted: Wed Apr 28, 2004 2:30 pm    Post subject: Reply with quote

Dovrebbero parlarne nel prossimo numero di Linux&C, nella sezione Hardening Linux, fino adesso è stata molto interessante.

Bye!
_________________
...
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2963
Location: Milano, Italy

PostPosted: Wed Apr 28, 2004 4:20 pm    Post subject: Reply with quote

motaboy wrote:
Dovrebbero parlarne nel prossimo numero di Linux&C, nella sezione Hardening Linux, fino adesso è stata molto interessante.


Già :D

Non vedo l'ora che si muovano a far uscire il nuovo numero... sono impaziente
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
Diggs
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 239
Location: LoSt In NeT SpAcE

PostPosted: Wed Apr 28, 2004 6:24 pm    Post subject: Reply with quote

Un pò di links

GrSecurity:

http://www.linuxquestions.org/questions/archive/4/2003/05/4/61683

File Permission:

https://forums.gentoo.org/viewtopic.php?t=140142
(è un pò restrittivo eehe)

http://linux.psycholand.org/art/hardening.html
(da correggere e ottimizzare per gentoo)

Selinux:

http://www.crypt.gen.nz/selinux/faq.html#GA.4

Good Work :wink:
_________________
IRCNET NICK: diggs on IRCNET
http://leonardo.netsons.org/
Gioca a Tremulous! Player [!!!] Diggs [ITA]
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Wed Apr 28, 2004 8:53 pm    Post subject: Reply with quote

interessante. :)
Pero' forse manca la parte relativa alla configurazione di PaX e i permessi sulle risorse, ovvero la parte grossa di utilizzo del sistema.
Potresti includerla?
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Diggs
Apprentice
Apprentice


Joined: 07 Oct 2003
Posts: 239
Location: LoSt In NeT SpAcE

PostPosted: Sun May 02, 2004 2:14 pm    Post subject: Reply with quote

Vista la gran quantità di persone interessate a grsecurity, selinux ed ecc ecc perchè non fare una cosa carina:

Creare una serie di topic relativi al "minimum security howto" nella quale ognuon riporta le proprie esperienze riguardo ai tool sopra riportati, al filesystem hardening, al networking ed ecc ecc. Magari non veri e propri tutorial [se ci fossero sarebbe grande cosa :wink: ] :arrow: Una sorta di topic "Tip for..."...
_________________
IRCNET NICK: diggs on IRCNET
http://leonardo.netsons.org/
Gioca a Tremulous! Player [!!!] Diggs [ITA]
Back to top
View user's profile Send private message
primero.gentoo
Guru
Guru


Joined: 23 Dec 2003
Posts: 402

PostPosted: Tue May 04, 2004 9:11 pm    Post subject: Reply with quote

ecco un'altro bel link che avevo ... sparso in quel gran casino che e' il mio bookmark :lol:

SANS whitepaper (PDF)

ciauz
_________________
"Linux, the choice of a GNU generation"
==Micro$oft - just say NO==
(L#USER 353039)
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Sun Dec 19, 2004 4:51 pm    Post subject: Reply with quote

Scusate ma volevo porvi qualche domanda.

A quanto ho capito non si può usare una patch se non per il kernel per il quale è stata fatta. Quindi se uno usa i gentoo-dev-sources (essendo la stabile la 2.6.9) non si può usare giusto?

Quindi se volessi il gentoo-dev-sources-2.6.7 (per cui c'è la patch) basta dare un emerge =sys-kernel/gentoo-dev-sources-2.6.7 giusto?

Poi volevo fare una precisazione. Da quanto ne sò i gentoo-sources sono già patchati per il grsecurity. Basta ovviamente configurarli.

Un ultima domanda: SElinux è compatibile col grsecurity?

Grazie e scusate per la miriade di domande.
_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2963
Location: Milano, Italy

PostPosted: Sun Dec 19, 2004 5:31 pm    Post subject: Reply with quote

Neomubumba wrote:
A quanto ho capito non si può usare una patch se non per il kernel per il quale è stata fatta.
Esatto
Neomubumba wrote:
Quindi se volessi il gentoo-dev-sources-2.6.7 (per cui c'è la patch) basta dare un emerge =sys-kernel/gentoo-dev-sources-2.6.7 giusto?
Poi volevo fare una precisazione. Da quanto ne sò i gentoo-sources sono già patchati per il grsecurity. Basta ovviamente configurarli.

Ferma ferma... Allora se non ricordo male grsecuity andrebbe applicato ai sorgento vanilla, applicarlo a kernel cui sono state applicate altre patch potrebbe non dare i risultati sperati.

In portage ci sono i pacchetti hardened-sources [kernel 2.4 gentoo-sources con grsecurity ed altre belle cosette] e hardened-dev-sources [kernel 2.6 gentoo-dev-sources con grsecurity ed altre belle cosette].
Così potrai sperimentar grsecurity [non mi ricordo se c'è dentro anche SELinux] su un kernel patchato e controllato dal team gentoo, senza che tu debba far nulla. Più comodo non credi :wink:

Neomubumba wrote:
Un ultima domanda: SElinux è compatibile col grsecurity?
Non so. Cmq se proprio vuoi fare hardening leggi questo eccellente howto dalla documentazione ufficiale gentoo . Una volta che avrai finito di leggerla ripensa se hai davvero bisogno di SELinux.

E' un sistema molto complesso da metter in piedi e da gestire... Valuta tu.
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Mon Dec 20, 2004 7:45 am    Post subject: Reply with quote

selinux e grsecurity sono due implementazioni diverse.
grsecurity e' piu userfriendly, mentre selinux e' piu granulare.
grsecurity e' fermo al kernel 2.6.7 a causa di modifiche al codice mmap che hanno fatto sui kernel successivi.
selinux e' MOLTO ostico da installare, specie su gentoo.. calcola che io nonostante vari tentativi non sono mai riuscito a crearne un sistema funzioannte.

grsecurity ha dalla sua il fatto che puo' "imparare" dall'esecuzione dei demoni, mentre con selinux sei tu che devi scrivere tutte le acl (pensaci)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Mon Dec 20, 2004 3:23 pm    Post subject: Reply with quote

Grazie per i consigli. Un ultimissima domanda... stò seguendo un tutorial che ho trovato su OpenSource (a proposito appunto di Grsecurity) e dice di patchare le binutils con una patch per PaX. Ho provato a guardare se c'era qualche falg specifico per le binutils ma ho trovato che le uniche flag possibili sono: -bootstrap -build -debug -multitarget +nls. E non mi sembra che ci sia nulla che abbia a che vedere con PaX, quindi la mia domanda è: sono già patchate (che non penso che sia così) e se no se posso patcharle io usando lo stesso emerge.

Andrebbe bene qualcosa del genere:

Code:
emerge binutils
# dopo che le ha scompattate in /tmp/portage gli do un CTRL + z
cd /tmp/portage/binutils...
patch -p1 < /patch....
# patcho i sorgenti
fg
#riprendo ora con la compilazione


Potrebbe andare bene?
_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2963
Location: Milano, Italy

PostPosted: Mon Dec 20, 2004 3:38 pm    Post subject: Reply with quote

Prova a cercare Pax in portage...
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Mon Dec 20, 2004 3:46 pm    Post subject: Reply with quote

In portage c'è Pax come paxctl (che è quello che devo mettere) ma il fatto è che nell'articolo c'è scritto che si patchano le binutils per aggiungere il supporto alle Pax. Quindi se in portage c'è paxctl (che è quello che poi devo installare), le binutils dovrebbe essere già patchate per supportare paxctl (altrimenti le richiederebbe come dipendenza, no?)

Infatti ho provato pure a dare:

Code:
emerge -Dp paxctl


e non mi richiedeva nient'altro che paxctl
_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
.:deadhead:.
Advocate
Advocate


Joined: 25 Nov 2003
Posts: 2963
Location: Milano, Italy

PostPosted: Mon Dec 20, 2004 5:49 pm    Post subject: Reply with quote

Magari è così :) cmq oltre ad eventuali guide, io butterei anche un occhio alla doc presente sul sito di gsecurity e di pax...
_________________
Proudly member of the Gentoo Documentation Project: the Italian Conspiracy ! ;)
Back to top
View user's profile Send private message
Sparker
l33t
l33t


Joined: 28 Aug 2003
Posts: 992

PostPosted: Mon Dec 20, 2004 6:57 pm    Post subject: Reply with quote

Come già accennato esiste il progetto gentoo-hardened
Per ora la documentazione è un po' scarsa
Hanno creato il kernel hardened-(dev-)sources, che contiene sia grsec che PAX che selinux.
Inoltre è utile compilare il sistema con la USE "hardened", in particolare viene patchato gcc per creare binari più sicuri (non chiedetemi come :oops: )
Back to top
View user's profile Send private message
FonderiaDigitale
Veteran
Veteran


Joined: 06 Nov 2003
Posts: 1710
Location: Rome, Italy

PostPosted: Mon Dec 20, 2004 7:00 pm    Post subject: Reply with quote

riguardo hardened-dev-sources, se si abilita la flag selinux viene escluso pax+grsecurity (ovviamente)
_________________
Come disse un amico, i sistemisti sono un po' come gli artigiani per l'informatica :)
Back to top
View user's profile Send private message
Neomubumba
Tux's lil' helper
Tux's lil' helper


Joined: 17 Feb 2004
Posts: 136
Location: Milano

PostPosted: Tue Dec 21, 2004 12:37 pm    Post subject: Reply with quote

Se però non si mette la flag use selinux mi sembra di aver capito che è possibile usare sia PaX/Grsecurity che SElinux. Basta abilitare questa opzione (e poi configurare le nuove opzioni):

Code:
Linux Kernel Configuration
--> Security options
      ...
      --> [*] Enable different security models

_________________
Some of those that were forces, are the sames that bore crosses,
Some of those that were crosses, are the sames that are forces
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Forum italiano (Italian) Risorse italiane (documentazione e tools) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum