Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
C2 Kernel Konfiguration III für Lockdown und IMA
View unanswered posts
View posts from last 24 hours
View posts from last 7 days

 
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Deutsche Dokumentation
View previous topic :: View next topic  
Author Message
pietinger
Moderator
Moderator


Joined: 17 Oct 2006
Posts: 4160
Location: Bavaria

PostPosted: Sat Oct 31, 2020 2:49 pm    Post subject: C2 Kernel Konfiguration III für Lockdown und IMA Reply with quote

(Dieser Post ist Teil einer Installation-Anleitung. Falls nicht schon geschehen lies bitte: Installation Guide for Paranoid Dummies Post Nr. 2)

Hinweis: Alle Beschreibungen der C-Reihe wurden getestet mit einem signierten, monolithischen, (stub-) Kernel (*) der Version 5.9.0 und 5.9.2, der per SecureBoot von UEFI direkt geladen wird. (* das bedeutet B.2 und B.3 wurden komplett vorher umgesetzt).

Mache den Kernel Lockdown nicht, wenn Du noch unsignierte Kernel-Module verwendest. Also entweder Du hast einen monolithischen Kernel, oder Du hast die Kernel-Module signiert. Lies vorher nochmal B.2 !!



C.2 Kernel Konfiguration III für Lockdown und IMA


1. Vorbereitung

Prüfe ob der "Auditing support" gesetzt ist. Dies ist zwar nach der derzeitigen default configuration der Fall, es könnte aber sein, dass Du diesen mal entfernt hast. Wir brauchen ihn aber:
Code:
General setup  --->
 [*] Auditing support


Nun werden wir nur noch in den "Security options" sein. Je nachdem wieviel Du hier schon konfiguriert hast, ist diese unterschiedlich aufgebaut. Du solltest mindestens diese Optionen haben:
Code:
Security options  --->
 [ ] Enable access key retention support
 [*] Restrict unprivileged access to the kernel syslog                                                  !!!
 [ ] Enable different security models
 [ ] Enable the securityfs filesystem
 [ ] Enable Intel(R) Trusted Execution Technology (Intel(R) TXT)
 [*] Harden memory copies between kernel and userspace                                                  !!!
 [*] Harden common str/mem functions against buffer overflows                                           !!!
 [*] Force all usermode helper calls through a single binary                                            !!!
 ()    Path to the static usermode helper binary                                                        !!!
    First legacy 'major LSM' to be initialized (Unix Discretionary Access Controls)  --->
 (lockdown,yama,loadpin,safesetid,integrity,bpf) Ordered list of enabled LSMs
    Kernel hardening options  --->

(Die fünf mit !!! markierten Zeilen sollten exakt so sein wie hier. Also auch der leere Pfad.)

Von früheren Konfig-Orgien des Kernels kennst Du sicher schon das Verhalten, dass einige Optionen erst erscheinen, wenn Du andere aktiviert hast. Deshalb aktiviere als erstes - falls nicht schon geschehen - diese beiden:
Code:
 [*] Enable different security models
 [*] Enable the securityfs filesystem

Jetzt müssen die einzelnen Linux Security Module (LSM) erscheinen. Falls Du nur IMA haben möchtest überspringe das nächste Kapitel.


2. Aktivieren des Kernel Lockdown

Das vorhin gesagte gilt auch für folgenden Block. Du musst zuerst die erste Zeile enabeln um die beiden weiteren zu bekommen:
Code:
 [*] Basic module for enforcing kernel lockdown
 [*]   Enable lockdown LSM early in init
 Kernel default lockdown mode (Confidentiality)  --->

Wenn Du später diese Konfiguration in dmesg überprüfst, sollte - mindestens - folgendes erscheinen (kann auch mehr sein, falls Du zusätzliches konfiguriert hast):
Code:
 ~ # dmesg | grep -i lockdown
[    0.000000] Kernel is locked down from Kernel configuration; see man kernel_lockdown.7
[    1.248033] LSM: builtin ignored: lockdown

Die 2. Zeile ist normal und würde nur dann "LSM: builtin ordering: lockdown (enabled)" anzeigen, wenn der "Enable lockdown LSM early in init" in der Kernel Konfig nicht aktiviert wäre (dafür würde dann die erste Zeile fehlen).

Falls Du nur den Lockdown aktiviert haben wolltest - ohne IMA - dann überspringe das nächste Kapitel. Ausser Punkt 4 sind keine weiteren Aktionen mehr nötig. Du bist dann fertig und benötigst weder C.3 noch C.4.


3. Vorbereitende Kernel Konfiguration für IMA

Als erstes musst Du das aktivieren:
Code:
 [*] Integrity subsystem

Es erscheinen vier Sub-Menüs. Die ersten drei werden wir aktivieren (also nicht EVM). Danach erscheinen jedoch noch weitere Optionen. Ich habe das zusammengefasst. Wenn Du fertig bist, sollte das ganze so aussehen:
Code:
 [*] Integrity subsystem
 [*]   Digital signature verification using multiple keyrings
 [*]     Enable asymmetric keys support
 [ ]       Require all keys on the integrity keyrings be signed
 [*]       Provide keyring for platform/firmware trusted keys
 -*-   Enables integrity auditing support
 [*]   Integrity Measurement Architecture(IMA)
         Default template (ima-ng (default))  --->
         Default integrity hash algorithm (SHA1 (default))  --->
 [ ]     Enable multiple writes to the IMA policy
 [*]     Enable reading back the current IMA policy
 [*]     Appraise integrity measurements
 [ ]     Enable loading an IMA architecture specific policy
 [ ]   IMA build time configured policy rules
 [*]   ima_appraise boot parameter
 [ ]   Support module-style signatures for appraisal
 [ ]   Require all keys on the .ima keyring be signed (deprecated)
 [ ]   Permit keys validly signed by a built-in or secondary CA cert (EXPERIMENTAL)
 [ ]   Disable htable to allow measurement of duplicate records

Ergänze nun die Bulit-in kernel Command Line mit den beiden Parameter "lsm.debug" und "ima_appraise=off":
Code:
Processor type and features  --->
 [*] Built-in kernel command line
 (root=PARTUUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx ro loglevel=8 ima_appraise=off lsm.debug) Built-in kernel command string
 [*]   Built-in command line overrides boot loader arguments

Der Paramter "lsm.debug" ist überhaupt nicht notwendig, ich möchte nur einige Ausgaben vom LSM Subsystem sehen. Du kannst ihn problemlos später entfernen.


4. Nachdem Du die Konfiguration (mit speichern) verlassen hast, kannst Du den Kernel gleich compilieren, installieren und booten, und es sollte nichts schlimmes passieren. Wenn Du aber nicht nur den Kernel Lockdown, sondern auch noch IMA haben möchtest, kannst Du Dir das sparen und gleich mit C.3 weitermachen. An dieser Stelle möchte ich auf den 3.Post von A.2 hinweisen (https://forums.gentoo.org/viewtopic-t-1112778-highlight-.html): Der Trick mit "dmesg -t" ist ideal um die Auswirkungen unterschiedlicher Kernel Konfigurationen zu sehen.

Wenn Du diesen Kernel mit SecureBoot startest, solltest Du (mindestens) folgendes in dmseg sehen:
Code:
# dmesg | grep LSM
[    1.248029] LSM: Security Framework initializing
[    1.248032] LSM: first ordering: capability (enabled)
[    1.248033] LSM: builtin ignored: lockdown
[    1.248034] LSM: builtin ordering: yama (enabled)
[    1.248035] LSM: builtin ignored: loadpin
[    1.248036] LSM: builtin ignored: safesetid
[    1.248038] LSM: builtin ordering: integrity (enabled)
[    1.248039] LSM: builtin ignored: bpf
[    1.248040] LSM: cred blob size     = 0
[    1.248041] LSM: file blob size     = 0
[    1.248041] LSM: inode blob size    = 0
[    1.248054] LSM: ipc blob size      = 0
[    1.248055] LSM: msg_msg blob size  = 0
[    1.248056] LSM: task blob size     = 0
[    1.248057] LSM: initializing capability
[    1.248058] LSM: initializing yama
[    1.248062] LSM: initializing integrity
# dmesg | grep integrity
[    1.397183] LSM: builtin ordering: integrity (enabled)
[    1.397213] LSM: initializing integrity
# dmesg | grep ima:
[    2.154438] ima: No TPM chip found, activating TPM-bypass!
[    2.154460] ima: Allocated hash algorithm: sha1
[    2.154481] ima: No architecture policies found
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Deutsches Forum (German) Deutsche Dokumentation 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