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: Select all
General setup --->
[*] Auditing supportCode: Select all
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 --->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: Select all
[*] Enable different security models
[*] Enable the securityfs filesystem2. 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: Select all
[*] Basic module for enforcing kernel lockdown
[*] Enable lockdown LSM early in init
Kernel default lockdown mode (Confidentiality) --->Code: Select all
~ # dmesg | grep -i lockdown
[ 0.000000] Kernel is locked down from Kernel configuration; see man kernel_lockdown.7
[ 1.248033] LSM: builtin ignored: lockdownFalls 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: Select all
[*] Integrity subsystemCode: Select all
[*] 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 recordsCode: Select all
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 arguments4. 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-1 ... ight-.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: Select all
# 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