2024-08-03 06:08:15 +00:00
|
|
|
# SPDX-License-Identifier: GPL-2.0-only
|
|
|
|
#
|
|
|
|
# Integrity Policy Enforcement (IPE) configuration
|
|
|
|
#
|
|
|
|
|
|
|
|
menuconfig SECURITY_IPE
|
|
|
|
bool "Integrity Policy Enforcement (IPE)"
|
audit,ipe: add IPE auditing support
Users of IPE require a way to identify when and why an operation fails,
allowing them to both respond to violations of policy and be notified
of potentially malicious actions on their systems with respect to IPE
itself.
This patch introduces 3 new audit events.
AUDIT_IPE_ACCESS(1420) indicates the result of an IPE policy evaluation
of a resource.
AUDIT_IPE_CONFIG_CHANGE(1421) indicates the current active IPE policy
has been changed to another loaded policy.
AUDIT_IPE_POLICY_LOAD(1422) indicates a new IPE policy has been loaded
into the kernel.
This patch also adds support for success auditing, allowing users to
identify why an allow decision was made for a resource. However, it is
recommended to use this option with caution, as it is quite noisy.
Here are some examples of the new audit record types:
AUDIT_IPE_ACCESS(1420):
audit: AUDIT1420 ipe_op=EXECUTE ipe_hook=BPRM_CHECK enforcing=1
pid=297 comm="sh" path="/root/vol/bin/hello" dev="tmpfs"
ino=3897 rule="op=EXECUTE boot_verified=TRUE action=ALLOW"
audit: AUDIT1420 ipe_op=EXECUTE ipe_hook=BPRM_CHECK enforcing=1
pid=299 comm="sh" path="/mnt/ipe/bin/hello" dev="dm-0"
ino=2 rule="DEFAULT action=DENY"
audit: AUDIT1420 ipe_op=EXECUTE ipe_hook=BPRM_CHECK enforcing=1
pid=300 path="/tmp/tmpdp2h1lub/deny/bin/hello" dev="tmpfs"
ino=131 rule="DEFAULT action=DENY"
The above three records were generated when the active IPE policy only
allows binaries from the initramfs to run. The three identical `hello`
binary were placed at different locations, only the first hello from
the rootfs(initramfs) was allowed.
Field ipe_op followed by the IPE operation name associated with the log.
Field ipe_hook followed by the name of the LSM hook that triggered the IPE
event.
Field enforcing followed by the enforcement state of IPE. (it will be
introduced in the next commit)
Field pid followed by the pid of the process that triggered the IPE
event.
Field comm followed by the command line program name of the process that
triggered the IPE event.
Field path followed by the file's path name.
Field dev followed by the device name as found in /dev where the file is
from.
Note that for device mappers it will use the name `dm-X` instead of
the name in /dev/mapper.
For a file in a temp file system, which is not from a device, it will use
`tmpfs` for the field.
The implementation of this part is following another existing use case
LSM_AUDIT_DATA_INODE in security/lsm_audit.c
Field ino followed by the file's inode number.
Field rule followed by the IPE rule made the access decision. The whole
rule must be audited because the decision is based on the combination of
all property conditions in the rule.
Along with the syscall audit event, user can know why a blocked
happened. For example:
audit: AUDIT1420 ipe_op=EXECUTE ipe_hook=BPRM_CHECK enforcing=1
pid=2138 comm="bash" path="/mnt/ipe/bin/hello" dev="dm-0"
ino=2 rule="DEFAULT action=DENY"
audit[1956]: SYSCALL arch=c000003e syscall=59
success=no exit=-13 a0=556790138df0 a1=556790135390 a2=5567901338b0
a3=ab2a41a67f4f1f4e items=1 ppid=147 pid=1956 auid=4294967295 uid=0
gid=0 euid=0 suid=0 fsuid=0 egid=0 sgid=0 fsgid=0 tty=pts0
ses=4294967295 comm="bash" exe="/usr/bin/bash" key=(null)
The above two records showed bash used execve to run "hello" and got
blocked by IPE. Note that the IPE records are always prior to a SYSCALL
record.
AUDIT_IPE_CONFIG_CHANGE(1421):
audit: AUDIT1421
old_active_pol_name="Allow_All" old_active_pol_version=0.0.0
old_policy_digest=sha256:E3B0C44298FC1C149AFBF4C8996FB92427AE41E4649
new_active_pol_name="boot_verified" new_active_pol_version=0.0.0
new_policy_digest=sha256:820EEA5B40CA42B51F68962354BA083122A20BB846F
auid=4294967295 ses=4294967295 lsm=ipe res=1
The above record showed the current IPE active policy switch from
`Allow_All` to `boot_verified` along with the version and the hash
digest of the two policies. Note IPE can only have one policy active
at a time, all access decision evaluation is based on the current active
policy.
The normal procedure to deploy a policy is loading the policy to deploy
into the kernel first, then switch the active policy to it.
AUDIT_IPE_POLICY_LOAD(1422):
audit: AUDIT1422 policy_name="boot_verified" policy_version=0.0.0
policy_digest=sha256:820EEA5B40CA42B51F68962354BA083122A20BB846F2676
auid=4294967295 ses=4294967295 lsm=ipe res=1
The above record showed a new policy has been loaded into the kernel
with the policy name, policy version and policy hash.
Signed-off-by: Deven Bowers <deven.desai@linux.microsoft.com>
Signed-off-by: Fan Wu <wufan@linux.microsoft.com>
[PM: subject line tweak]
Signed-off-by: Paul Moore <paul@paul-moore.com>
2024-08-03 06:08:23 +00:00
|
|
|
depends on SECURITY && SECURITYFS && AUDIT && AUDITSYSCALL
|
2024-08-03 06:08:15 +00:00
|
|
|
select PKCS7_MESSAGE_PARSER
|
|
|
|
select SYSTEM_DATA_VERIFICATION
|
2024-08-03 06:08:27 +00:00
|
|
|
select IPE_PROP_DM_VERITY if DM_VERITY
|
|
|
|
select IPE_PROP_DM_VERITY_SIGNATURE if DM_VERITY && DM_VERITY_VERIFY_ROOTHASH_SIG
|
2024-08-03 06:08:30 +00:00
|
|
|
select IPE_PROP_FS_VERITY if FS_VERITY
|
|
|
|
select IPE_PROP_FS_VERITY_BUILTIN_SIG if FS_VERITY && FS_VERITY_BUILTIN_SIGNATURES
|
2024-08-03 06:08:15 +00:00
|
|
|
help
|
|
|
|
This option enables the Integrity Policy Enforcement LSM
|
|
|
|
allowing users to define a policy to enforce a trust-based access
|
|
|
|
control. A key feature of IPE is a customizable policy to allow
|
|
|
|
admins to reconfigure trust requirements on the fly.
|
|
|
|
|
|
|
|
If unsure, answer N.
|
2024-08-03 06:08:27 +00:00
|
|
|
|
|
|
|
if SECURITY_IPE
|
2024-08-03 06:08:31 +00:00
|
|
|
config IPE_BOOT_POLICY
|
|
|
|
string "Integrity policy to apply on system startup"
|
|
|
|
help
|
|
|
|
This option specifies a filepath to an IPE policy that is compiled
|
|
|
|
into the kernel. This policy will be enforced until a policy update
|
|
|
|
is deployed via the $securityfs/ipe/policies/$policy_name/active
|
|
|
|
interface.
|
|
|
|
|
|
|
|
If unsure, leave blank.
|
|
|
|
|
ipe: allow secondary and platform keyrings to install/update policies
The current policy management makes it impossible to use IPE
in a general purpose distribution. In such cases the users are not
building the kernel, the distribution is, and access to the private
key included in the trusted keyring is, for obvious reason, not
available.
This means that users have no way to enable IPE, since there will
be no built-in generic policy, and no access to the key to sign
updates validated by the trusted keyring.
Just as we do for dm-verity, kernel modules and more, allow the
secondary and platform keyrings to also validate policies. This
allows users enrolling their own keys in UEFI db or MOK to also
sign policies, and enroll them. This makes it sensible to enable
IPE in general purpose distributions, as it becomes usable by
any user wishing to do so. Keys in these keyrings can already
load kernels and kernel modules, so there is no security
downgrade.
Add a kconfig each, like dm-verity does, but default to enabled if
the dependencies are available.
Signed-off-by: Luca Boccassi <bluca@debian.org>
Reviewed-by: Serge Hallyn <serge@hallyn.com>
[FW: fixed some style issues]
Signed-off-by: Fan Wu <wufan@kernel.org>
2024-09-15 09:11:19 +00:00
|
|
|
config IPE_POLICY_SIG_SECONDARY_KEYRING
|
|
|
|
bool "IPE policy update verification with secondary keyring"
|
|
|
|
default y
|
|
|
|
depends on SECONDARY_TRUSTED_KEYRING
|
|
|
|
help
|
|
|
|
Also allow the secondary trusted keyring to verify IPE policy
|
|
|
|
updates.
|
|
|
|
|
|
|
|
If unsure, answer Y.
|
|
|
|
|
|
|
|
config IPE_POLICY_SIG_PLATFORM_KEYRING
|
|
|
|
bool "IPE policy update verification with platform keyring"
|
|
|
|
default y
|
|
|
|
depends on INTEGRITY_PLATFORM_KEYRING
|
|
|
|
help
|
|
|
|
Also allow the platform keyring to verify IPE policy updates.
|
|
|
|
|
|
|
|
If unsure, answer Y.
|
|
|
|
|
2024-08-03 06:08:27 +00:00
|
|
|
menu "IPE Trust Providers"
|
|
|
|
|
|
|
|
config IPE_PROP_DM_VERITY
|
|
|
|
bool "Enable support for dm-verity based on root hash"
|
|
|
|
depends on DM_VERITY
|
|
|
|
help
|
|
|
|
This option enables the 'dmverity_roothash' property within IPE
|
|
|
|
policies. The property evaluates to TRUE when a file from a dm-verity
|
|
|
|
volume is evaluated, and the volume's root hash matches the value
|
|
|
|
supplied in the policy.
|
|
|
|
|
|
|
|
config IPE_PROP_DM_VERITY_SIGNATURE
|
|
|
|
bool "Enable support for dm-verity based on root hash signature"
|
|
|
|
depends on DM_VERITY && DM_VERITY_VERIFY_ROOTHASH_SIG
|
|
|
|
help
|
|
|
|
This option enables the 'dmverity_signature' property within IPE
|
|
|
|
policies. The property evaluates to TRUE when a file from a dm-verity
|
|
|
|
volume, which has been mounted with a valid signed root hash,
|
|
|
|
is evaluated.
|
|
|
|
|
2024-08-03 06:08:30 +00:00
|
|
|
If unsure, answer Y.
|
|
|
|
|
|
|
|
config IPE_PROP_FS_VERITY
|
|
|
|
bool "Enable support for fs-verity based on file digest"
|
|
|
|
depends on FS_VERITY
|
|
|
|
help
|
|
|
|
This option enables the 'fsverity_digest' property within IPE
|
|
|
|
policies. The property evaluates to TRUE when a file is fsverity
|
|
|
|
enabled and its digest matches the supplied digest value in the
|
|
|
|
policy.
|
|
|
|
|
|
|
|
if unsure, answer Y.
|
|
|
|
|
|
|
|
config IPE_PROP_FS_VERITY_BUILTIN_SIG
|
|
|
|
bool "Enable support for fs-verity based on builtin signature"
|
|
|
|
depends on FS_VERITY && FS_VERITY_BUILTIN_SIGNATURES
|
|
|
|
help
|
|
|
|
This option enables the 'fsverity_signature' property within IPE
|
|
|
|
policies. The property evaluates to TRUE when a file is fsverity
|
|
|
|
enabled and it has a valid builtin signature whose signing cert
|
|
|
|
is in the .fs-verity keyring.
|
|
|
|
|
|
|
|
if unsure, answer Y.
|
|
|
|
|
2024-08-03 06:08:27 +00:00
|
|
|
endmenu
|
|
|
|
|
2024-08-03 06:08:32 +00:00
|
|
|
config SECURITY_IPE_KUNIT_TEST
|
|
|
|
bool "Build KUnit tests for IPE" if !KUNIT_ALL_TESTS
|
|
|
|
depends on KUNIT=y
|
|
|
|
default KUNIT_ALL_TESTS
|
|
|
|
help
|
|
|
|
This builds the IPE KUnit tests.
|
|
|
|
|
|
|
|
KUnit tests run during boot and output the results to the debug log
|
|
|
|
in TAP format (https://testanything.org/). Only useful for kernel devs
|
|
|
|
running KUnit test harness and are not for inclusion into a
|
|
|
|
production build.
|
|
|
|
|
|
|
|
For more information on KUnit and unit tests in general please refer
|
|
|
|
to the KUnit documentation in Documentation/dev-tools/kunit/.
|
|
|
|
|
|
|
|
If unsure, say N.
|
|
|
|
|
2024-08-03 06:08:27 +00:00
|
|
|
endif
|