Skip to content

Commit a430d95

Browse files
committed
Merge tag 'lsm-pr-20240911' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm
Pull lsm updates from Paul Moore: - Move the LSM framework to static calls This transitions the vast majority of the LSM callbacks into static calls. Those callbacks which haven't been converted were left as-is due to the general ugliness of the changes required to support the static call conversion; we can revisit those callbacks at a future date. - Add the Integrity Policy Enforcement (IPE) LSM This adds a new LSM, Integrity Policy Enforcement (IPE). There is plenty of documentation about IPE in this patches, so I'll refrain from going into too much detail here, but the basic motivation behind IPE is to provide a mechanism such that administrators can restrict execution to only those binaries which come from integrity protected storage, e.g. a dm-verity protected filesystem. You will notice that IPE requires additional LSM hooks in the initramfs, dm-verity, and fs-verity code, with the associated patches carrying ACK/review tags from the associated maintainers. We couldn't find an obvious maintainer for the initramfs code, but the IPE patchset has been widely posted over several years. Both Deven Bowers and Fan Wu have contributed to IPE's development over the past several years, with Fan Wu agreeing to serve as the IPE maintainer moving forward. Once IPE is accepted into your tree, I'll start working with Fan to ensure he has the necessary accounts, keys, etc. so that he can start submitting IPE pull requests to you directly during the next merge window. - Move the lifecycle management of the LSM blobs to the LSM framework Management of the LSM blobs (the LSM state buffers attached to various kernel structs, typically via a void pointer named "security" or similar) has been mixed, some blobs were allocated/managed by individual LSMs, others were managed by the LSM framework itself. Starting with this pull we move management of all the LSM blobs, minus the XFRM blob, into the framework itself, improving consistency across LSMs, and reducing the amount of duplicated code across LSMs. Due to some additional work required to migrate the XFRM blob, it has been left as a todo item for a later date; from a practical standpoint this omission should have little impact as only SELinux provides a XFRM LSM implementation. - Fix problems with the LSM's handling of F_SETOWN The LSM hook for the fcntl(F_SETOWN) operation had a couple of problems: it was racy with itself, and it was disconnected from the associated DAC related logic in such a way that the LSM state could be updated in cases where the DAC state would not. We fix both of these problems by moving the security_file_set_fowner() hook into the same section of code where the DAC attributes are updated. Not only does this resolve the DAC/LSM synchronization issue, but as that code block is protected by a lock, it also resolve the race condition. - Fix potential problems with the security_inode_free() LSM hook Due to use of RCU to protect inodes and the placement of the LSM hook associated with freeing the inode, there is a bit of a challenge when it comes to managing any LSM state associated with an inode. The VFS folks are not open to relocating the LSM hook so we have to get creative when it comes to releasing an inode's LSM state. Traditionally we have used a single LSM callback within the hook that is triggered when the inode is "marked for death", but not actually released due to RCU. Unfortunately, this causes problems for LSMs which want to take an action when the inode's associated LSM state is actually released; so we add an additional LSM callback, inode_free_security_rcu(), that is called when the inode's LSM state is released in the RCU free callback. - Refactor two LSM hooks to better fit the LSM return value patterns The vast majority of the LSM hooks follow the "return 0 on success, negative values on failure" pattern, however, there are a small handful that have unique return value behaviors which has caused confusion in the past and makes it difficult for the BPF verifier to properly vet BPF LSM programs. This includes patches to convert two of these"special" LSM hooks to the common 0/-ERRNO pattern. - Various cleanups and improvements A handful of patches to remove redundant code, better leverage the IS_ERR_OR_NULL() helper, add missing "static" markings, and do some minor style fixups. * tag 'lsm-pr-20240911' of git://git.kernel.org/pub/scm/linux/kernel/git/pcmoore/lsm: (40 commits) security: Update file_set_fowner documentation fs: Fix file_set_fowner LSM hook inconsistencies lsm: Use IS_ERR_OR_NULL() helper function lsm: remove LSM_COUNT and LSM_CONFIG_COUNT ipe: Remove duplicated include in ipe.c lsm: replace indirect LSM hook calls with static calls lsm: count the LSMs enabled at compile time kernel: Add helper macros for loop unrolling init/main.c: Initialize early LSMs after arch code, static keys and calls. MAINTAINERS: add IPE entry with Fan Wu as maintainer documentation: add IPE documentation ipe: kunit test for parser scripts: add boot policy generation program ipe: enable support for fs-verity as a trust provider fsverity: expose verified fsverity built-in signatures to LSMs lsm: add security_inode_setintegrity() hook ipe: add support for dm-verity as a trust provider dm-verity: expose root hash digest and signature data to LSMs block,lsm: add LSM blob and new LSM hooks for block devices ipe: add permissive toggle ...
2 parents ad060db + 19c9d55 commit a430d95

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

71 files changed

+6062
-483
lines changed

Documentation/admin-guide/LSM/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,3 +47,4 @@ subdirectories.
4747
tomoyo
4848
Yama
4949
SafeSetID
50+
ipe

Documentation/admin-guide/LSM/ipe.rst

Lines changed: 790 additions & 0 deletions
Large diffs are not rendered by default.

Documentation/admin-guide/kernel-parameters.txt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2350,6 +2350,18 @@
23502350
ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V
23512351
IPC identifiers from 32,768 to 16,777,216.
23522352

2353+
ipe.enforce= [IPE]
2354+
Format: <bool>
2355+
Determine whether IPE starts in permissive (0) or
2356+
enforce (1) mode. The default is enforce.
2357+
2358+
ipe.success_audit=
2359+
[IPE]
2360+
Format: <bool>
2361+
Start IPE with success auditing enabled, emitting
2362+
an audit event when a binary is allowed. The default
2363+
is 0.
2364+
23532365
irqaffinity= [SMP] Set the default irq affinity mask
23542366
The argument is a cpu list, as described above.
23552367

Documentation/filesystems/fsverity.rst

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,16 @@ authenticating fs-verity file hashes include:
8686
signature in their "security.ima" extended attribute, as controlled
8787
by the IMA policy. For more information, see the IMA documentation.
8888

89+
- Integrity Policy Enforcement (IPE). IPE supports enforcing access
90+
control decisions based on immutable security properties of files,
91+
including those protected by fs-verity's built-in signatures.
92+
"IPE policy" specifically allows for the authorization of fs-verity
93+
files using properties ``fsverity_digest`` for identifying
94+
files by their verity digest, and ``fsverity_signature`` to authorize
95+
files with a verified fs-verity's built-in signature. For
96+
details on configuring IPE policies and understanding its operational
97+
modes, please refer to :doc:`IPE admin guide </admin-guide/LSM/ipe>`.
98+
8999
- Trusted userspace code in combination with `Built-in signature
90100
verification`_. This approach should be used only with great care.
91101

@@ -457,7 +467,11 @@ Enabling this option adds the following:
457467
On success, the ioctl persists the signature alongside the Merkle
458468
tree. Then, any time the file is opened, the kernel verifies the
459469
file's actual digest against this signature, using the certificates
460-
in the ".fs-verity" keyring.
470+
in the ".fs-verity" keyring. This verification happens as long as the
471+
file's signature exists, regardless of the state of the sysctl variable
472+
"fs.verity.require_signatures" described in the next item. The IPE LSM
473+
relies on this behavior to recognize and label fsverity files
474+
that contain a verified built-in fsverity signature.
461475

462476
3. A new sysctl "fs.verity.require_signatures" is made available.
463477
When set to 1, the kernel requires that all verity files have a
@@ -481,7 +495,7 @@ be carefully considered before using them:
481495

482496
- Builtin signature verification does *not* make the kernel enforce
483497
that any files actually have fs-verity enabled. Thus, it is not a
484-
complete authentication policy. Currently, if it is used, the only
498+
complete authentication policy. Currently, if it is used, one
485499
way to complete the authentication policy is for trusted userspace
486500
code to explicitly check whether files have fs-verity enabled with a
487501
signature before they are accessed. (With
@@ -490,6 +504,15 @@ be carefully considered before using them:
490504
could just store the signature alongside the file and verify it
491505
itself using a cryptographic library, instead of using this feature.
492506

507+
- Another approach is to utilize fs-verity builtin signature
508+
verification in conjunction with the IPE LSM, which supports defining
509+
a kernel-enforced, system-wide authentication policy that allows only
510+
files with a verified fs-verity builtin signature to perform certain
511+
operations, such as execution. Note that IPE doesn't require
512+
fs.verity.require_signatures=1.
513+
Please refer to :doc:`IPE admin guide </admin-guide/LSM/ipe>` for
514+
more details.
515+
493516
- A file's builtin signature can only be set at the same time that
494517
fs-verity is being enabled on the file. Changing or deleting the
495518
builtin signature later requires re-creating the file.

Documentation/security/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,4 @@ Security Documentation
1919
digsig
2020
landlock
2121
secrets/index
22+
ipe

0 commit comments

Comments
 (0)