fsverity: expose verified fsverity built-in signatures to LSMs
This patch enhances fsverity's capabilities to support both integrity and authenticity protection by introducing the exposure of built-in signatures through a new LSM hook. This functionality allows LSMs, e.g. IPE, to enforce policies based on the authenticity and integrity of files, specifically focusing on built-in fsverity signatures. It enables a policy enforcement layer within LSMs for fsverity, offering granular control over the usage of authenticity claims. For instance, a policy could be established to only permit the execution of all files with verified built-in fsverity signatures. The introduction of a security_inode_setintegrity() hook call within fsverity's workflow ensures that the verified built-in signature of a file is exposed to LSMs. This enables LSMs to recognize and label fsverity files that contain a verified built-in fsverity signature. This hook is invoked subsequent to the fsverity_verify_signature() process, guaranteeing the signature's verification against fsverity's keyring. This mechanism is crucial for maintaining system security, as it operates in kernel space, effectively thwarting attempts by malicious binaries to bypass user space stack interactions. The second to last commit in this patch set will add a link to the IPE documentation in fsverity.rst. Signed-off-by: Deven Bowers <deven.desai@linux.microsoft.com> Signed-off-by: Fan Wu <wufan@linux.microsoft.com> Acked-by: Eric Biggers <ebiggers@google.com> Signed-off-by: Paul Moore <paul@paul-moore.com>
This commit is contained in:
parent
fb55e177d5
commit
7c373e4f14
@ -86,6 +86,14 @@ authenticating fs-verity file hashes include:
|
||||
signature in their "security.ima" extended attribute, as controlled
|
||||
by the IMA policy. For more information, see the IMA documentation.
|
||||
|
||||
- Integrity Policy Enforcement (IPE). IPE supports enforcing access
|
||||
control decisions based on immutable security properties of files,
|
||||
including those protected by fs-verity's built-in signatures.
|
||||
"IPE policy" specifically allows for the authorization of fs-verity
|
||||
files using properties ``fsverity_digest`` for identifying
|
||||
files by their verity digest, and ``fsverity_signature`` to authorize
|
||||
files with a verified fs-verity's built-in signature.
|
||||
|
||||
- Trusted userspace code in combination with `Built-in signature
|
||||
verification`_. This approach should be used only with great care.
|
||||
|
||||
@ -457,7 +465,11 @@ Enabling this option adds the following:
|
||||
On success, the ioctl persists the signature alongside the Merkle
|
||||
tree. Then, any time the file is opened, the kernel verifies the
|
||||
file's actual digest against this signature, using the certificates
|
||||
in the ".fs-verity" keyring.
|
||||
in the ".fs-verity" keyring. This verification happens as long as the
|
||||
file's signature exists, regardless of the state of the sysctl variable
|
||||
"fs.verity.require_signatures" described in the next item. The IPE LSM
|
||||
relies on this behavior to recognize and label fsverity files
|
||||
that contain a verified built-in fsverity signature.
|
||||
|
||||
3. A new sysctl "fs.verity.require_signatures" is made available.
|
||||
When set to 1, the kernel requires that all verity files have a
|
||||
@ -481,7 +493,7 @@ be carefully considered before using them:
|
||||
|
||||
- Builtin signature verification does *not* make the kernel enforce
|
||||
that any files actually have fs-verity enabled. Thus, it is not a
|
||||
complete authentication policy. Currently, if it is used, the only
|
||||
complete authentication policy. Currently, if it is used, one
|
||||
way to complete the authentication policy is for trusted userspace
|
||||
code to explicitly check whether files have fs-verity enabled with a
|
||||
signature before they are accessed. (With
|
||||
@ -490,6 +502,13 @@ be carefully considered before using them:
|
||||
could just store the signature alongside the file and verify it
|
||||
itself using a cryptographic library, instead of using this feature.
|
||||
|
||||
- Another approach is to utilize fs-verity builtin signature
|
||||
verification in conjunction with the IPE LSM, which supports defining
|
||||
a kernel-enforced, system-wide authentication policy that allows only
|
||||
files with a verified fs-verity builtin signature to perform certain
|
||||
operations, such as execution. Note that IPE doesn't require
|
||||
fs.verity.require_signatures=1.
|
||||
|
||||
- A file's builtin signature can only be set at the same time that
|
||||
fs-verity is being enabled on the file. Changing or deleting the
|
||||
builtin signature later requires re-creating the file.
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <linux/cred.h>
|
||||
#include <linux/key.h>
|
||||
#include <linux/security.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/verification.h>
|
||||
|
||||
@ -41,7 +42,11 @@ static struct key *fsverity_keyring;
|
||||
* @sig_size: size of signature in bytes, or 0 if no signature
|
||||
*
|
||||
* If the file includes a signature of its fs-verity file digest, verify it
|
||||
* against the certificates in the fs-verity keyring.
|
||||
* against the certificates in the fs-verity keyring. Note that signatures
|
||||
* are verified regardless of the state of the 'fsverity_require_signatures'
|
||||
* variable and the LSM subsystem relies on this behavior to help enforce
|
||||
* file integrity policies. Please discuss changes with the LSM list
|
||||
* (thank you!).
|
||||
*
|
||||
* Return: 0 on success (signature valid or not required); -errno on failure
|
||||
*/
|
||||
@ -106,6 +111,17 @@ int fsverity_verify_signature(const struct fsverity_info *vi,
|
||||
return err;
|
||||
}
|
||||
|
||||
err = security_inode_setintegrity(inode,
|
||||
LSM_INT_FSVERITY_BUILTINSIG_VALID,
|
||||
signature,
|
||||
sig_size);
|
||||
|
||||
if (err) {
|
||||
fsverity_err(inode, "Error %d exposing file signature to LSMs",
|
||||
err);
|
||||
return err;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -92,6 +92,7 @@ struct dm_verity_digest {
|
||||
enum lsm_integrity_type {
|
||||
LSM_INT_DMVERITY_SIG_VALID,
|
||||
LSM_INT_DMVERITY_ROOTHASH,
|
||||
LSM_INT_FSVERITY_BUILTINSIG_VALID,
|
||||
};
|
||||
|
||||
/*
|
||||
|
Loading…
Reference in New Issue
Block a user