Integrity Policy Enforcement LSM (IPE)
Subsystems (11)
v19 cover Integrity Policy Enforcement LSM (IPE)
IPE is a Linux Security Module that takes a complementary approach to access control. Unlike traditional access control mechanisms that rely on labels and paths for decision-making, IPE focuses on the immutable security properties inherent to system components. These properties are fundamental attributes or features of a system component that cannot be altered, ensuring a consistent and reliable basis for security decisions.
To elaborate, in the context of IPE, system components primarily refer to files or the devices these files reside on. However, this is just a starting point. The concept of system components is flexible and can be extended to include new elements as the system evolves. The immutable properties include the origin of a file, which remains constant and unchangeable over time. For example, IPE policies can be crafted to trust files originating from the initramfs. Since initramfs is typically verified by the bootloader, its files are deemed trustworthy; "file is from initramfs" becomes an immutable property under IPE's consideration.
The immutable property concept extends to the security features enabled on a file's origin, such as dm-verity or fs-verity, which provide a layer of integrity and trust. For example, IPE allows the definition of policies that trust files from a dm-verity protected device. dm-verity ensures the integrity of an entire device by providing a verifiable and immutable state of its contents. Similarly, fs-verity offers filesystem-level integrity checks, allowing IPE to enforce policies that trust files protected by fs-verity. These two features cannot be turned off once established, so they are considered immutable properties. These examples demonstrate how IPE leverages immutable properties, such as a file's origin and its integrity protection mechanisms, to make access control decisions.
For the IPE policy, specifically, it grants the ability to enforce stringent access controls by assessing security properties against reference values defined within the policy. This assessment can be based on the existence of a security property (e.g., verifying if a file originates from initramfs) or evaluating the internal state of an immutable security property. The latter includes checking the roothash of a dm-verity protected device, determining whether dm-verity possesses a valid signature, assessing the digest of a fs-verity protected file, or determining whether fs-verity possesses a valid built-in signature. This nuanced approach to policy enforcement enables a highly secure and customizable system defense mechanism, tailored to specific security requirements and trust models.
IPE is compiled under CONFIG_SECURITY_IPE.
Use Cases
---------
IPE works best in fixed-function devices: Devices in which their purpose is clearly defined and not supposed to be changed (e.g. network firewall device in a data center, an IoT device, etcetera), where all software and configuration is built and provisioned by the system owner.
IPE is a long-way off for use in general-purpose computing: the Linux community as a whole tends to follow a decentralized trust model, known as the web of trust, which IPE has no support for as of yet. There are exceptions, such as the case where a Linux distribution vendor trusts only their own keys, where IPE can successfully be used to enforce the trust requirement.
Additionally, while most packages are signed today, the files inside the packages (for instance, the executables), tend to be unsigned. This makes it difficult to utilize IPE in systems where a package manager is expected to be functional, without major changes to the package manager and ecosystem behind it.
The digest_cache LSM[1] is a system that when combined with IPE, could be used to enable general purpose computing scenarios.
Policy
-------
IPE policy is a plain-text policy composed of multiple statements over several lines. There is one required line, at the top of the policy, indicating the policy name, and the policy version, for instance:
policy_name=Ex_Policy policy_version=0.0.0
The policy version indicates the current version of the policy. This is used to prevent roll-back of policy to potentially insecure previous versions of the policy.
The next portion of IPE policy, are rules. Rules are formed by key=value pairs, known as properties. IPE rules require two keys: "action", which determines what IPE does when it encounters a match against the policy and "op", which determines when that rule should be evaluated.
Thus, a minimal rule is:
op=EXECUTE action=ALLOW
This example rule will allow any execution. A rule is required to have the "op" property as the first token of a rule, and the "action" as the last token of the rule.
Additional properties are used to assess immutable security properties about the files being evaluated. These properties are intended to be deterministic attributes that are resident in the kernel.
For example:
op=EXECUTE dmverity_signature=FALSE action=DENY
This rule with property dmverity_signature will deny any file not from a signed dmverity volume to be executed.
All available properties for IPE described in the documentation patch of this series.
Rules are evaluated top-to-bottom. As a result, any revocation rules, or denies should be placed early in the file to ensure that these rules are evaluated before a rule with "action=ALLOW" is hit.
Any unknown syntax in IPE policy will result in a fatal error to parse the policy.
Additionally, a DEFAULT operation must be set for all understood operations within IPE. For policies to remain completely forwards compatible, it is recommended that users add a "DEFAULT action=ALLOW" and override the defaults on a per-operation basis.
For more information about the policy syntax, see the kernel documentation page.
Early Usermode Protection
--------------------------
IPE can be provided with a policy at startup to load and enforce. This is intended to be a minimal policy to get the system to a state where userspace is setup and ready to receive commands, at which point a policy can be deployed via securityfs. This "boot policy" can be specified via the config, SECURITY_IPE_BOOT_POLICY, which accepts a path to a plain-text version of the IPE policy to apply. This policy will be compiled into the kernel. If not specified, IPE will be disabled until a policy is deployed and activated through the method above.
Policy Examples
----------------
Allow all:
policy_name=Allow_All policy_version=0.0.0
DEFAULT action=ALLOW
Allow only initramfs:
policy_name=Allow_Initramfs policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE boot_verified=TRUE action=ALLOW
Allow any signed and validated dm-verity volume and the initramfs:
policy_name=Allow_Signed_DMV_And_Initramfs policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE boot_verified=TRUE action=ALLOW
op=EXECUTE dmverity_signature=TRUE action=ALLOW
Prohibit execution from a specific dm-verity volume, while allowing all signed volumes and the initramfs:
policy_name=Deny_DMV_By_Roothash policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE dmverity_roothash=sha256:cd2c5bae7c6c579edaae4353049d58eb5f2e8be0244bf05345bc8e5ed257baff action=DENY
op=EXECUTE boot_verified=TRUE action=ALLOW
op=EXECUTE dmverity_signature=TRUE action=ALLOW
Allow only a specific dm-verity volume:
policy_name=Allow_DMV_By_Roothash policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE dmverity_roothash=sha256:401fcec5944823ae12f62726e8184407a5fa9599783f030dec146938 action=ALLOW
Allow any fs-verity file with a valid built-in signature:
policy_name=Allow_Signed_And_Validated_FSVerity policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE fsverity_signature=TRUE action=ALLOW
Allow execution of a specific fs-verity file:
policy_name=ALLOW_FSV_By_Digest policy_version=0.0.0 DEFAULT action=DENY
op=EXECUTE fsverity_digest=sha256:fd88f2b8824e197f850bf4c5109bea5cf0ee38104f710843bb72da796ba5af9e action=ALLOW
Deploying Policies
-------------------
First sign a plain text policy, with a certificate that is present in the SYSTEM_TRUSTED_KEYRING of your test machine. Through openssl, the signing can be done via:
openssl smime -sign -in "$MY_POLICY" -signer "$MY_CERTIFICATE" \
-inkey "$MY_PRIVATE_KEY" -outform der -noattr -nodetach \
-out "$MY_POLICY.p7s"Then, simply cat the file into the IPE's "new_policy" securityfs node:
cat "$MY_POLICY.p7s" > /sys/kernel/security/ipe/new_policy
The policy should now be present under the policies/ subdirectory, under its "policy_name" attribute.
The policy is now present in the kernel and can be marked as active, via the securityfs node:
echo 1 > "/sys/kernel/security/ipe/$MY_POLICY_NAME/active"
This will now mark the policy as active and the system will be enforcing $MY_POLICY_NAME.
There is one requirement when marking a policy as active, the policy_version attribute must either increase, or remain the same as the currently running policy.
Policies can be updated via:
cat "$MY_UPDATED_POLICY.p7s" > \
"/sys/kernel/security/ipe/policies/$MY_POLICY_NAME/update"Additionally, policies can be deleted via the "delete" securityfs node. Simply write "1" to the corresponding node in the policy folder:
echo 1 > "/sys/kernel/security/ipe/policies/$MY_POLICY_NAME/delete"
There is only one requirement to delete policies, the policy being deleted must not be the active policy.
NOTE: Any securityfs write to IPE's nodes will require CAP_MAC_ADMIN.
Integrations
-------------
This patch series adds support for fsverity via digest and signature (fsverity_signature and fsverity_digest), dm-verity by digest and signature (dmverity_signature and dmverity_roothash), and trust for the initramfs (boot_verified).
Please see the documentation patch for more information about the integrations available.
Testing
--------
KUnit Tests are available. Recommended kunitconfig:
CONFIG_KUNIT=y
CONFIG_SECURITY=y
CONFIG_SECURITYFS=y
CONFIG_PKCS7_MESSAGE_PARSER=y
CONFIG_SYSTEM_DATA_VERIFICATION=y
CONFIG_FS_VERITY=y
CONFIG_FS_VERITY_BUILTIN_SIGNATURES=y
CONFIG_BLOCK=y
CONFIG_MD=y
CONFIG_BLK_DEV_DM=y
CONFIG_DM_VERITY=y
CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG=y
CONFIG_NET=y
CONFIG_AUDIT=y
CONFIG_AUDITSYSCALL=y
CONFIG_BLK_DEV_INITRD=y
CONFIG_SECURITY_IPE=y
CONFIG_IPE_PROP_DM_VERITY=y
CONFIG_IPE_PROP_DM_VERITY_SIGNATURE=y
CONFIG_IPE_PROP_FS_VERITY=y
CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG=y
CONFIG_SECURITY_IPE_KUNIT_TEST=y
Simply run:
make ARCH=um mrproper
./tools/testing/kunit/kunit.py run --kunitconfig <path/to/config>
And the tests will execute and report the result.
In addition, IPE has a python based integration
test suite https://github.com/microsoft/ipe/tree/test-suite that can test both user interfaces and enforcement functionalities.
Documentation
--------------
There is both documentation available on github at
https://microsoft.github.io/ipe, and Documentation in this patch series, to be added in-tree.
Known Gaps
-----------
IPE has two known gaps:
1. IPE cannot verify the integrity of anonymous executable memory, such as the trampolines created by gcc closures and libffi (<3.4.2), or JIT'd code. Unfortunately, as this is dynamically generated code, there is no way for IPE to ensure the integrity of this code to form a trust basis. In all cases, the return result for these operations will be whatever the admin configures the DEFAULT action for "EXECUTE".
2. IPE cannot verify the integrity of interpreted languages' programs when these scripts invoked via ``<interpreter> <file>``. This is because the way interpreters execute these files, the scripts themselves are not evaluated as executable code through one of IPE's hooks. Interpreters can be enlightened to the usage of IPE by trying to mmap a file into executable memory (+X), after opening the file and responding to the error code appropriately. This also applies to included files, or high value files, such as configuration files of critical system components.
Appendix
---------
A. IPE Github Repository: https://github.com/microsoft/ipe
B. IPE Users' Guide: Documentation/admin-guide/LSM/ipe.rst
References
-----------
1: https://lore.kernel.org/lkml/[email protected]/
FAQ:
----
Q: What is the difference between IMA and IPE?
A: See the documentation patch for more on this topic.
Previous Postings
-----------------
v1: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v3: https://lore.kernel.org/all/[email protected]/
v4: https://lore.kernel.org/all/[email protected]/
v5: https://lore.kernel.org/all/[email protected]/
v6: https://lore.kernel.org/all/[email protected]/
v7: https://lore.kernel.org/all/1634151995-16266-1-git-send-email-deven.desai@linux.microsoft.com/
v8: https://lore.kernel.org/all/1654714889-26728-1-git-send-email-deven.desai@linux.microsoft.com/
v9: https://lore.kernel.org/lkml/[email protected]/
v10: https://lore.kernel.org/lkml/[email protected]/
v11: https://lore.kernel.org/lkml/[email protected]/
v12: https://lore.kernel.org/lkml/[email protected]/
v13: https://lore.kernel.org/lkml/[email protected]/
v14: https://lore.kernel.org/lkml/[email protected]/
v15: https://lore.kernel.org/lkml/[email protected]/
v16: https://lore.kernel.org/lkml/[email protected]/
v17: https://lore.kernel.org/lkml/[email protected]/
v18: https://lore.kernel.org/lkml/[email protected]/
Changelog
----------
v2:
Split the second patch of the previous series into two. Minor corrections in the cover-letter and documentation comments regarding CAP_MAC_ADMIN checks in IPE.
v3:
Address various comments by Jann Horn. Highlights:
Switch various audit allocators to GFP_KERNEL. Utilize rcu_access_pointer() in various locations. Strip out the caching system for properties
Strip comments from headers
Move functions around in patches
Remove kernel command line parameters
Reconcile the race condition on the delete node for policy by
expanding the policy critical section.
Address a few comments by Jonathan Corbet around the documentation
pages for IPE.
Fix an issue with the initialization of IPE policy with a "-0"
version, caused by not initializing the hlist entries before freeing.
v4:
Address a concern around IPE's behavior with unknown syntax.
Specifically, make any unknown syntax a fatal error instead of a warning, as suggested by Mickaël Salaün.
Introduce a new securityfs node, $securityfs/ipe/property_config,
which provides a listing of what properties are enabled by the kernel and their versions. This allows usermode to predict what policies should be allowed.
Strip some comments from c files that I missed.
Clarify some documentation comments around 'boot_verified'.
While this currently does not functionally change the property itself, the distinction is important when IPE can enforce verified reads. Additionally, 'KERNEL_READ' was omitted from the documentation. This has been corrected.
Change SecurityFS and SHA1 to a reverse dependency.
Update the cover-letter with the updated behavior of unknown syntax. Remove all sysctls, making an equivalent function in securityfs. Rework the active/delete mechanism to be a node under the policy in
$securityfs/ipe/policies.
The kernel command line parameters ipe.enforce and ipe.success_audit
have returned as this functionality is no longer exposed through sysfs.
v5:
Correct some grammatical errors reported by Randy Dunlap. Fix some warnings reported by kernel test bot.
Change convention around security_bdev_setsecurity. -ENOSYS
is now expected if an LSM does not implement a particular @name, as suggested by Casey Schaufler.
Minor string corrections related to the move from sysfs to securityfs Correct a spelling of an #ifdef for the permissive argument. Add the kernel parameters re-added to the documentation. Fix a minor bug where the mode being audited on permissive switch
was the original mode, not the mode being swapped to.
Cleanup doc comments, fix some whitespace alignment issues.
v6:
Change if statement condition in security_bdev_setsecurity to be
more concise, as suggested by Casey Schaufler and Al Viro
Drop the 6th patch in the series, "dm-verity move signature check..."
due to numerous issues, and it ultimately providing no real value.
Fix the patch tree - the previous iteration appears to have been in a
torn state (patches 8+9 were merged). This has since been corrected.
v7:
* Reword cover letter to more accurate convey IPE's purpose and latest updates.
* Refactor series to:
1. Support a context structure, enabling:
1. Easier Testing via KUNIT
2. A better architecture for future designs
2. Make parser code cleaner
* Move patch 01/12 to [14/16] of the series
* Split up patch 02/12 into four parts:
1. context creation [01/16]
2. audit [07/16]
3. evaluation loop [03/16]
4. access control hooks [05/16]
5. permissive mode [08/16]
* Split up patch 03/12 into two parts:
1. parser [02/16]
2. userspace interface [04/16]
* Reword and refactor patch 04/12 to [09/16]
* Squash patch 05/12, 07/12, 09/12 to [10/16]
* Squash patch 08/12, 10/12 to [11/16]
* Change audit records to MAC region (14XX) from Integrity region (18XX)
* Add FSVerity Support
* Interface changes:
1. "raw" was renamed to "pkcs7" and made read only
2. "raw"'s write functionality (update a policy) moved to "update"
3. introduced "version", "policy_name" nodes.
4. "content" renamed to "policy"
5. The boot policy can now be updated like any other policy.
* Add additional developer-level documentation
* Update admin-guide docs to reflect changes.
* Kunit tests
* Dropped CONFIG_SECURITY_IPE_PERMISSIVE_SWITCH - functionality can easily come later with a small patch.
* Use partition0 for block_device for dm-verity patch
v8:
* Add changelog information to individual commits
* A large number of changes to the audit patch.
* split fs/ & security/ changes to two separate patches.
* split block/, security/ & drivers/md/ changes to separate patches.
* Add some historical context to what lead to the creation of IPE in the documentation patch.
* Cover-letter changes suggested by Roberto Sassu.
v9:
* Rewrite IPE parser to use kernel match_table parser.
* Adapt existing IPE properties to the new parser.
* Remove ipe_context, quote policy syntax, kernel_read for simplicity.
* Add new function in the security file system to delete IPE policy.
* Make IPE audit builtin and change several audit formats.
* Make boot_verified property builtin
v10:
* Address various code style/format issues
* Correct the rcu locking for active policy
* Fix memleak bugs in the parser, optimize the parser per upstream feedback
* Adding new audit events for IPE and update audit formats
* Make the dmverity property auto selected
* Adding more context in the commit messages
v11:
* Address various code style/format issues
* Add finalize hook to device mapper
* move the security hook for dm-verity to the new device mapper finalize hook
v12:
* Address locking issues
* Change the implementation of boot_verified to trust initramfs only
* Update audit format for IPE decision events
* Refactor code for lsm_id
* Add IPE test suite link
v13:
* Rename the new security hook in initramfs
* Make the policy grammar independent of kernel config
* Correct IPE audit format
* Refactor policy update code
v14:
* Add more code comments/docs for dmverity/fsverity
* Fix incorrect code usage and format in dmverity
* Drop one accepted commit of dmverity
v15:
* Fix grammar issues
* Add more documentation to fsverity
* Switch security hooks from *_setsecurity() to *_setintegrity()
* Cleanup unnecessary headers
v16:
* Fix format issues, refactor names
* Further improve documentation for fsverity
* Fix bugs in dmverity implementation
* Switch to use call_int_hook() for *_setintegrity()
v17:
* Fix various code/Documentation style issues
* Switch to use reverse christmas tree style
* add ipe_ prefix to all non-static functions
* Correct documentation for fsverity
* Rewrite design concept part of IPE Documentation
* Fix incorrect interface path in IPE Documentation
v18:
* Add two new kconfigs and make them auto-selected
* Fix incorrect error handling and switch to use crypto_ahash_alg_name() in dmverity
* Move the inode_setintegrity hook call into fsverity_verify_signature() in fsverity
* Fix typos and cleanup unnecessary code
* Improve policy examples inside documentation
* Remove insecure hash algorithms and adapt the documentation accordingly
* Update the documentation regarding the new Kconfig switches
v19:
* Drop the finalize dm callback and switch to preresume callback for dm-verity
* Adding NULL check before kmemdup dm-verity roothash signature
* Refactor inode_setintegrity hook and cleanup related code
* Fix documentation warning and format issues
Deven Bowers (13):
security: add ipe lsm
ipe: add policy parser
ipe: add evaluation loop
ipe: add LSM hooks on execution and kernel read
ipe: add userspace interface
uapi|audit|ipe: add ipe auditing support
ipe: add permissive toggle
block,lsm: add LSM blob and new LSM hooks for block device dm verity: expose root hash digest and signature data to LSMs
ipe: add support for dm-verity as a trust provider
scripts: add boot policy generation program
ipe: kunit test for parser
Documentation: add ipe documentation
Fan Wu (7):
initramfs|security: Add a security hook to do_populate_rootfs()
ipe: introduce 'boot_verified' as a trust provider
security: add new securityfs delete function
security: add security_inode_setintegrity() hook
fsverity: expose verified fsverity built-in signatures to LSMs
ipe: enable support for fs-verity as a trust provider
MAINTAINERS: ipe: add ipe maintainer information
Documentation/admin-guide/LSM/index.rst | 1 + Documentation/admin-guide/LSM/ipe.rst | 792 ++++++++++++++++++ .../admin-guide/kernel-parameters.txt | 12 + Documentation/filesystems/fsverity.rst | 27 +- Documentation/security/index.rst | 1 + Documentation/security/ipe.rst | 446 ++++++++++ MAINTAINERS | 10 + block/bdev.c | 7 + drivers/md/dm-verity-target.c | 108 +++ drivers/md/dm-verity.h | 6 + fs/verity/signature.c | 18 +- include/linux/blk_types.h | 3 + include/linux/lsm_hook_defs.h | 9 + include/linux/lsm_hooks.h | 1 + include/linux/security.h | 53 ++ include/uapi/linux/audit.h | 3 + include/uapi/linux/lsm.h | 1 + init/initramfs.c | 3 + scripts/Makefile | 1 + scripts/ipe/Makefile | 2 + scripts/ipe/polgen/.gitignore | 2 + scripts/ipe/polgen/Makefile | 5 + scripts/ipe/polgen/polgen.c | 145 ++++ security/Kconfig | 11 +- security/Makefile | 1 + security/inode.c | 25 + security/ipe/.gitignore | 2 + security/ipe/Kconfig | 97 +++ security/ipe/Makefile | 31 + security/ipe/audit.c | 279 ++++++ security/ipe/audit.h | 19 + security/ipe/digest.c | 118 +++ security/ipe/digest.h | 26 + security/ipe/eval.c | 394 +++++++++ security/ipe/eval.h | 70 ++ security/ipe/fs.c | 247 ++++++ security/ipe/fs.h | 16 + security/ipe/hooks.c | 315 +++++++ security/ipe/hooks.h | 52 ++ security/ipe/ipe.c | 99 +++ security/ipe/ipe.h | 26 + security/ipe/policy.c | 229 +++++ security/ipe/policy.h | 98 +++ security/ipe/policy_fs.c | 470 +++++++++++ security/ipe/policy_parser.c | 556 ++++++++++++ security/ipe/policy_parser.h | 11 + security/ipe/policy_tests.c | 296 +++++++ security/security.c | 122 ++- .../selftests/lsm/lsm_list_modules_test.c | 3 + 49 files changed, 5260 insertions(+), 9 deletions(-) create mode 100644 Documentation/admin-guide/LSM/ipe.rst create mode 100644 Documentation/security/ipe.rst create mode 100644 scripts/ipe/Makefile create mode 100644 scripts/ipe/polgen/.gitignore create mode 100644 scripts/ipe/polgen/Makefile create mode 100644 scripts/ipe/polgen/polgen.c create mode 100644 security/ipe/.gitignore create mode 100644 security/ipe/Kconfig create mode 100644 security/ipe/Makefile create mode 100644 security/ipe/audit.c create mode 100644 security/ipe/audit.h create mode 100644 security/ipe/digest.c create mode 100644 security/ipe/digest.h create mode 100644 security/ipe/eval.c create mode 100644 security/ipe/eval.h create mode 100644 security/ipe/fs.c create mode 100644 security/ipe/fs.h create mode 100644 security/ipe/hooks.c create mode 100644 security/ipe/hooks.h create mode 100644 security/ipe/ipe.c create mode 100644 security/ipe/ipe.h create mode 100644 security/ipe/policy.c create mode 100644 security/ipe/policy.h create mode 100644 security/ipe/policy_fs.c create mode 100644 security/ipe/policy_parser.c create mode 100644 security/ipe/policy_parser.h create mode 100644 security/ipe/policy_tests.c
--
2.44.0
PATCH v19 1/20 security: add ipe lsm
From: Deven Bowers <[email protected]>
Integrity Policy Enforcement (IPE) is an LSM that provides an complimentary approach to Mandatory Access Control than existing LSMs today.
Existing LSMs have centered around the concept of access to a resource should be controlled by the current user's credentials. IPE's approach, is that access to a resource should be controlled by the system's trust of a current resource.
The basis of this approach is defining a global policy to specify which resource can be trusted.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move ipe_load_properties to patch 04.
+ Remove useless 0-initializations
+ Prefix extern variables with ipe_
+ Remove kernel module parameters, as these are exposed through sysctls.
+ Add more prose to the IPE base config option help text.
+ Use GFP_KERNEL for audit_log_start.
+ Remove unnecessary caching system.
+ Remove comments from headers
+ Use rcu_access_pointer for rcu-pointer null check
+ Remove usage of reqprot; use prot only.
+ Move policy load and activation audit event to 03/12
v4:
+ Remove sysctls in favor of securityfs nodes
+ Re-add kernel module parameters, as these are now exposed through securityfs.
+ Refactor property audit loop to a separate function.
v5:
+ fix minor grammatical errors
+ do not group rule by curly-brace in audit record, reconstruct the exact rule.
v6:
+ No changes
v7:
+ Further split lsm creation into a separate commit from the evaluation loop and audit system, for easier review.
+ Introduce the concept of an ipe_context, a scoped way to introduce execution policies, used initially for allowing for kunit tests in isolation.
v8:
+ Follow lsmname_hook_name convention for lsm hooks.
+ Move LSM blob accessors to ipe.c and mark LSM blobs as static.
v9:
+ Remove ipe_context for simplification
v10:
+ Add github url
v11:
+ Correct github url
+ Move ipe before bpf
v12:
+ Switch to use lsm_id instead of string for lsm name
v13:
+ No changes
v14:
+ No changes
v15:
+ Add missing code in tools/testing/selftests/lsm/lsm_list_modules_test.c
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- include/uapi/linux/lsm.h | 1 + security/Kconfig | 11 ++--- security/Makefile | 1 + security/ipe/Kconfig | 17 ++++++++ security/ipe/Makefile | 9 ++++ security/ipe/ipe.c | 42 +++++++++++++++++++ security/ipe/ipe.h | 16 +++++++ security/security.c | 3 +- .../selftests/lsm/lsm_list_modules_test.c | 3 ++ 9 files changed, 97 insertions(+), 6 deletions(-) create mode 100644 security/ipe/Kconfig create mode 100644 security/ipe/Makefile create mode 100644 security/ipe/ipe.c create mode 100644 security/ipe/ipe.h
include/uapi/linux/lsm.h +1 -0
@@ -64,6 +64,7 @@ struct lsm_ctx {#define LSM_ID_LANDLOCK 110#define LSM_ID_IMA 111#define LSM_ID_EVM 112 +#define LSM_ID_IPE 113/* * LSM_ATTR_XXX definitions identify different LSM attributes
security/Kconfig +6 -5
@@ -192,6 +192,7 @@ source "security/yama/Kconfig" source "security/safesetid/Kconfig" source "security/lockdown/Kconfig" source "security/landlock/Kconfig" +source "security/ipe/Kconfig" source "security/integrity/Kconfig"
@@ -231,11 +232,11 @@ endchoice config LSM string "Ordered list of enabled LSMs" - default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,bpf" if DEFAULT_SECURITY_SMACK - default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,bpf" if DEFAULT_SECURITY_APPARMOR - default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,bpf" if DEFAULT_SECURITY_TOMOYO - default "landlock,lockdown,yama,loadpin,safesetid,bpf" if DEFAULT_SECURITY_DAC - default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,bpf" + default "landlock,lockdown,yama,loadpin,safesetid,smack,selinux,tomoyo,apparmor,ipe,bpf" if DEFAULT_SECURITY_SMACK + default "landlock,lockdown,yama,loadpin,safesetid,apparmor,selinux,smack,tomoyo,ipe,bpf" if DEFAULT_SECURITY_APPARMOR + default "landlock,lockdown,yama,loadpin,safesetid,tomoyo,ipe,bpf" if DEFAULT_SECURITY_TOMOYO + default "landlock,lockdown,yama,loadpin,safesetid,ipe,bpf" if DEFAULT_SECURITY_DAC + default "landlock,lockdown,yama,loadpin,safesetid,selinux,smack,tomoyo,apparmor,ipe,bpf" help A comma-separated list of LSMs, in initialization order. Any LSMs left off this list, except for those with order
security/Makefile +1 -0
@@ -25,6 +25,7 @@ obj-$(CONFIG_SECURITY_LOCKDOWN_LSM) += lockdown/ obj-$(CONFIG_CGROUPS) += device_cgroup.o obj-$(CONFIG_BPF_LSM) += bpf/ obj-$(CONFIG_SECURITY_LANDLOCK) += landlock/ +obj-$(CONFIG_SECURITY_IPE) += ipe/ # Object integrity file lists obj-$(CONFIG_INTEGRITY) += integrity/
security/ipe/Kconfig new file +17 -0
@@ -0,0 +1,17 @@ +# SPDX-License-Identifier: GPL-2.0-only +# +# Integrity Policy Enforcement (IPE) configuration +# + +menuconfig SECURITY_IPE + bool "Integrity Policy Enforcement (IPE)" + depends on SECURITY && SECURITYFS + select PKCS7_MESSAGE_PARSER + select SYSTEM_DATA_VERIFICATION + 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.
security/ipe/Makefile new file +9 -0
@@ -0,0 +1,9 @@ +# SPDX-License-Identifier: GPL-2.0 +# +# Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +# +# Makefile for building the IPE module as part of the kernel tree. +# + +obj-$(CONFIG_SECURITY_IPE) += \ + ipe.o \
security/ipe/ipe.c new file +42 -0
42 lines not on this page · raw message
security/ipe/ipe.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ + +#ifndef _IPE_H +#define _IPE_H + +#ifdef pr_fmt +#undef pr_fmt +#endif +#define pr_fmt (fmt) "ipe: " fmt + +#include <linux/lsm_hooks.h> + +#endif /* _IPE_H */
security/security.c +2 -1
@@ -51,7 +51,8 @@ (IS_ENABLED (CONFIG_BPF_LSM ) ?1 :0 ) + \ (IS_ENABLED (CONFIG_SECURITY_LANDLOCK ) ?1 :0 ) + \ (IS_ENABLED (CONFIG_IMA ) ?1 :0 ) + \ - (IS_ENABLED(CONFIG_EVM) ? 1 : 0)) + (IS_ENABLED (CONFIG_EVM ) ?1 :0 ) + \ + (IS_ENABLED(CONFIG_SECURITY_IPE) ? 1 : 0))/* * These are descriptions of the reasons that can be passed to the
tools/testing/selftests/lsm/lsm_list_modules_test.c +3 -0
@@ -128,6 +128,9 @@ TEST(correct_lsm_list_modules)case LSM_ID_EVM : name ="evm" ;break ; +case LSM_ID_IPE : + name ="ipe" ; +break ;default : name ="INVALID" ;break ;
Signature · 1 line
2.44.0
PATCH v19 2/20 ipe: add policy parser
In reply to Fan WuFrom: Deven Bowers <[email protected]>
IPE's interpretation of the what the user trusts is accomplished through its policy. IPE's design is to not provide support for a single trust provider, but to support multiple providers to enable the end-user to choose the best one to seek their needs.
This requires the policy to be rather flexible and modular so that integrity providers, like fs-verity, dm-verity, dm-integrity, or some other system, can plug into the policy with minimal code changes.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move policy load and activation audit event to 03/12
+ Fix a potential panic when a policy failed to load.
+ use pr_warn for a failure to parse instead of an audit record
+ Remove comments from headers
+ Add lockdep assertions to ipe_update_active_policy and ipe_activate_policy
+ Fix up warnings with checkpatch --strict
+ Use file_ns_capable for CAP_MAC_ADMIN for securityfs nodes.
+ Use memdup_user instead of kzalloc+simple_write_to_buffer.
+ Remove strict_parse command line parameter, as it is added by the sysctl command line.
+ Prefix extern variables with ipe_
v4:
+ Remove securityfs to reverse-dependency
+ Add SHA1 reverse dependency.
+ Add versioning scheme for IPE properties, and associated interface to query the versioning scheme.
+ Cause a parser to always return an error on unknown syntax.
+ Remove strict_parse option
+ Change active_policy interface from sysctl, to securityfs, and change scheme.
v5:
+ Cause an error if a default action is not defined for each operation.
+ Minor function renames
v6:
+ No changes
v7:
+ Further split parser and userspace interface into two separate commits, for easier review.
+ Refactor policy parser to make code cleaner via introducing a more modular design, for easier extension of policy, and easier review.
v8:
+ remove unnecessary pr_info emission on parser loading
+ add explicit newline to the pr_err emitted when a parser fails to load.
v9:
+ switch to match table to parse policy
+ remove quote syntax and KERNEL_READ operation
v10:
+ Fix memory leaks in parser
+ Fix typos and change code styles
v11:
+ Fix code style issues
v12:
+ Add __always_unused to an unused parameter
+ Simplify error case handling
v13:
+ No changes
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/Makefile | 2 + security/ipe/policy.c | 103 ++++++++ security/ipe/policy.h | 83 ++++++ security/ipe/policy_parser.c | 495 +++++++++++++++++++++++++++++++++++ security/ipe/policy_parser.h | 11 + 5 files changed, 694 insertions(+) create mode 100644 security/ipe/policy.c create mode 100644 security/ipe/policy.h create mode 100644 security/ipe/policy_parser.c create mode 100644 security/ipe/policy_parser.h
security/ipe/Makefile +2 -0
@@ -7,3 +7,5 @@ obj-$(CONFIG_SECURITY_IPE) += \ ipe.o \ + policy.o \ + policy_parser.o \
security/ipe/policy.c new file +103 -0
103 lines not on this page · raw message
security/ipe/policy.h new file +83 -0
83 lines not on this page · raw message
security/ipe/policy_parser.c new file +495 -0
495 lines not on this page · raw message
security/ipe/policy_parser.h new file +11 -0
@@ -0,0 +1,11 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ +#ifndef _IPE_POLICY_PARSER_H +#define _IPE_POLICY_PARSER_H + +int ipe_parse_policy (struct ipe_policy *p); +void ipe_free_parsed_policy (struct ipe_parsed_policy *p); + +#endif /* _IPE_POLICY_PARSER_H */
Signature · 1 line
2.44.0
PATCH v19 3/20 ipe: add evaluation loop
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Introduce a core evaluation function in IPE that will be triggered by various security hooks (e.g., mmap, bprm_check, kexec). This function systematically assesses actions against the defined IPE policy, by iterating over rules specific to the action being taken. This critical addition enables IPE to enforce its security policies effectively, ensuring that actions intercepted by these hooks are scrutinized for policy compliance before they are allowed to proceed.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move ipe_load_properties to patch 04.
+ Remove useless 0-initializations Prefix extern variables with ipe_
+ Remove kernel module parameters, as these are exposed through sysctls.
+ Add more prose to the IPE base config option help text.
+ Use GFP_KERNEL for audit_log_start.
+ Remove unnecessary caching system.
+ Remove comments from headers
+ Use rcu_access_pointer for rcu-pointer null check
+ Remove usage of reqprot; use prot only.
+Move policy load and activation audit event to 03/12
v4:
+ Remove sysctls in favor of securityfs nodes
+ Re-add kernel module parameters, as these are now exposed through securityfs.
+ Refactor property audit loop to a separate function.
v5:
+ fix minor grammatical errors
+ do not group rule by curly-brace in audit record,
+ reconstruct the exact rule.
v6:
+ No changes
v7:
+ Further split lsm creation into a separate commit from the evaluation loop and audit system, for easier review.
+ Propagating changes to support the new ipe_context structure in the evaluation loop.
v8:
+ Remove ipe_hook enumeration; hooks can be correlated via syscall record.
v9:
+ Remove ipe_context related code and simplify the evaluation loop.
v10:
+ Split eval part and boot_verified part
v11:
+ Fix code style issues
v12:
+ Correct an rcu_read_unlock usage
+ Add a WARN to unknown op during evaluation
v13:
+ No changes
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/Makefile | 1 + security/ipe/eval.c | 102 ++++++++++++++++++++++++++++++++++++++++++ security/ipe/eval.h | 24 ++++++++++ 3 files changed, 127 insertions(+) create mode 100644 security/ipe/eval.c create mode 100644 security/ipe/eval.h
security/ipe/Makefile +1 -0
@@ -6,6 +6,7 @@ # obj-$(CONFIG_SECURITY_IPE) += \ + eval.o \ ipe.o \ policy.o \ policy_parser.o \
security/ipe/eval.c new file +102 -0
102 lines not on this page · raw message
security/ipe/eval.h new file +24 -0
@@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ + +#ifndef _IPE_EVAL_H +#define _IPE_EVAL_H + +#include <linux/file.h> +#include <linux/types.h> + +#include "policy.h" + +extern struct ipe_policy __rcu *ipe_active_policy; + +struct ipe_eval_ctx { +enum ipe_op_type op; + +const struct file *file; +}; + +int ipe_evaluate_event (const struct ipe_eval_ctx *const ctx); + +#endif /* _IPE_EVAL_H */
Signature · 1 line
2.44.0
PATCH v19 4/20 ipe: add LSM hooks on execution and kernel read
In reply to Fan WuFrom: Deven Bowers <[email protected]>
IPE's initial goal is to control both execution and the loading of kernel modules based on the system's definition of trust. It accomplishes this by plugging into the security hooks for bprm_check_security, file_mprotect, mmap_file, kernel_load_data, and kernel_read_data.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move ipe_load_properties to patch 04.
+ Remove useless 0-initializations
+ Prefix extern variables with ipe_
+ Remove kernel module parameters, as these are exposed through sysctls.
+ Add more prose to the IPE base config option help text.
+ Use GFP_KERNEL for audit_log_start.
+ Remove unnecessary caching system.
+ Remove comments from headers
+ Use rcu_access_pointer for rcu-pointer null check
+ Remove usage of reqprot; use prot only.
+ Move policy load and activation audit event to 03/12
v4:
+ Remove sysctls in favor of securityfs nodes
+ Re-add kernel module parameters, as these are now exposed through securityfs.
+ Refactor property audit loop to a separate function.
v5:
+ fix minor grammatical errors
+ do not group rule by curly-brace in audit record, reconstruct the exact rule.
v6:
+ No changes
v7:
+ Further split lsm creation, the audit system, the evaluation loop and access control hooks into separate commits.
v8:
+ Rename hook functions to follow the lsmname_hook_name convention
+ Remove ipe_hook enumeration, can be derived from correlation with syscall audit record.
v9:
+ Minor changes for adapting to the new parser
v10:
+ Remove @reqprot part
v11:
+ Fix code style issues
v12:
+ Correct WARN usages
v13:
+ No changes
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/Makefile | 1 + security/ipe/eval.c | 14 ++++ security/ipe/eval.h | 5 ++ security/ipe/hooks.c | 184 ++++++++++++++++++++++++++++++++++++++++++ security/ipe/hooks.h | 25 ++++++ security/ipe/ipe.c | 6 ++ 6 files changed, 235 insertions(+) create mode 100644 security/ipe/hooks.c create mode 100644 security/ipe/hooks.h
security/ipe/Makefile +1 -0
@@ -7,6 +7,7 @@ obj-$(CONFIG_SECURITY_IPE) += \ eval.o \ + hooks.o \ ipe.o \ policy.o \ policy_parser.o \
security/ipe/eval.c +14 -0
@@ -16,6 +16,20 @@struct ipe_policy __rcu *ipe_active_policy; +/** +* ipe_build_eval_ctx() - Build an ipe evaluation context. +* @ctx: Supplies a pointer to the context to be populated. +* @file: Supplies a pointer to the file to associated with the evaluation. +* @op: Supplies the IPE policy operation associated with the evaluation. +*/ +void ipe_build_eval_ctx (struct ipe_eval_ctx *ctx, +const struct file *file, +enum ipe_op_type op) +{ + ctx->file = file; + ctx->op = op; +} +/** * evaluate_property() - Analyze @ctx against a rule property. * @ctx: Supplies a pointer to the context to be evaluated.
security/ipe/eval.h +5 -0
@@ -11,6 +11,8 @@#include "policy.h" +#define IPE_EVAL_CTX_INIT ((struct ipe_eval_ctx){ 0 }) +extern struct ipe_policy __rcu *ipe_active_policy;struct ipe_eval_ctx {
@@ -19,6 +21,9 @@ struct ipe_eval_ctx { const struct file *file; }; +void ipe_build_eval_ctx (struct ipe_eval_ctx *ctx, +const struct file *file, +enum ipe_op_type op);int ipe_evaluate_event (const struct ipe_eval_ctx *const ctx);#endif /* _IPE_EVAL_H */
security/ipe/hooks.c new file +184 -0
184 lines not on this page · raw message
security/ipe/hooks.h new file +25 -0
@@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ +#ifndef _IPE_HOOKS_H +#define _IPE_HOOKS_H + +#include <linux/fs.h> +#include <linux/binfmts.h> +#include <linux/security.h> + +int ipe_bprm_check_security (struct linux_binprm *bprm); + +int ipe_mmap_file (struct file *f,unsigned long reqprot,unsigned long prot, +unsigned long flags); + +int ipe_file_mprotect (struct vm_area_struct *vma,unsigned long reqprot, +unsigned long prot); + +int ipe_kernel_read_file (struct file *file,enum kernel_read_file_id id, +bool contents); + +int ipe_kernel_load_data (enum kernel_load_data_id id,bool contents); + +#endif /* _IPE_HOOKS_H */
security/ipe/ipe.c +6 -0
@@ -5,6 +5,7 @@#include <uapi/linux/lsm.h> #include "ipe.h" +#include "hooks.h" static struct lsm_blob_sizes ipe_blobs__ro_after_init = { };
@@ -15,6 +16,11 @@ static const struct lsm_id ipe_lsmid = { };static struct security_hook_list ipe_hooks[]__ro_after_init = { +LSM_HOOK_INIT (bprm_check_security, ipe_bprm_check_security), +LSM_HOOK_INIT (mmap_file, ipe_mmap_file), +LSM_HOOK_INIT (file_mprotect, ipe_file_mprotect), +LSM_HOOK_INIT (kernel_read_file, ipe_kernel_read_file), +LSM_HOOK_INIT (kernel_load_data, ipe_kernel_load_data), };/**
Signature · 1 line
2.44.0
PATCH v19 5/20 initramfs|security: Add a security hook to do_populate_rootfs()
In reply to Fan WuThis patch introduces a new hook to notify security system that the content of initramfs has been unpacked into the rootfs.
Upon receiving this notification, the security system can activate a policy to allow only files that originated from the initramfs to execute or load into kernel during the early stages of booting.
This approach is crucial for minimizing the attack surface by ensuring that only trusted files from the initramfs are operational in the critical boot phase.
---
v1-v11:
+ Not present
v12:
+ Introduced
v13:
+ Rename the hook name to initramfs_populated()
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Fix ocumentation style issues
v18:
+ No changes
v19:
+ No changes
--- include/linux/lsm_hook_defs.h | 2 ++ include/linux/security.h | 8 ++++++++ init/initramfs.c | 3 +++ security/security.c | 10 ++++++++++ 4 files changed, 23 insertions(+)
include/linux/lsm_hook_defs.h +2 -0
@@ -451,3 +451,5 @@ LSM_HOOK(int, 0, uring_override_creds, const struct cred *new) LSM_HOOK(int, 0, uring_sqpoll, void) LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)#endif /* CONFIG_IO_URING */ + +LSM_HOOK (void,LSM_RET_VOID , initramfs_populated, void)
include/linux/security.h +8 -0
@@ -2255,4 +2255,12 @@ static inline int security_uring_cmd(struct io_uring_cmd *ioucmd)#endif /* CONFIG_SECURITY */ #endif /* CONFIG_IO_URING */ +#ifdef CONFIG_SECURITY +extern void security_initramfs_populated (void ); +#else +static inline void security_initramfs_populated (void ) +{ +} +#endif /* CONFIG_SECURITY */ +#endif /* ! __LINUX_SECURITY_H */
init/initramfs.c +3 -0
@@ -17,6 +17,7 @@#include <linux/namei.h> #include <linux/init_syscalls.h> #include <linux/umh.h> +#include <linux/security.h> #include "do_mounts.h"
@@ -711,6 +712,8 @@ static void __init do_populate_rootfs(void *unused, async_cookie_t cookie)#endif } +security_initramfs_populated (); + done:/* * If the initrd region is overlapped with crashkernel reserved region,
security/security.c +10 -0
@@ -5676,3 +5676,13 @@ int security_uring_cmd(struct io_uring_cmd *ioucmd) return call_int_hook(uring_cmd, ioucmd); }#endif /* CONFIG_IO_URING */ + +/** +* security_initramfs_populated() - Notify LSMs that initramfs has been loaded +* +* Tells the LSMs the initramfs has been unpacked into the rootfs. +*/ +void security_initramfs_populated (void ) +{ +call_void_hook (initramfs_populated); +}
Signature · 1 line
2.44.0
PATCH v19 6/20 ipe: introduce 'boot_verified' as a trust provider
In reply to Fan WuIPE is designed to provide system level trust guarantees, this usually implies that trust starts from bootup with a hardware root of trust, which validates the bootloader. After this, the bootloader verifies the kernel and the initramfs.
As there's no currently supported integrity method for initramfs, and it's typically already verified by the bootloader. This patch introduces a new IPE property boot_verified which allows author of IPE policy to indicate trust for files from initramfs.
The implementation of this feature utilizes the newly added initramfs_populated hook. This hook marks the superblock of the rootfs after the initramfs has been unpacked into it.
Before mounting the real rootfs on top of the initramfs, initramfs script will recursively remove all files and directories on the initramfs. This is typically implemented by using switch_root(8)
(https://man7.org/linux/man-pages/man8/switch_root.8.html).
Therefore the initramfs will be empty and not accessible after the real rootfs takes over. It is advised to switch to a different policy that doesn't rely on the boot_verified property after this point. This ensures that the trust policies remain relevant and effective throughout the system's operation.
---
v2:
+No Changes
v3:
+ Remove useless caching system
+ Move ipe_load_properties to this match
+ Minor changes from checkpatch --strict warnings
v4:
+ Remove comments from headers that was missed previously.
+ Grammatical corrections.
v5:
+ No significant changes
v6:
+ No changes
v7:
+ Reword and refactor patch 04/12 to [09/16], based on changes in
the underlying system.
+ Add common audit function for boolean values
+ Use common audit function as implementation.
v8:
+ No changes
v9:
+ No changes
v10:
+ Replace struct file with struct super_block
v11:
+ Fix code style issues
v12:
+ Switch to use unpack_initramfs hook and security blob
v13:
+ Update the hook name
+ Rename the security blob field to initramfs
+ Remove the dependency on CONFIG_BLK_DEV_INITRD
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/eval.c | 41 +++++++++++++++++++++++++++++++++--- security/ipe/eval.h | 5 +++++ security/ipe/hooks.c | 9 ++++++++ security/ipe/hooks.h | 2 ++ security/ipe/ipe.c | 8 +++++++ security/ipe/ipe.h | 1 + security/ipe/policy.h | 2 ++ security/ipe/policy_parser.c | 39 +++++++++++++++++++++++++++++++--- 8 files changed, 101 insertions(+), 6 deletions(-)
security/ipe/eval.c +38 -3
@@ -16,6 +16,18 @@struct ipe_policy __rcu *ipe_active_policy; +#define FILE_SUPERBLOCK (f) ((f)->f_path.mnt->mnt_sb) + +/** +* build_ipe_sb_ctx() - Build initramfs field of an ipe evaluation context. +* @ctx: Supplies a pointer to the context to be populated. +* @file: Supplies the file struct of the file triggered IPE event. +*/ +static void build_ipe_sb_ctx (struct ipe_eval_ctx *ctx,const struct file *const file) +{ + ctx->initramfs =ipe_sb (FILE_SUPERBLOCK (file))->initramfs; +} +/** * ipe_build_eval_ctx() - Build an ipe evaluation context. * @ctx: Supplies a pointer to the context to be populated.
@@ -28,6 +40,22 @@ void ipe_build_eval_ctx(struct ipe_eval_ctx *ctx, { ctx->file = file; ctx->op = op; + +if (file) +build_ipe_sb_ctx (ctx, file); +} + +/** +* evaluate_boot_verified() - Evaluate @ctx for the boot verified property. +* @ctx: Supplies a pointer to the context being evaluated. +* +* Return: +* * %true - The current @ctx match the @p +* * %false - The current @ctx doesn't match the @p +*/ +static bool evaluate_boot_verified (const struct ipe_eval_ctx *const ctx) +{ +return ctx->initramfs; }/**
@@ -35,8 +63,8 @@ void ipe_build_eval_ctx(struct ipe_eval_ctx *ctx,* @ctx: Supplies a pointer to the context to be evaluated. * @p: Supplies a pointer to the property to be evaluated. * -* This is a placeholder. The actual function will be introduced in the -* latter commits. +* This function Determines whether the specified @ctx +* matches the conditions defined by a rule property @p. * * Return: * * %true - The current @ctx match the @p
@@ -45,7 +73,14 @@ void ipe_build_eval_ctx(struct ipe_eval_ctx *ctx,static bool evaluate_property (const struct ipe_eval_ctx *const ctx,struct ipe_prop *p) { -return false; +switch (p->type) { +case IPE_PROP_BOOT_VERIFIED_FALSE : +return !evaluate_boot_verified (ctx); +case IPE_PROP_BOOT_VERIFIED_TRUE : +return evaluate_boot_verified (ctx); +default : +return false; + } }/**
security/ipe/eval.h +5 -0
@@ -15,10 +15,15 @@extern struct ipe_policy __rcu *ipe_active_policy; +struct ipe_superblock { +bool initramfs; +}; +struct ipe_eval_ctx {enum ipe_op_type op;const struct file *file; +bool initramfs; }; void ipe_build_eval_ctx(struct ipe_eval_ctx *ctx,
security/ipe/hooks.c +9 -0
@@ -4,6 +4,7 @@*/ #include <linux/fs.h> +#include <linux/fs_struct.h> #include <linux/types.h> #include <linux/binfmts.h> #include <linux/mman.h>
@@ -182,3 +183,11 @@ int ipe_kernel_load_data(enum kernel_load_data_id id, bool contents)ipe_build_eval_ctx (&ctx,NULL , op);return ipe_evaluate_event (&ctx); } + +/** +* ipe_unpack_initramfs() - Mark the current rootfs as initramfs. +*/ +void ipe_unpack_initramfs (void ) +{ +ipe_sb (current->fs->root.mnt->mnt_sb)->initramfs = true; +}
security/ipe/hooks.h +2 -0
@@ -22,4 +22,6 @@ int ipe_kernel_read_file(struct file *file, enum kernel_read_file_id id,int ipe_kernel_load_data (enum kernel_load_data_id id,bool contents); +void ipe_unpack_initramfs (void ); +#endif /* _IPE_HOOKS_H */
security/ipe/ipe.c +8 -0
@@ -5,9 +5,11 @@#include <uapi/linux/lsm.h> #include "ipe.h" +#include "eval.h" #include "hooks.h" static struct lsm_blob_sizes ipe_blobs__ro_after_init = { + .lbs_superblock =sizeof (struct ipe_superblock ), };static const struct lsm_id ipe_lsmid = {
@@ -15,12 +17,18 @@ static const struct lsm_id ipe_lsmid = { .id = LSM_ID_IPE, }; +struct ipe_superblock *ipe_sb (const struct super_block *sb) +{ +return sb->s_security + ipe_blobs.lbs_superblock; +} +static struct security_hook_list ipe_hooks[]__ro_after_init = {LSM_HOOK_INIT (bprm_check_security, ipe_bprm_check_security),LSM_HOOK_INIT (mmap_file, ipe_mmap_file),LSM_HOOK_INIT (file_mprotect, ipe_file_mprotect),LSM_HOOK_INIT (kernel_read_file, ipe_kernel_read_file),LSM_HOOK_INIT (kernel_load_data, ipe_kernel_load_data), +LSM_HOOK_INIT (initramfs_populated, ipe_unpack_initramfs), };/**
security/ipe/ipe.h +1 -0
@@ -12,5 +12,6 @@#define pr_fmt (fmt) "ipe: " fmt#include <linux/lsm_hooks.h> +struct ipe_superblock *ipe_sb (const struct super_block *sb);#endif /* _IPE_H */
security/ipe/policy.h +2 -0
@@ -30,6 +30,8 @@ enum ipe_action_type {#define IPE_ACTION_INVALID __IPE_ACTION_MAXenum ipe_prop_type { +IPE_PROP_BOOT_VERIFIED_FALSE , +IPE_PROP_BOOT_VERIFIED_TRUE , __IPE_PROP_MAX };
security/ipe/policy_parser.c +36 -3
@@ -270,13 +270,19 @@ static enum ipe_action_type parse_action(char *t)return match_token (t, action_tokens, args); } +static const match_table_t property_tokens = { + {IPE_PROP_BOOT_VERIFIED_FALSE ,"boot_verified=FALSE" }, + {IPE_PROP_BOOT_VERIFIED_TRUE ,"boot_verified=TRUE" }, + {IPE_PROP_INVALID ,NULL } +}; +/** * parse_property() - Parse a rule property given a token string. * @t: Supplies the token string to be parsed. * @r: Supplies the ipe_rule the parsed property will be associated with. * -* This is a placeholder. The actual function will be introduced in the -* latter commits. +* This function parses and associates a property with an IPE rule based +* on a token string. * * Return: * * %0 - Success
@@ -285,7 +291,34 @@ static enum ipe_action_type parse_action(char *t)*/ static int parse_property (char *t,struct ipe_rule *r) { -return -EBADMSG ; +substring_t args[MAX_OPT_ARGS ]; +struct ipe_prop *p =NULL ; +int rc =0 ; +int token; + + p =kzalloc (sizeof (*p),GFP_KERNEL ); +if (!p) +return -ENOMEM ; + + token =match_token (t, property_tokens, args); + +switch (token) { +case IPE_PROP_BOOT_VERIFIED_FALSE : +case IPE_PROP_BOOT_VERIFIED_TRUE : + p->type = token; +break ; +default : + rc = -EBADMSG ; +break ; + } +if (rc) + goto err; +list_add_tail (&p->next, &r->props); + +return rc; +err: +kfree (p); +return rc; }/**
Signature · 1 line
2.44.0
PATCH v19 7/20 security: add new securityfs delete function
In reply to Fan WuWhen deleting a directory in the security file system, the existing securityfs_remove requires the directory to be empty, otherwise it will do nothing. This leads to a potential risk that the security file system might be in an unclean state when the intended deletion did not happen.
This commit introduces a new function securityfs_recursive_remove to recursively delete a directory without leaving an unclean state.
---
v1-v8:
+ Not present
v9:
+ Introduced
v10:
+ No changes
v11:
+ Fix code style issues
v12:
+ No changes
v13:
+ No changes
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ No changes
v18:
+ No changes
v19:
+ No changes
--- include/linux/security.h | 1 + security/inode.c | 25 +++++++++++++++++++++++++ 2 files changed, 26 insertions(+)
include/linux/security.h +1 -0
@@ -2089,6 +2089,7 @@ struct dentry *securityfs_create_symlink(const char *name,const char *target, const struct inode_operations *iops);extern void securityfs_remove (struct dentry *dentry); +extern void securityfs_recursive_remove (struct dentry *dentry);#else /* CONFIG_SECURITYFS */
security/inode.c +25 -0
@@ -313,6 +313,31 @@ void securityfs_remove(struct dentry *dentry) }EXPORT_SYMBOL_GPL (securityfs_remove); +static void remove_one (struct dentry *victim) +{ +simple_release_fs (&mount, &mount_count); +} + +/** +* securityfs_recursive_remove - recursively removes a file or directory +* +* @dentry: a pointer to a the dentry of the file or directory to be removed. +* +* This function recursively removes a file or directory in securityfs that was +* previously created with a call to another securityfs function (like +* securityfs_create_file() or variants thereof.) +*/ +void securityfs_recursive_remove (struct dentry *dentry) +{ +if (IS_ERR_OR_NULL (dentry)) +return ; + +simple_pin_fs (&fs_type, &mount, &mount_count); +simple_recursive_removal (dentry, remove_one); +simple_release_fs (&mount, &mount_count); +} +EXPORT_SYMBOL_GPL (securityfs_recursive_remove); +#ifdef CONFIG_SECURITY static struct dentry *lsm_dentry; static ssize_t lsm_read(struct file *filp, char __user *buf, size_t count,
Signature · 1 line
2.44.0
PATCH v19 8/20 ipe: add userspace interface
In reply to Fan WuFrom: Deven Bowers <[email protected]>
As is typical with LSMs, IPE uses securityfs as its interface with userspace. for a complete list of the interfaces and the respective inputs/outputs, please see the documentation under admin-guide/LSM/ipe.rst
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move policy load and activation audit event to 03/12
+ Fix a potential panic when a policy failed to load.
+ use pr_warn for a failure to parse instead of an audit record
+ Remove comments from headers
+ Add lockdep assertions to ipe_update_active_policy and ipe_activate_policy
+ Fix up warnings with checkpatch --strict
+ Use file_ns_capable for CAP_MAC_ADMIN for securityfs nodes.
+ Use memdup_user instead of kzalloc+simple_write_to_buffer.
+ Remove strict_parse command line parameter, as it is added by the sysctl command line.
+ Prefix extern variables with ipe_
v4:
+ Remove securityfs to reverse-dependency
+ Add SHA1 reverse dependency.
+ Add versioning scheme for IPE properties, and associated interface to query the versioning scheme.
+ Cause a parser to always return an error on unknown syntax.
+ Remove strict_parse option
+ Change active_policy interface from sysctl, to securityfs, and change scheme.
v5:
+ Cause an error if a default action is not defined for each operation.
+ Minor function renames
v6:
+ No changes
v7:
+ Propagating changes to support the new ipe_context structure in the evaluation loop.
+ Further split the parser and userspace interface changes into separate commits.
+ "raw" was renamed to "pkcs7" and made read only
+ "raw"'s write functionality (update a policy) moved to "update"
+ introduced "version", "policy_name" nodes.
+ "content" renamed to "policy"
+ changes to allow the compiled-in policy to be treated identical to deployed-after-the-fact policies.
v8:
+ Prevent securityfs initialization if the LSM is disabled
v9:
+ Switch to securityfs_recursive_remove for policy folder deletion
v10:
+ Simplify and correct concurrency
+ Fix typos
v11:
+ Correct code comments
v12:
+ Correct locking and remove redundant code
v13:
+ Move the free of old policy into the ipe_update_policy function
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/Makefile | 2 + security/ipe/fs.c | 105 +++++++++ security/ipe/fs.h | 16 ++ security/ipe/ipe.c | 3 + security/ipe/ipe.h | 2 + security/ipe/policy.c | 121 ++++++++++ security/ipe/policy.h | 7 + security/ipe/policy_fs.c | 470 +++++++++++++++++++++++++++++++++++++++ 8 files changed, 726 insertions(+) create mode 100644 security/ipe/fs.c create mode 100644 security/ipe/fs.h create mode 100644 security/ipe/policy_fs.c
security/ipe/Makefile +2 -0
@@ -8,6 +8,8 @@ obj-$(CONFIG_SECURITY_IPE) += \ eval.o \ hooks.o \ + fs.o \ ipe.o \ policy.o \ + policy_fs.o \ policy_parser.o \
security/ipe/fs.c new file +105 -0
105 lines not on this page · raw message
security/ipe/fs.h new file +16 -0
@@ -0,0 +1,16 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ + +#ifndef _IPE_FS_H +#define _IPE_FS_H + +#include "policy.h" + +extern struct dentry *policy_root__ro_after_init ; + +int ipe_new_policyfs_node (struct ipe_policy *p); +void ipe_del_policyfs_node (struct ipe_policy *p); + +#endif /* _IPE_FS_H */
security/ipe/ipe.c +3 -0
@@ -8,6 +8,8 @@#include "eval.h" #include "hooks.h" +bool ipe_enabled; +static struct lsm_blob_sizes ipe_blobs__ro_after_init = { .lbs_superblock =sizeof (struct ipe_superblock ), };
@@ -45,6 +47,7 @@ static struct security_hook_list ipe_hooks[] __ro_after_init = {static int __init ipe_init (void ) {security_add_hooks (ipe_hooks,ARRAY_SIZE (ipe_hooks), &ipe_lsmid); + ipe_enabled = true;return 0 ; }
security/ipe/ipe.h +2 -0
@@ -14,4 +14,6 @@#include <linux/lsm_hooks.h> struct ipe_superblock *ipe_sb (const struct super_block *sb); +extern bool ipe_enabled; +#endif /* _IPE_H */
security/ipe/policy.c +121 -0
145 lines not on this page · raw message
security/ipe/policy.h +7 -0
@@ -7,6 +7,7 @@#include <linux/list.h> #include <linux/types.h> +#include <linux/fs.h> enum ipe_op_type {IPE_OP_EXEC =0 ,
@@ -76,10 +77,16 @@ struct ipe_policy {size_t textlen;struct ipe_parsed_policy *parsed; + + struct dentry *policyfs; };struct ipe_policy *ipe_new_policy (const char *text,size_t textlen,const char *pkcs7,size_t pkcs7len);void ipe_free_policy (struct ipe_policy *pol); +int ipe_update_policy (struct inode *root,const char *text,size_t textlen, +const char *pkcs7,size_t pkcs7len); +int ipe_set_active_pol (const struct ipe_policy *p); +extern struct mutex ipe_policy_lock;#endif /* _IPE_POLICY_H */
security/ipe/policy_fs.c new file +470 -0
470 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH v19 9/20 uapi|audit|ipe: add ipe auditing support
In reply to Fan WuFrom: Deven Bowers <[email protected]>
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=1The 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=1The above record showed a new policy has been loaded into the kernel with the policy name, policy version and policy hash.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move ipe_load_properties to patch 04.
+ Remove useless 0-initializations
+ Prefix extern variables with ipe_
+ Remove kernel module parameters, as these are exposed through sysctls.
+ Add more prose to the IPE base config option help text.
+ Use GFP_KERNEL for audit_log_start.
+ Remove unnecessary caching system.
+ Remove comments from headers
+ Use rcu_access_pointer for rcu-pointer null check
+ Remove usage of reqprot; use prot only.
+ Move policy load and activation audit event to 03/12
v4:
+ Remove sysctls in favor of securityfs nodes
+ Re-add kernel module parameters, as these are now exposed through securityfs.
+ Refactor property audit loop to a separate function.
v5:
+ fix minor grammatical errors
+ do not group rule by curly-brace in audit record, reconstruct the exact rule.
v6:
+ No changes
v7:
+ Further split lsm creation, the audit system, the evaluation loop, and access control hooks into separate patches.
+ Further split audit system patch into two separate patches; one for include/uapi, and the usage of the new defines.
+ Split out the permissive functionality into another separate patch, for easier review.
+ Correct misuse of audit_log_n_untrusted string to audit_log_format
+ Use get_task_comm instead of comm directly.
+ Quote certain audit values
+ Remove unnecessary help text on choice options - these were previously indented at the wrong level
+ Correct a stale string constant (ctx_ns_enforce to ctx_enforce)
v8:
+ Change dependency for CONFIG_AUDIT to CONFIG_AUDITSYSCALL
+ Drop ctx_* prefix
+ Reuse, where appropriate, the audit fields from the field
dictionary. This transforms:
ctx_pathname -> path
ctx_ino -> ino
ctx_dev -> dev + Add audit records and event examples to commit description.
+ Remove new_audit_ctx, replace with audit_log_start. All data that would provided by new_audit_ctx is already present in the syscall audit record, that is always emitted on these actions. The audit records should be correlated as such.
+ Change audit types:
+ AUDIT_TRUST_RESULT -> AUDIT_IPE_ACCESS
+ This prevents overloading of the AVC type.
+ AUDIT_TRUST_POLICY_ACTIVATE -> AUDIT_MAC_CONFIG_CHANGE
+ AUDIT_TRUST_POLICY_LOAD -> AUDIT_MAC_POLICY_LOAD
+ There were no significant difference in meaning between these types.
+ Remove enforcing parameter passed from the context structure for AUDIT_IPE_ACCESS.
+ This field can be inferred from the SYSCALL audit event, based on the success field.
+ Remove all fields already captured in the syscall record. "hook", an IPE specific field, can be determined via the syscall field in the syscall record itself, so it has been removed.
+ ino, path, and dev in IPE's record refer to the subject of the syscall, while the syscall record refers to the calling process.
+ remove IPE prefix from policy load/policy activation events
+ fix a bug wherein a policy change audit record was not fired when updating a policy
v9:
+ Merge the AUDIT_IPE_ACCESS definition with the audit support commit
+ Change the audit format of policy load and switch
+ Remove the ipe audit kernel switch
v10:
+ Create AUDIT_IPE_CONFIG_CHANGE and AUDIT_IPE_POLICY_LOAD
+ Change field names per upstream feedback
v11:
+ Fix style issues
v12:
+ Add ipe_op, ipe_hook, and enforcing fields to AUDIT_IPE_ACCESS
v13:
+ Remove dependency on CONFIG_BLK_DEV_INITRD
+ Add field placeholders for anonymous files
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- include/uapi/linux/audit.h | 3 + security/ipe/Kconfig | 2 +- security/ipe/Makefile | 1 + security/ipe/audit.c | 214 +++++++++++++++++++++++++++++++++++++ security/ipe/audit.h | 18 ++++ security/ipe/eval.c | 44 ++++++-- security/ipe/eval.h | 13 ++- security/ipe/fs.c | 68 ++++++++++++ security/ipe/hooks.c | 10 +- security/ipe/hooks.h | 11 ++ security/ipe/policy.c | 5 + 11 files changed, 372 insertions(+), 17 deletions(-) create mode 100644 security/ipe/audit.c create mode 100644 security/ipe/audit.h
include/uapi/linux/audit.h +3 -0
@@ -143,6 +143,9 @@#define AUDIT_MAC_UNLBL_STCDEL 1417/* NetLabel: del a static label */ #define AUDIT_MAC_CALIPSO_ADD 1418/* NetLabel: add CALIPSO DOI entry */ #define AUDIT_MAC_CALIPSO_DEL 1419/* NetLabel: del CALIPSO DOI entry */ +#define AUDIT_IPE_ACCESS 1420/* IPE denial or grant */ +#define AUDIT_IPE_CONFIG_CHANGE 1421/* IPE config change */ +#define AUDIT_IPE_POLICY_LOAD 1422/* IPE policy load */ #define AUDIT_FIRST_KERN_ANOM_MSG 1700#define AUDIT_LAST_KERN_ANOM_MSG 1799
security/ipe/Kconfig +1 -1
@@ -5,7 +5,7 @@ menuconfig SECURITY_IPE bool "Integrity Policy Enforcement (IPE)" - depends on SECURITY && SECURITYFS + depends on SECURITY && SECURITYFS && AUDIT && AUDITSYSCALL select PKCS7_MESSAGE_PARSER select SYSTEM_DATA_VERIFICATION help
security/ipe/Makefile +1 -0
@@ -13,3 +13,4 @@ obj-$(CONFIG_SECURITY_IPE) += \ policy.o \ policy_fs.o \ policy_parser.o \ + audit.o \
security/ipe/audit.c new file +214 -0
214 lines not on this page · raw message
security/ipe/audit.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ + +#ifndef _IPE_AUDIT_H +#define _IPE_AUDIT_H + +#include "policy.h" + +void ipe_audit_match (const struct ipe_eval_ctx *const ctx, +enum ipe_match match_type, +enum ipe_action_type act,const struct ipe_rule *const r); +void ipe_audit_policy_load (const struct ipe_policy *const p); +void ipe_audit_policy_activation (const struct ipe_policy *const op, +const struct ipe_policy *const np); + +#endif /* _IPE_AUDIT_H */
security/ipe/eval.c +34 -10
95 lines not on this page · raw message
security/ipe/eval.h +12 -1
@@ -10,10 +10,12 @@#include <linux/types.h> #include "policy.h" +#include "hooks.h" #define IPE_EVAL_CTX_INIT ((struct ipe_eval_ctx){ 0 })extern struct ipe_policy __rcu *ipe_active_policy; +extern bool success_audit;struct ipe_superblock {bool initramfs;
@@ -21,14 +23,23 @@ struct ipe_superblock {struct ipe_eval_ctx {enum ipe_op_type op; +enum ipe_hook_type hook;const struct file *file;bool initramfs; }; +enum ipe_match { +IPE_MATCH_RULE =0 , +IPE_MATCH_TABLE , +IPE_MATCH_GLOBAL , + __IPE_MATCH_MAX +}; +void ipe_build_eval_ctx (struct ipe_eval_ctx *ctx,const struct file *file, -enum ipe_op_type op); +enum ipe_op_type op, +enum ipe_hook_type hook);int ipe_evaluate_event (const struct ipe_eval_ctx *const ctx);#endif /* _IPE_EVAL_H */
security/ipe/fs.c +68 -0
103 lines not on this page · raw message
security/ipe/hooks.c +5 -5
@@ -29,7 +29,7 @@ int ipe_bprm_check_security(struct linux_binprm *bprm) {struct ipe_eval_ctx ctx =IPE_EVAL_CTX_INIT ; -ipe_build_eval_ctx (&ctx, bprm->file,IPE_OP_EXEC ); +ipe_build_eval_ctx (&ctx, bprm->file,IPE_OP_EXEC ,IPE_HOOK_BPRM_CHECK );return ipe_evaluate_event (&ctx); }
@@ -54,7 +54,7 @@ int ipe_mmap_file(struct file *f, unsigned long reqprot __always_unused,struct ipe_eval_ctx ctx =IPE_EVAL_CTX_INIT ;if (prot &PROT_EXEC ) { -ipe_build_eval_ctx (&ctx, f,IPE_OP_EXEC ); +ipe_build_eval_ctx (&ctx, f,IPE_OP_EXEC ,IPE_HOOK_MMAP );return ipe_evaluate_event (&ctx); }
@@ -86,7 +86,7 @@ int ipe_file_mprotect(struct vm_area_struct *vma,return 0 ;if (prot &PROT_EXEC ) { -ipe_build_eval_ctx (&ctx, vma->vm_file,IPE_OP_EXEC ); +ipe_build_eval_ctx (&ctx, vma->vm_file,IPE_OP_EXEC ,IPE_HOOK_MPROTECT );return ipe_evaluate_event (&ctx); }
@@ -136,7 +136,7 @@ int ipe_kernel_read_file(struct file *file, enum kernel_read_file_id id,WARN (1 ,"no rule setup for kernel_read_file enum %d" , id); } -ipe_build_eval_ctx (&ctx, file, op); +ipe_build_eval_ctx (&ctx, file, op,IPE_HOOK_KERNEL_READ );return ipe_evaluate_event (&ctx); }
@@ -180,7 +180,7 @@ int ipe_kernel_load_data(enum kernel_load_data_id id, bool contents)WARN (1 ,"no rule setup for kernel_load_data enum %d" , id); } -ipe_build_eval_ctx (&ctx,NULL , op); +ipe_build_eval_ctx (&ctx,NULL , op,IPE_HOOK_KERNEL_LOAD );return ipe_evaluate_event (&ctx); }
security/ipe/hooks.h +11 -0
@@ -9,6 +9,17 @@#include <linux/binfmts.h> #include <linux/security.h> +enum ipe_hook_type { +IPE_HOOK_BPRM_CHECK =0 , +IPE_HOOK_MMAP , +IPE_HOOK_MPROTECT , +IPE_HOOK_KERNEL_READ , +IPE_HOOK_KERNEL_LOAD , + __IPE_HOOK_MAX +}; + +#define IPE_HOOK_INVALID __IPE_HOOK_MAX +int ipe_bprm_check_security (struct linux_binprm *bprm); int ipe_mmap_file(struct file *f, unsigned long reqprot, unsigned long prot,
security/ipe/policy.c +5 -0
@@ -11,6 +11,7 @@#include "fs.h" #include "policy.h" #include "policy_parser.h" +#include "audit.h" /* lock for synchronizing writers across ipe policy */ DEFINE_MUTEX (ipe_policy_lock);
@@ -112,6 +113,7 @@ int ipe_update_policy(struct inode *root, const char *text, size_t textlen, root->i_private = new;swap (new->policyfs, old->policyfs); +ipe_audit_policy_load (new);mutex_lock (&ipe_policy_lock); ap = rcu_dereference_protected(ipe_active_policy,
@@ -120,6 +122,7 @@ int ipe_update_policy(struct inode *root, const char *text, size_t textlen,rcu_assign_pointer (ipe_active_policy, new);mutex_unlock (&ipe_policy_lock);synchronize_rcu (); +ipe_audit_policy_activation (old, new); }else {mutex_unlock (&ipe_policy_lock); }
@@ -220,5 +223,7 @@ int ipe_set_active_pol(const struct ipe_policy *p)mutex_unlock (&ipe_policy_lock);synchronize_rcu (); +ipe_audit_policy_activation (ap, p); +return 0 ; }
Signature · 1 line
2.44.0
PATCH v19 10/20 ipe: add permissive toggle
In reply to Fan WuFrom: Deven Bowers <[email protected]>
IPE, like SELinux, supports a permissive mode. This mode allows policy authors to test and evaluate IPE policy without it effecting their programs. When the mode is changed, a 1404 AUDIT_MAC_STATUS be reported.
This patch adds the following audit records:
audit: MAC_STATUS enforcing=0 old_enforcing=1 auid=4294967295
ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1
audit: MAC_STATUS enforcing=1 old_enforcing=0 auid=4294967295
ses=4294967295 enabled=1 old-enabled=1 lsm=ipe res=1The audit record only emit when the value from the user input is different from the current enforce value.
---
v2:
+ Split evaluation loop, access control hooks, and evaluation loop from policy parser and userspace interface to pass mailing list character limit
v3:
+ Move ipe_load_properties to patch 04.
+ Remove useless 0-initializations
+ Prefix extern variables with ipe_
+ Remove kernel module parameters, as these are exposed through sysctls.
+ Add more prose to the IPE base config option help text.
+ Use GFP_KERNEL for audit_log_start.
+ Remove unnecessary caching system.
+ Remove comments from headers
+ Use rcu_access_pointer for rcu-pointer null check
+ Remove usage of reqprot; use prot only.
+ Move policy load and activation audit event to 03/12
v4:
+ Remove sysctls in favor of securityfs nodes
+ Re-add kernel module parameters, as these are now exposed through securityfs.
+ Refactor property audit loop to a separate function.
v5:
+ fix minor grammatical errors
+ do not group rule by curly-brace in audit record, reconstruct the exact rule.
v6:
+ No changes
v7:
+ Further split lsm creation into a separate commit from the evaluation loop and audit system, for easier review.
+ Propagating changes to support the new ipe_context structure in the evaluation loop.
+ Split out permissive functionality into a separate patch for easier review.
+ Remove permissive switch compile-time configuration option - this is trivial to add later.
v8:
+ Remove "IPE" prefix from permissive audit record
+ align fields to the linux-audit field dictionary. This causes the following fields to change:
enforce -> permissive
+ Remove duplicated information correlated with syscall record, that will always be present in the audit event.
+ Change audit types:
+ AUDIT_TRUST_STATUS -> AUDIT_MAC_STATUS
+ There is no significant difference in meaning between these types.
v9:
+ Clean up ipe_context related code
v10:
+ Change audit format to comform with the existing format selinux is using
+ Remove the audit record emission during init to align with selinux, which does not perform this action.
v11:
+ Remove redundant code
v12:
+ Remove redundant code
v13:
+ Remove audit format macro
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/audit.c | 27 ++++++++++++++++-- security/ipe/audit.h | 1 + security/ipe/eval.c | 11 ++++++-- security/ipe/eval.h | 1 + security/ipe/fs.c | 66 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 102 insertions(+), 4 deletions(-)
security/ipe/audit.c +25 -2
@@ -93,8 +93,8 @@ void ipe_audit_match(const struct ipe_eval_ctx *const ctx,if (!ab)return ; -audit_log_format (ab,"ipe_op=%s ipe_hook=%s pid=%d comm=" , - op, audit_hook_names[ctx->hook], +audit_log_format (ab,"ipe_op=%s ipe_hook=%s enforcing=%d pid=%d comm=" , + op, audit_hook_names[ctx->hook],READ_ONCE (enforce),task_tgid_nr (current));audit_log_untrustedstring (ab,get_task_comm (comm, current));
@@ -212,3 +212,26 @@ void ipe_audit_policy_load(const struct ipe_policy *const p)audit_log_end (ab); } + +/** +* ipe_audit_enforce() - Audit a change in IPE's enforcement state. +* @new_enforce: The new value enforce to be set. +* @old_enforce: The old value currently in enforce. +*/ +void ipe_audit_enforce (bool new_enforce,bool old_enforce) +{ +struct audit_buffer *ab; + + ab =audit_log_start (audit_context (),GFP_KERNEL ,AUDIT_MAC_STATUS ); +if (!ab) +return ; + +audit_log (audit_context (),GFP_KERNEL ,AUDIT_MAC_STATUS , +"enforcing=%d old_enforcing=%d auid=%u ses=%u" +" enabled=1 old-enabled=1 lsm=ipe res=1" , + new_enforce, old_enforce, +from_kuid (&init_user_ns,audit_get_loginuid (current)), +audit_get_sessionid (current)); + +audit_log_end (ab); +}
security/ipe/audit.h +1 -0
@@ -14,5 +14,6 @@ void ipe_audit_match(const struct ipe_eval_ctx *const ctx,void ipe_audit_policy_load (const struct ipe_policy *const p);void ipe_audit_policy_activation (const struct ipe_policy *const op,const struct ipe_policy *const np); +void ipe_audit_enforce (bool new_enforce,bool old_enforce);#endif /* _IPE_AUDIT_H */
security/ipe/eval.c +9 -2
@@ -18,6 +18,7 @@struct ipe_policy __rcu *ipe_active_policy;bool success_audit; +bool enforce = true;#define FILE_SUPERBLOCK (f) ((f)->f_path.mnt->mnt_sb)
@@ -108,6 +109,7 @@ int ipe_evaluate_event(const struct ipe_eval_ctx *const ctx)enum ipe_action_type action;enum ipe_match match_type;bool match = false; +int rc =0 ;rcu_read_lock ();
@@ -160,9 +162,12 @@ int ipe_evaluate_event(const struct ipe_eval_ctx *const ctx)ipe_audit_match (ctx, match_type, action, rule);if (action ==IPE_ACTION_DENY ) -return -EACCES ; + rc = -EACCES ; -return 0 ; +if (!READ_ONCE (enforce)) + rc =0 ; + +return rc; }/* Set the right module name */
@@ -173,3 +178,5 @@ int ipe_evaluate_event(const struct ipe_eval_ctx *const ctx)module_param (success_audit, bool,0400 );MODULE_PARM_DESC (success_audit,"Start IPE with success auditing enabled" ); +module_param (enforce, bool,0400 ); +MODULE_PARM_DESC (enforce,"Start IPE in enforce or permissive mode" );
security/ipe/eval.h +1 -0
@@ -16,6 +16,7 @@extern struct ipe_policy __rcu *ipe_active_policy;extern bool success_audit; +extern bool enforce;struct ipe_superblock {bool initramfs;
security/ipe/fs.c +66 -0
96 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH v19 11/20 block,lsm: add LSM blob and new LSM hooks for block device
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Some block devices have valuable security properties that is only accessible during the creation time.
For example, when creating a dm-verity block device, the dm-verity's roothash and roothash signature, which are extreme important security metadata, are passed to the kernel. However, the roothash will be saved privately in dm-verity, which prevents the security subsystem to easily access that information. Worse, in the current implementation the roothash signature will be discarded after the verification, making it impossible to utilize the roothash signature by the security subsystem.
With this patch, an LSM blob is added to the block_device structure. This enables the security subsystem to store security-sensitive data related to block devices within the security blob. For example, LSM can use the new LSM blob to save the roothash signature of a dm-verity, and LSM can make access decision based on the data inside the signature, like the signer certificate.
The implementation follows the same approach used for security blobs in other structures like struct file, struct inode, and struct superblock. The initialization of the security blob occurs after the creation of the struct block_device, performed by the security subsystem. Similarly, the security blob is freed by the security subsystem before the struct block_device is deallocated or freed.
This patch also introduces a new hook to save block device's integrity data. For example, for dm-verity, LSMs can use this hook to save the roothash signature of a dm-verity into the security blob, and LSMs can make access decisions based on the data inside the signature, like the signer certificate.
---
v2:
+ No Changes
v3:
+ Minor style changes from checkpatch --strict
v4:
+ No Changes
v5:
+ Allow multiple callers to call security_bdev_setsecurity
v6:
+ Simplify security_bdev_setsecurity break condition
v7:
+ Squash all dm-verity related patches to two patches, the additions to dm-verity/fs, and the consumption of the additions.
v8:
+ Split dm-verity related patches squashed in v7 to 3 commits based on topic:
+ New LSM hook
+ Consumption of hook outside LSM
+ Consumption of hook inside LSM.
+ change return of security_bdev_alloc / security_bdev_setsecurity to LSM_RET_DEFAULT instead of 0.
+ Change return code to -EOPNOTSUPP, bring inline with other setsecurity hooks.
v9:
+ Add Reviewed-by: Casey Schaufler <[email protected]>
+ Remove unlikely when calling LSM hook
+ Make the security field dependent on CONFIG_SECURITY
v10:
+ No changes
v11:
+ No changes
v12:
+ No changes
v13:
+ No changes
v14:
+ No changes
v15:
+ Drop security_bdev_setsecurity() for new hook security_bdev_setintegrity() in the next commit
+ Update call_int_hook() for 260017f
v16:
+ Drop Reviewed-by tag for the new changes
+ Squash the security_bdev_setintegrity() into this commit
+ Rename enum from lsm_intgr_type to lsm_integrity_type
+ Switch to use call_int_hook() for bdev_setintegrity()
+ Correct comment
+ Fix return in security_bdev_alloc()
v17:
+ Fix a typo
+ Improve the commit subject line
v18:
+ No changes
v19:
+ No changes
--- block/bdev.c | 7 +++ include/linux/blk_types.h | 3 ++ include/linux/lsm_hook_defs.h | 5 ++ include/linux/lsm_hooks.h | 1 + include/linux/security.h | 26 ++++++++++ security/security.c | 89 +++++++++++++++++++++++++++++++++++ 6 files changed, 131 insertions(+)
block/bdev.c +7 -0
@@ -24,6 +24,7 @@#include <linux/pseudo_fs.h> #include <linux/uio.h> #include <linux/namei.h> +#include <linux/security.h> #include <linux/part_stat.h> #include <linux/uaccess.h> #include <linux/stat.h>
@@ -324,6 +325,11 @@ static struct inode *bdev_alloc_inode(struct super_block *sb)if (!ei)return NULL ;memset (&ei->bdev,0 ,sizeof (ei->bdev)); + +if (security_bdev_alloc (&ei->bdev)) { +kmem_cache_free (bdev_cachep, ei); +return NULL ; + }return &ei->vfs_inode; }
@@ -333,6 +339,7 @@ static void bdev_free_inode(struct inode *inode)free_percpu (bdev->bd_stats);kfree (bdev->bd_meta_info); +security_bdev_free (bdev);if (!bdev_is_partition (bdev)) {if (bdev->bd_disk && bdev->bd_disk->bdi)
include/linux/blk_types.h +3 -0
@@ -71,6 +71,9 @@ struct block_device {struct partition_meta_info *bd_meta_info;int bd_writers; +#ifdef CONFIG_SECURITY +void *security; +#endif /* * keep this out-of-line as it's both big and not needed in the fast * path
include/linux/lsm_hook_defs.h +5 -0
@@ -453,3 +453,8 @@ LSM_HOOK(int, 0, uring_cmd, struct io_uring_cmd *ioucmd)#endif /* CONFIG_IO_URING */ LSM_HOOK(void, LSM_RET_VOID, initramfs_populated, void) + +LSM_HOOK(int, 0, bdev_alloc_security, struct block_device *bdev) +LSM_HOOK(void, LSM_RET_VOID, bdev_free_security, struct block_device *bdev) +LSM_HOOK(int, 0, bdev_setintegrity, struct block_device *bdev, + enum lsm_integrity_type type, const void *value, size_t size)
include/linux/lsm_hooks.h +1 -0
@@ -78,6 +78,7 @@ struct lsm_blob_sizes {int lbs_msg_msg;int lbs_task;int lbs_xattr_count;/* number of xattr slots in new_xattrs array */ +int lbs_bdev; };/**
include/linux/security.h +26 -0
@@ -83,6 +83,10 @@ enum lsm_event { LSM_POLICY_CHANGE, }; +enum lsm_integrity_type { + __LSM_INT_MAX +}; +/* * These are reasons that can be passed to the security_locked_down() * LSM hook. Lockdown reasons that protect kernel integrity (ie, the
@@ -509,6 +513,11 @@ int security_inode_getsecctx(struct inode *inode, void **ctx, u32 *ctxlen);int security_locked_down (enum lockdown_reason what);int lsm_fill_user_ctx (struct lsm_ctx __user *uctx,u32 *uctx_len,void *val,size_t val_len,u64 id,u64 flags); +int security_bdev_alloc (struct block_device *bdev); +void security_bdev_free (struct block_device *bdev); +int security_bdev_setintegrity (struct block_device *bdev, +enum lsm_integrity_type type,const void *value, +size_t size);#else /* CONFIG_SECURITY */ static inline int call_blocking_lsm_notifier (enum lsm_event event,void *data)
@@ -1483,6 +1492,23 @@ static inline int lsm_fill_user_ctx(struct lsm_ctx __user *uctx, {return -EOPNOTSUPP ; } + +static inline int security_bdev_alloc (struct block_device *bdev) +{ +return 0 ; +} + +static inline void security_bdev_free (struct block_device *bdev) +{ +} + +static inline int security_bdev_setintegrity (struct block_device *bdev, +enum lsm_integrity_type type, +const void *value,size_t size) +{ +return 0 ; +} +#endif /* CONFIG_SECURITY */ #if defined(CONFIG_SECURITY ) && defined(CONFIG_WATCH_QUEUE )
security/security.c +89 -0
119 lines not on this page · raw message
Signature · 1 line
2.44.0
Eric Biggers
maintainerRe: [PATCH v19 11/20] block,lsm: add LSM blob and new LSM hooks for block device
Quoted 5 lines · Fan Wu
From: Deven Bowers <[email protected]>
Some block devices have valuable security properties that is only accessible during the creation time.
Quoted 7 lines
For example, when creating a dm-verity block device, the dm-verity's roothash and roothash signature, which are extreme important security metadata, are passed to the kernel. However, the roothash will be saved privately in dm-verity, which prevents the security subsystem to easily access that information. Worse, in the current implementation the roothash signature will be discarded after the verification, making it impossible to utilize the roothash signature by the security subsystem.
This patch seems to be assuming that creating the block device == setting up dm-verity. That's not how it actually works. The way that device-mapper works is that first a device-mapper device is created, and then targets are loaded into it. The targets can be changed later, any number of times.
So, while the creation of the block device is when the LSM blob is allocated, it's not when the actual contents of it are initialized. And its contents can vary over the lifetime of the block device, including changing from something the LSM "trusts" to something it doesn't "trust".
I'm not sure if this is "just" a documentation issue or if there are bugs resulting from not handling changes properly. The code itself *looks* correct, but seeing it's not clear how much this has been considered and that getting this wrong would allow the LSM checks to be bypassed, I thought I'd draw attention to it. This is really something that ought to be called out explicitly in comments, for example.
Quoted 3 lines
For example, LSM can use the new LSM blob to save the roothash signature of a dm-verity, and LSM can make access decision based on the data inside the signature, like the signer certificate.
This isn't what IPE actually does, though. So this doesn't seem like a particularly useful example in this context.
Quoted 4 lines
For example, for dm-verity, LSMs can use this hook to save the roothash signature of a dm-verity into the security blob, and LSMs can make access decisions based on the data inside the signature, like the signer certificate.
Likewise.
include/linux/blk_types.h struct block_device { · line 76
Quoted 11 lines
include/linux/blk_types.h +3
-0@@ -71,6 +71,9 @@ struct block_device {struct partition_meta_info *bd_meta_info;int bd_writers; +#ifdef CONFIG_SECURITY +void *security; +#endif
All the other fields in struct block_device are prefixed with "bd_", so please use the same pattern for this new field (bd_security).
Quoted 4 lines
security/security.c +0
-0
[...]
Quoted 9 lines
security/security.c +9
-0+/** +* security_bdev_setintegrity() - Set the device's integrity data +* @bdev: block device +* @type: type of integrity, e.g. hash digest, signature, etc +* @value: the integrity value +* @size: size of the integrity value +* +* Register a verified integrity measurement of a bdev with LSMs. +* LSMs should free the previously saved data if @value is NULL.
security/security.c int security_locked_down(enum lockdown_reason what) · line 5659
Quoted 10 lines
security/security.c +10
-0+* +* Return: Returns 0 on success, negative values on failure. +*/ +int security_bdev_setintegrity (struct block_device *bdev, +enum lsm_integrity_type type,const void *value, +size_t size) +{ +return call_int_hook (bdev_setintegrity, bdev, type, value, size); +} +EXPORT_SYMBOL (security_bdev_setintegrity);
This might be a good place to explicitly document that the block device's integrity properties may change over the lifetime of the block device and that LSMs *must* (not "should") handle all possible types of updates, including updates from a non-NULL value of a property to a NULL value.
- Eric
PATCH v19 12/20 dm verity: expose root hash digest and signature data to LSMs
In reply to Fan WuFrom: Deven Bowers <[email protected]>
dm-verity provides a strong guarantee of a block device's integrity. As a generic way to check the integrity of a block device, it provides those integrity guarantees to its higher layers, including the filesystem level.
An LSM that control access to a resource on the system based on the available integrity claims can use this transitive property of dm-verity, by querying the underlying block_device of a particular file.
The digest and signature information need to be stored in the block device to fulfill the next requirement of authorization via LSM policy. This will enable the LSM to perform revocation of devices that are still mounted, prohibiting execution of files that are no longer authorized by the LSM in question.
This patch adds two security hook calls in dm-verity to expose the dm-verity roothash and the roothash signature to LSMs via preresume callback. The hook calls are depended on CONFIG_SECURITY.
---
v2:
+ No Changes
v3:
+ No changes
v4:
+ No changes
v5:
+ No changes
v6:
+ Fix an improper cleanup that can result in
a leak
v7:
+ Squash patch 08/12, 10/12 to [11/16]
+ Use part0 for block_device, to retrieve the block_device, when calling security_bdev_setsecurity
v8:
+ Undo squash of 08/12, 10/12 - separating drivers/md/ from security/ & block/
+ Use common-audit function for dmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduced dm_verity_digest structure introduced in patch 14/20.
+ Create new structure, dm_verity_digest, containing digest algorithm, size, and digest itself to pass to the LSM layer. V7 was missing the algorithm.
+ Create an associated public header containing this new structure and the key values for the LSM hook, specific to dm-verity.
+ Additional information added to commit, discussing the layering of the changes and how the information passed will be used.
v9:
+ No changes
v10:
+ No changes
v11:
+ Add an optional field to save signature
+ Move the security hook call to the new finalize hook
v12:
+ No changes
v13:
+ No changes
v14:
+ Correct code format
+ Remove unnecessary header and switch to dm_disk()
v15:
+ Refactor security_bdev_setsecurity() to security_bdev_setintegrity()
+ Remove unnecessary headers
v16:
+ Use kmemdup to duplicate signature
+ Clean up lsm blob data in error case
v17:
+ Switch to depend on CONFIG_SECURITY
+ Use new enum name LSM_INT_DMVERITY_SIG_VALID
v18:
+ Amend commit title
+ Fix incorrect error handling
+ Make signature exposure depends on CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG
+ Fix inaccurate comment
+ Remove include/linux/dm-verity.h
+ use crypto_ahash_alg_name(v->tfm) instead of v->alg_name
v19:
+ Drop finalize callback and switch to preresume callback
+ Adding NULL check to avoid kmemdup when sig is NULL
--- drivers/md/dm-verity-target.c | 108 ++++++++++++++++++++++++++++++++++ drivers/md/dm-verity.h | 6 ++ include/linux/security.h | 9 ++- 3 files changed, 122 insertions(+), 1 deletion(-)
drivers/md/dm-verity-target.c +108 -0
@@ -22,6 +22,7 @@#include <linux/scatterlist.h> #include <linux/string.h> #include <linux/jump_label.h> +#include <linux/security.h> #define DM_MSG_PREFIX "verity"
@@ -1017,6 +1018,41 @@ static void verity_io_hints(struct dm_target *ti, struct queue_limits *limits)blk_limits_io_min (limits, limits->logical_block_size); } +#ifdef CONFIG_SECURITY + +static int verity_init_sig (struct dm_verity *v,const void *sig, +size_t sig_size) +{ + v->sig_size = sig_size; + +if (sig) { + v->root_digest_sig =kmemdup (sig, v->sig_size,GFP_KERNEL ); +if (!v->root_digest_sig) +return -ENOMEM ; + } + +return 0 ; +} + +static void verity_free_sig (struct dm_verity *v) +{ +kfree (v->root_digest_sig); +} + +#else + +static inline int verity_init_sig (struct dm_verity *v,const void *sig, +size_t sig_size) +{ +return 0 ; +} + +static inline void verity_free_sig (struct dm_verity *v) +{ +} + +#endif /* CONFIG_SECURITY */ +static void verity_dtr (struct dm_target *ti) {struct dm_verity *v = ti->private;
@@ -1035,6 +1071,7 @@ static void verity_dtr(struct dm_target *ti)kfree (v->salt);kfree (v->root_digest);kfree (v->zero_digest); +verity_free_sig (v);if (v->tfm)crypto_free_ahash (v->tfm);
@@ -1434,6 +1471,13 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->error ="Root hash verification failed" ; goto bad; } + + r =verity_init_sig (v, verify_args.sig, verify_args.sig_size); +if (r <0 ) { + ti->error ="Cannot allocate root digest signature" ; + goto bad; + } + v->hash_per_block_bits =__fls ((1 << v->hash_dev_block_bits) / v->digest_size);
@@ -1584,6 +1628,67 @@ int dm_verity_get_root_digest(struct dm_target *ti, u8 **root_digest, unsigned ireturn 0 ; } +#ifdef CONFIG_SECURITY + +#ifdef CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG + +static int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return security_bdev_setintegrity (bdev, +LSM_INT_DMVERITY_SIG_VALID , + v->root_digest_sig, + v->sig_size); +} + +#else + +static inline int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return 0 ; +} + +#endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */ + +/* +* Expose verity target's root hash and signature data to LSMs before resume. +* +* Returns 0 on success, or -ENOMEM if the system is out of memory. +*/ +static int verity_preresume (struct dm_target *ti) +{ +struct block_device *bdev; +struct dm_verity_digest root_digest; +struct dm_verity *v; +int r; + + v = ti->private; + bdev =dm_disk (dm_table_get_md (ti->table))->part0; + root_digest.digest = v->root_digest; + root_digest.digest_len = v->digest_size; + root_digest.alg =crypto_ahash_alg_name (v->tfm); + + r =security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH , &root_digest, +sizeof (root_digest)); +if (r) +return r; + + r =verity_security_set_signature (bdev, v); +if (r) + goto bad; + +return 0 ; + +bad: + +security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH ,NULL ,0 ); + +return r; +} + +#endif /* CONFIG_SECURITY */ +static struct target_type verity_target = { .name ="verity" , .features =DM_TARGET_SINGLETON |DM_TARGET_IMMUTABLE ,
@@ -1596,6 +1701,9 @@ static struct target_type verity_target = { .prepare_ioctl = verity_prepare_ioctl, .iterate_devices = verity_iterate_devices, .io_hints = verity_io_hints, +#ifdef CONFIG_SECURITY + .preresume = verity_preresume, +#endif /* CONFIG_SECURITY */ };module_dm (verity);
drivers/md/dm-verity.h +6 -0
@@ -43,6 +43,9 @@ struct dm_verity {u8 *root_digest;/* digest of the root block */ u8 *salt;/* salt: its size is salt_size */ u8 *zero_digest;/* digest for a zero block */ +#ifdef CONFIG_SECURITY +u8 *root_digest_sig;/* signature of the root digest */ +#endif /* CONFIG_SECURITY */ unsigned int salt_size;sector_t data_start;/* data offset in 512-byte sectors */ sector_t hash_start;/* hash start in blocks */
@@ -56,6 +59,9 @@ struct dm_verity { bool hash_failed:1; /* set if hash of any block failed */ bool use_bh_wq:1; /* try to verify in BH wq before normal work-queue */unsigned int digest_size;/* digest size for the current hash algorithm */ +#ifdef CONFIG_SECURITY +unsigned int sig_size;/* root digest signature size */ +#endif /* CONFIG_SECURITY */ unsigned int ahash_reqsize;/* the size of temporary space for crypto */ enum verity_mode mode;/* mode for handling verification errors */ unsigned int corrupted_errs;/* Number of errors for corrupted blocks */
include/linux/security.h +8 -1
@@ -83,8 +83,15 @@ enum lsm_event { LSM_POLICY_CHANGE, }; +struct dm_verity_digest { +const char *alg; +const u8 *digest; +size_t digest_len; +}; +enum lsm_integrity_type { - __LSM_INT_MAX +LSM_INT_DMVERITY_SIG_VALID , +LSM_INT_DMVERITY_ROOTHASH , };/*
Signature · 1 line
2.44.0
Re: [PATCH v19 12/20] dm verity: expose root hash digest and signature data to LSMs
Quoted 312 lines · Fan Wu
From: Deven Bowers <[email protected]>
dm-verity provides a strong guarantee of a block device's integrity. As a generic way to check the integrity of a block device, it provides those integrity guarantees to its higher layers, including the filesystem level.
An LSM that control access to a resource on the system based on the available integrity claims can use this transitive property of dm-verity, by querying the underlying
block_deviceof a particular file.The digest and signature information need to be stored in the block device to fulfill the next requirement of authorization via LSM policy. This will enable the LSM to perform revocation of devices that are still mounted, prohibiting execution of files that are no longer authorized by the LSM in question.
This patch adds two security hook calls in dm-verity to expose the dm-verity roothash and the roothash signature to LSMs via preresume callback. The hook calls are depended on
CONFIG_SECURITY.Signed-off-by Deven Bowers <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v2:
+ No Changesv3:
+ No changesv4:
+ No changesv5:
+ No changesv6:
+ Fix an improper cleanup that can result in
a leakv7:
+ Squash patch 08/12, 10/12 to [11/16]
+ Use part0 forblock_device, to retrieve theblock_device, when callingsecurity_bdev_setsecurityv8:
+ Undo squash of 08/12, 10/12 - separatingdrivers/md/fromsecurity/&block/
+ Use common-audit function fordmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduceddm_verity_digeststructure introduced in patch 14/20.
+ Create new structure,dm_verity_digest, containing digest algorithm, size, and digest itself to pass to the LSM layer. V7 was missing the algorithm.
+ Create an associated public header containing this new structure and the key values for the LSM hook, specific to dm-verity.
+ Additional information added to commit, discussing the layering of the changes and how the information passed will be used.v9:
+ No changesv10:
+ No changesv11:
+ Add an optional field to save signature
+ Move the security hook call to the new finalize hookv12:
+ No changesv13:
+ No changesv14:
+ Correct code format
+ Remove unnecessary header and switch todm_disk()v15:
+ Refactorsecurity_bdev_setsecurity()tosecurity_bdev_setintegrity()
+ Remove unnecessary headersv16:
+ Use kmemdup to duplicate signature
+ Clean up lsm blob data in error casev17:
+ Switch to depend onCONFIG_SECURITY
+ Use new enum nameLSM_INT_DMVERITY_SIG_VALIDv18:
+ Amend commit title
+ Fix incorrect error handling
+ Make signature exposure depends onCONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG
+ Fix inaccurate comment
+ Removeinclude/linux/dm-verity.h
+ usecrypto_ahash_alg_name(v->tfm)instead ofv->alg_namev19:
+ Drop finalize callback and switch to preresume callback
+ Adding NULL check to avoid kmemdup when sig is NULL--- drivers/md/dm-verity-target.c | 108 ++++++++++++++++++++++++++++++++++ drivers/md/dm-verity.h | 6 ++ include/linux/security.h | 9 ++- 3 files changed, 122 insertions(+), 1 deletion(-)drivers/md/dm-verity-target.c +108
-0@@ -22,6 +22,7 @@#include <linux/scatterlist.h> #include <linux/string.h> #include <linux/jump_label.h> +#include <linux/security.h> #define DM_MSG_PREFIX "verity"@@ -1017,6 +1018,41 @@ static void verity_io_hints(struct dm_target *ti, struct queue_limits *limits)blk_limits_io_min (limits, limits->logical_block_size); } +#ifdef CONFIG_SECURITY + +static int verity_init_sig (struct dm_verity *v,const void *sig, +size_t sig_size) +{ + v->sig_size = sig_size; + +if (sig) { + v->root_digest_sig =kmemdup (sig, v->sig_size,GFP_KERNEL ); +if (!v->root_digest_sig) +return -ENOMEM ; + } + +return 0 ; +} + +static void verity_free_sig (struct dm_verity *v) +{ +kfree (v->root_digest_sig); +} + +#else + +static inline int verity_init_sig (struct dm_verity *v,const void *sig, +size_t sig_size) +{ +return 0 ; +} + +static inline void verity_free_sig (struct dm_verity *v) +{ +} + +#endif /* CONFIG_SECURITY */ +static void verity_dtr (struct dm_target *ti) {struct dm_verity *v = ti->private;@@ -1035,6 +1071,7 @@ static void verity_dtr(struct dm_target *ti)kfree (v->salt);kfree (v->root_digest);kfree (v->zero_digest); +verity_free_sig (v);if (v->tfm)crypto_free_ahash (v->tfm);@@ -1434,6 +1471,13 @@ static int verity_ctr(struct dm_target *ti, unsigned int argc, char **argv) ti->error ="Root hash verification failed" ; goto bad; } + + r =verity_init_sig (v, verify_args.sig, verify_args.sig_size); +if (r <0 ) { + ti->error ="Cannot allocate root digest signature" ; + goto bad; + } + v->hash_per_block_bits =__fls ((1 << v->hash_dev_block_bits) / v->digest_size);@@ -1584,6 +1628,67 @@ int dm_verity_get_root_digest(struct dm_target *ti, u8 **root_digest, unsigned ireturn 0 ; } +#ifdef CONFIG_SECURITY + +#ifdef CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG + +static int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return security_bdev_setintegrity (bdev, +LSM_INT_DMVERITY_SIG_VALID , + v->root_digest_sig, + v->sig_size); +} + +#else + +static inline int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return 0 ; +} + +#endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */ + +/* +* Expose verity target's root hash and signature data to LSMs before resume. +* +* Returns 0 on success, or -ENOMEM if the system is out of memory. +*/ +static int verity_preresume (struct dm_target *ti) +{ +struct block_device *bdev; +struct dm_verity_digest root_digest; +struct dm_verity *v; +int r; + + v = ti->private; + bdev =dm_disk (dm_table_get_md (ti->table))->part0; + root_digest.digest = v->root_digest; + root_digest.digest_len = v->digest_size; + root_digest.alg =crypto_ahash_alg_name (v->tfm); + + r =security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH , &root_digest, +sizeof (root_digest)); +if (r) +return r; + + r =verity_security_set_signature (bdev, v); +if (r) + goto bad; + +return 0 ; + +bad: + +security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH ,NULL ,0 ); + +return r; +} + +#endif /* CONFIG_SECURITY */ +static struct target_type verity_target = { .name ="verity" , .features =DM_TARGET_SINGLETON |DM_TARGET_IMMUTABLE ,@@ -1596,6 +1701,9 @@ static struct target_type verity_target = { .prepare_ioctl = verity_prepare_ioctl, .iterate_devices = verity_iterate_devices, .io_hints = verity_io_hints, +#ifdef CONFIG_SECURITY + .preresume = verity_preresume, +#endif /* CONFIG_SECURITY */ };module_dm (verity);drivers/md/dm-verity.h +6
-0@@ -43,6 +43,9 @@ struct dm_verity {u8 *root_digest;/* digest of the root block */ u8 *salt;/* salt: its size is salt_size */ u8 *zero_digest;/* digest for a zero block */ +#ifdef CONFIG_SECURITY +u8 *root_digest_sig;/* signature of the root digest */ +#endif /* CONFIG_SECURITY */ unsigned int salt_size;sector_t data_start;/* data offset in 512-byte sectors */ sector_t hash_start;/* hash start in blocks */ @@ -56,6 +59,9 @@ struct dm_verity { bool hash_failed:1; /* set if hash of any block failed */ bool use_bh_wq:1; /* try to verify in BH wq before normal work-queue */unsigned int digest_size;/* digest size for the current hash algorithm */ +#ifdef CONFIG_SECURITY +unsigned int sig_size;/* root digest signature size */ +#endif /* CONFIG_SECURITY */ unsigned int ahash_reqsize;/* the size of temporary space for crypto */ enum verity_mode mode;/* mode for handling verification errors */ unsigned int corrupted_errs;/* Number of errors for corrupted blocks */ include/linux/security.h +8
-1@@ -83,8 +83,15 @@ enum lsm_event { LSM_POLICY_CHANGE, }; +struct dm_verity_digest { +const char *alg; +const u8 *digest; +size_t digest_len; +}; +enum lsm_integrity_type { - __LSM_INT_MAX +LSM_INT_DMVERITY_SIG_VALID , +LSM_INT_DMVERITY_ROOTHASH , };/* Signature · 1 line
2.44.0
Eric Biggers
maintainerRe: [PATCH v19 12/20] dm verity: expose root hash digest and signature data to LSMs
In reply to Fan WuQuoted 54 lines · Fan Wu
drivers/md/dm-verity-target.c +54
-0+#ifdef CONFIG_SECURITY + +#ifdef CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG + +static int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return security_bdev_setintegrity (bdev, +LSM_INT_DMVERITY_SIG_VALID , + v->root_digest_sig, + v->sig_size); +} + +#else + +static inline int verity_security_set_signature (struct block_device *bdev, +struct dm_verity *v) +{ +return 0 ; +} + +#endif /* CONFIG_DM_VERITY_VERIFY_ROOTHASH_SIG */ + +/* +* Expose verity target's root hash and signature data to LSMs before resume. +* +* Returns 0 on success, or -ENOMEM if the system is out of memory. +*/ +static int verity_preresume (struct dm_target *ti) +{ +struct block_device *bdev; +struct dm_verity_digest root_digest; +struct dm_verity *v; +int r; + + v = ti->private; + bdev =dm_disk (dm_table_get_md (ti->table))->part0; + root_digest.digest = v->root_digest; + root_digest.digest_len = v->digest_size; + root_digest.alg =crypto_ahash_alg_name (v->tfm); + + r =security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH , &root_digest, +sizeof (root_digest)); +if (r) +return r; + + r =verity_security_set_signature (bdev, v); +if (r) + goto bad; + +return 0 ; + +bad: +
drivers/md/dm-verity-target.c int dm_verity_get_root_digest(struct dm_target *ti, u8 **root_digest, unsigned i · line 1694
Quoted 10 lines
drivers/md/dm-verity-target.c +7
-0+security_bdev_setintegrity (bdev,LSM_INT_DMVERITY_ROOTHASH ,NULL ,0 ); + +return r; +} + +#endif /* CONFIG_SECURITY */ +static struct target_type verity_target = { .name ="verity" , .features =DM_TARGET_SINGLETON |DM_TARGET_IMMUTABLE ,
Due to the possibility of table reloads, it looks like the security of this scheme is dependent on (a) DM_TARGET_SINGLETON, (b) DM_TARGET_IMMUTABLE, *and*
(c) sending LSM_INT_DMVERITY_ROOTHASH and LSM_INT_DMVERITY_SIG_VALID to the LSM(s) even when there is no signature. Notably, this differs from the similar-looking code in fsverity where updates are not possible and LSM_INT_FSVERITY_BUILTINSIG_VALID is not sent when there's no signature.
Given the subtleties here and the fact that getting any of these things wrong would allow the LSM checks to be bypassed, it would really be worth leaving a comment that explicitly documents why this is secure. And maybe also a /* Note: singleton and immutable are depended on by the LSM hooks */ just above the 'DM_TARGET_SINGLETON | DM_TARGET_IMMUTABLE' in case someone tries to remove those. I see they were added only recently, which was a breaking UAPI change, so I worry about people trying to revert it.
- Eric
PATCH v19 13/20 ipe: add support for dm-verity as a trust provider
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Allows author of IPE policy to indicate trust for a singular dm-verity volume, identified by roothash, through "dmverity_roothash" and all signed and validated dm-verity volumes, through "dmverity_signature".
---
v2:
+ No Changes
v3:
+ No changes
v4:
+ No changes
v5:
+ No changes
v6:
+ Fix an improper cleanup that can result in
a leak
v7:
+ Squash patch 08/12, 10/12 to [11/16]
v8:
+ Undo squash of 08/12, 10/12 - separating drivers/md/ from security/ & block/
+ Use common-audit function for dmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduced dm_verity_digest structure introduced in patch 14/20.
v9:
+ Adapt to the new parser
v10:
+ Select the Kconfig when all dependencies are enabled
v11:
+ No changes
v12:
+ Refactor to use struct digest_info* instead of void*
+ Correct audit format
v13:
+ Remove the CONFIG_IPE_PROP_DM_VERITY dependency inside the parser to make the policy grammar independent of the kernel config.
v14:
+ No changes
v15:
+ Fix one grammar issue in KCONFIG
+ Switch to use security_bdev_setintegrity() hook
v16:
+ Refactor for enum integrity type
v17:
+ Add years to license header
+ Fix code and documentation style issues
+ Return -EINVAL in ipe_bdev_setintegrity when passed type is not supported
+ Use new enum name LSM_INT_DMVERITY_SIG_VALID
v18:
+ Add Kconfig IPE_PROP_DM_VERITY_SIGNATURE and make both DM_VERITY config auto-selected
v19:
+ No changes
--- security/ipe/Kconfig | 27 ++++++++ security/ipe/Makefile | 1 + security/ipe/audit.c | 29 ++++++++- security/ipe/digest.c | 118 +++++++++++++++++++++++++++++++++++ security/ipe/digest.h | 26 ++++++++ security/ipe/eval.c | 93 ++++++++++++++++++++++++++- security/ipe/eval.h | 12 ++++ security/ipe/hooks.c | 93 +++++++++++++++++++++++++++ security/ipe/hooks.h | 8 +++ security/ipe/ipe.c | 15 +++++ security/ipe/ipe.h | 4 ++ security/ipe/policy.h | 3 + security/ipe/policy_parser.c | 24 ++++++- 13 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 security/ipe/digest.c create mode 100644 security/ipe/digest.h
security/ipe/Kconfig +27 -0
@@ -8,6 +8,8 @@ menuconfig SECURITY_IPE depends on SECURITY && SECURITYFS && AUDIT && AUDITSYSCALL select PKCS7_MESSAGE_PARSER select SYSTEM_DATA_VERIFICATION + select IPE_PROP_DM_VERITY if DM_VERITY + select IPE_PROP_DM_VERITY_SIGNATURE if DM_VERITY && DM_VERITY_VERIFY_ROOTHASH_SIG help This option enables the Integrity Policy Enforcement LSM allowing users to define a policy to enforce a trust-based access
@@ -15,3 +17,28 @@ menuconfig SECURITY_IPE admins to reconfigure trust requirements on the fly. If unsure, answer N. + +if SECURITY_IPE +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. + +endmenu + +endif
security/ipe/Makefile +1 -0
@@ -6,6 +6,7 @@ # obj-$(CONFIG_SECURITY_IPE) += \ + digest.o \ eval.o \ hooks.o \ fs.o \
security/ipe/audit.c +27 -2
@@ -13,6 +13,7 @@#include "hooks.h" #include "policy.h" #include "audit.h" +#include "digest.h" #define ACTSTR (x) ((x) == IPE_ACTION_ALLOW ? "ALLOW" : "DENY")
@@ -49,8 +50,22 @@ static const char *const audit_hook_names[__IPE_HOOK_MAX] = {static const char *const audit_prop_names[__IPE_PROP_MAX] = {"boot_verified=FALSE" ,"boot_verified=TRUE" , +"dmverity_roothash=" , +"dmverity_signature=FALSE" , +"dmverity_signature=TRUE" , }; +/** +* audit_dmv_roothash() - audit the roothash of a dmverity_roothash property. +* @ab: Supplies a pointer to the audit_buffer to append to. +* @rh: Supplies a pointer to the digest structure. +*/ +static void audit_dmv_roothash (struct audit_buffer *ab,const void *rh) +{ +audit_log_format (ab,"%s" , audit_prop_names[IPE_PROP_DMV_ROOTHASH ]); +ipe_digest_audit (ab, rh); +} +/** * audit_rule() - audit an IPE policy rule. * @ab: Supplies a pointer to the audit_buffer to append to.
@@ -62,8 +77,18 @@ static void audit_rule(struct audit_buffer *ab, const struct ipe_rule *r)audit_log_format (ab," rule=\"%s " , audit_op_names[r->op]); -list_for_each_entry (ptr, &r->props, next) -audit_log_format (ab,"%s " , audit_prop_names[ptr->type]); +list_for_each_entry (ptr, &r->props, next) { +switch (ptr->type) { +case IPE_PROP_DMV_ROOTHASH : +audit_dmv_roothash (ab, ptr->value); +break ; +default : +audit_log_format (ab,"%s" , audit_prop_names[ptr->type]); +break ; + } + +audit_log_format (ab," " ); + }audit_log_format (ab,"action=%s\"" ,ACTSTR (r->action)); }
security/ipe/digest.c new file +118 -0
118 lines not on this page · raw message
security/ipe/digest.h new file +26 -0
@@ -0,0 +1,26 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* +* Copyright (C) 2020-2024 Microsoft Corporation. All rights reserved. +*/ + +#ifndef _IPE_DIGEST_H +#define _IPE_DIGEST_H + +#include <linux/types.h> +#include <linux/audit.h> + +#include "policy.h" + +struct digest_info { +const char *alg; +const u8 *digest; +size_t digest_len; +}; + +struct digest_info *ipe_digest_parse (const char *valstr); +void ipe_digest_free (struct digest_info *digest_info); +void ipe_digest_audit (struct audit_buffer *ab,const struct digest_info *val); +bool ipe_digest_eval (const struct digest_info *expected, +const struct digest_info *digest); + +#endif /* _IPE_DIGEST_H */
security/ipe/eval.c +92 -1
128 lines not on this page · raw message
security/ipe/eval.h +12 -0
@@ -22,12 +22,24 @@ struct ipe_superblock {bool initramfs; }; +#ifdef CONFIG_IPE_PROP_DM_VERITY +struct ipe_bdev { +#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE +bool dm_verity_signed; +#endif /* CONFIG_IPE_PROP_DM_VERITY_SIGNATURE */ +struct digest_info *root_hash; +}; +#endif /* CONFIG_IPE_PROP_DM_VERITY */ +struct ipe_eval_ctx {enum ipe_op_type op;enum ipe_hook_type hook;const struct file *file;bool initramfs; +#ifdef CONFIG_IPE_PROP_DM_VERITY +const struct ipe_bdev *ipe_bdev; +#endif /* CONFIG_IPE_PROP_DM_VERITY */ };enum ipe_match {
security/ipe/hooks.c +93 -0
106 lines not on this page · raw message
security/ipe/hooks.h +8 -0
@@ -8,6 +8,7 @@#include <linux/fs.h> #include <linux/binfmts.h> #include <linux/security.h> +#include <linux/blk_types.h> enum ipe_hook_type {IPE_HOOK_BPRM_CHECK =0 ,
@@ -35,4 +36,11 @@ int ipe_kernel_load_data(enum kernel_load_data_id id, bool contents);void ipe_unpack_initramfs (void ); +#ifdef CONFIG_IPE_PROP_DM_VERITY +void ipe_bdev_free_security (struct block_device *bdev); + +int ipe_bdev_setintegrity (struct block_device *bdev,enum lsm_integrity_type type, +const void *value,size_t len); +#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#endif /* _IPE_HOOKS_H */
security/ipe/ipe.c +15 -0
@@ -7,11 +7,15 @@#include "ipe.h" #include "eval.h" #include "hooks.h" +#include "eval.h" bool ipe_enabled;static struct lsm_blob_sizes ipe_blobs__ro_after_init = { .lbs_superblock =sizeof (struct ipe_superblock ), +#ifdef CONFIG_IPE_PROP_DM_VERITY + .lbs_bdev =sizeof (struct ipe_bdev ), +#endif /* CONFIG_IPE_PROP_DM_VERITY */ };static const struct lsm_id ipe_lsmid = {
@@ -24,6 +28,13 @@ struct ipe_superblock *ipe_sb(const struct super_block *sb)return sb->s_security + ipe_blobs.lbs_superblock; } +#ifdef CONFIG_IPE_PROP_DM_VERITY +struct ipe_bdev *ipe_bdev (struct block_device *b) +{ +return b->security + ipe_blobs.lbs_bdev; +} +#endif /* CONFIG_IPE_PROP_DM_VERITY */ +static struct security_hook_list ipe_hooks[]__ro_after_init = {LSM_HOOK_INIT (bprm_check_security, ipe_bprm_check_security),LSM_HOOK_INIT (mmap_file, ipe_mmap_file),
@@ -31,6 +42,10 @@ static struct security_hook_list ipe_hooks[] __ro_after_init = {LSM_HOOK_INIT (kernel_read_file, ipe_kernel_read_file),LSM_HOOK_INIT (kernel_load_data, ipe_kernel_load_data),LSM_HOOK_INIT (initramfs_populated, ipe_unpack_initramfs), +#ifdef CONFIG_IPE_PROP_DM_VERITY +LSM_HOOK_INIT (bdev_free_security, ipe_bdev_free_security), + LSM_HOOK_INIT(bdev_setintegrity, ipe_bdev_setintegrity), +#endif /* CONFIG_IPE_PROP_DM_VERITY */ };/**
security/ipe/ipe.h +4 -0
@@ -16,4 +16,8 @@ struct ipe_superblock *ipe_sb(const struct super_block *sb);extern bool ipe_enabled; +#ifdef CONFIG_IPE_PROP_DM_VERITY +struct ipe_bdev *ipe_bdev (struct block_device *b); +#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#endif /* _IPE_H */
security/ipe/policy.h +3 -0
@@ -33,6 +33,9 @@ enum ipe_action_type {enum ipe_prop_type {IPE_PROP_BOOT_VERIFIED_FALSE ,IPE_PROP_BOOT_VERIFIED_TRUE , +IPE_PROP_DMV_ROOTHASH , +IPE_PROP_DMV_SIG_FALSE , +IPE_PROP_DMV_SIG_TRUE , __IPE_PROP_MAX };
security/ipe/policy_parser.c +23 -1
@@ -11,6 +11,7 @@#include "policy.h" #include "policy_parser.h" +#include "digest.h" #define START_COMMENT '#'#define IPE_POLICY_DELIM " \t"
@@ -221,6 +222,7 @@ static void free_rule(struct ipe_rule *r)list_for_each_entry_safe (p, t, &r->props, next) {list_del (&p->next); +ipe_digest_free (p->value);kfree (p); }
@@ -273,6 +275,9 @@ static enum ipe_action_type parse_action(char *t)static const match_table_t property_tokens = { {IPE_PROP_BOOT_VERIFIED_FALSE ,"boot_verified=FALSE" }, {IPE_PROP_BOOT_VERIFIED_TRUE ,"boot_verified=TRUE" }, + {IPE_PROP_DMV_ROOTHASH ,"dmverity_roothash=%s" }, + {IPE_PROP_DMV_SIG_FALSE ,"dmverity_signature=FALSE" }, + {IPE_PROP_DMV_SIG_TRUE ,"dmverity_signature=TRUE" }, {IPE_PROP_INVALID ,NULL } };
@@ -295,6 +300,7 @@ static int parse_property(char *t, struct ipe_rule *r)struct ipe_prop *p =NULL ;int rc =0 ;int token; +char *dup =NULL ; p =kzalloc (sizeof (*p),GFP_KERNEL );if (!p)
@@ -303,8 +309,22 @@ static int parse_property(char *t, struct ipe_rule *r) token =match_token (t, property_tokens, args);switch (token) { +case IPE_PROP_DMV_ROOTHASH : + dup =match_strdup (&args[0 ]); +if (!dup) { + rc = -ENOMEM ; + goto err; + } + p->value =ipe_digest_parse (dup); +if (IS_ERR (p->value)) { + rc =PTR_ERR (p->value); + goto err; + } + fallthrough;case IPE_PROP_BOOT_VERIFIED_FALSE :case IPE_PROP_BOOT_VERIFIED_TRUE : +case IPE_PROP_DMV_SIG_FALSE : +case IPE_PROP_DMV_SIG_TRUE : p->type = token;break ;default :
@@ -315,10 +335,12 @@ static int parse_property(char *t, struct ipe_rule *r) goto err;list_add_tail (&p->next, &r->props); +out: +kfree (dup);return rc; err:kfree (p); -return rc; + goto out; }/**
Signature · 1 line
2.44.0
Paul Moore
maintainerRe: [PATCH v19 13/20] ipe: add support for dm-verity as a trust provider
Quoted 92 lines · On May 24, 2024 Fan Wu <[email protected]> wrote:
Allows author of IPE policy to indicate trust for a singular dm-verity volume, identified by roothash, through "
dmverity_roothash" and all signed and validated dm-verity volumes, through "dmverity_signature".Signed-off-by Deven Bowers <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v2:
+ No Changesv3:
+ No changesv4:
+ No changesv5:
+ No changesv6:
+ Fix an improper cleanup that can result in
a leakv7:
+ Squash patch 08/12, 10/12 to [11/16]v8:
+ Undo squash of 08/12, 10/12 - separatingdrivers/md/fromsecurity/&block/
+ Use common-audit function fordmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduceddm_verity_digeststructure introduced in patch 14/20.v9:
+ Adapt to the new parserv10:
+ Select theKconfigwhen all dependencies are enabledv11:
+ No changesv12:
+ Refactor to use struct digest_info* instead of void*
+ Correct audit formatv13:
+ Remove theCONFIG_IPE_PROP_DM_VERITYdependency inside the parser to make the policy grammar independent of the kernel config.v14:
+ No changesv15:
+ Fix one grammar issue in KCONFIG
+ Switch to usesecurity_bdev_setintegrity()hookv16:
+ Refactor for enum integrity typev17:
+ Add years to license header
+ Fix code and documentation style issues
+ Return-EINVALinipe_bdev_setintegritywhen passed type is not supported
+ Use new enum nameLSM_INT_DMVERITY_SIG_VALIDv18:
+ AddKconfigIPE_PROP_DM_VERITY_SIGNATUREand make bothDM_VERITYconfig auto-selectedv19:
+ No changes--- security/ipe/Kconfig | 27 ++++++++ security/ipe/Makefile | 1 + security/ipe/audit.c | 29 ++++++++- security/ipe/digest.c | 118 +++++++++++++++++++++++++++++++++++ security/ipe/digest.h | 26 ++++++++ security/ipe/eval.c | 93 ++++++++++++++++++++++++++- security/ipe/eval.h | 12 ++++ security/ipe/hooks.c | 93 +++++++++++++++++++++++++++ security/ipe/hooks.h | 8 +++ security/ipe/ipe.c | 15 +++++ security/ipe/ipe.h | 4 ++ security/ipe/policy.h | 3 + security/ipe/policy_parser.c | 24 ++++++- 13 files changed, 449 insertions(+), 4 deletions(-) create mode 100644 security/ipe/digest.c create mode 100644 security/ipe/digest.h
...
Quoted 73 lines
security/ipe/hooks.c +65
-0@@ -191,3 +193,94 @@ void ipe_unpack_initramfs(void) {ipe_sb (current->fs->root.mnt->mnt_sb)->initramfs = true; } + +#ifdef CONFIG_IPE_PROP_DM_VERITY +/** +* ipe_bdev_free_security() - Free IPE's LSM blob of block_devices. +* @bdev: Supplies a pointer to a block_device that contains the structure +* to free. +*/ +void ipe_bdev_free_security (struct block_device *bdev) +{ +struct ipe_bdev *blob =ipe_bdev (bdev); + +ipe_digest_free (blob->root_hash); +} + +#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE +static void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ + blob->dm_verity_signed = size >0 && value; +} +#else +static inline void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ +} +#endif /* CONFIG_IPE_PROP_DM_VERITY_SIGNATURE */ + +/** +* ipe_bdev_setintegrity() - Save integrity data from a bdev to IPE's LSM blob. +* @bdev: Supplies a pointer to a block_device that contains the LSM blob. +* @type: Supplies the integrity type. +* @value: Supplies the value to store. +* @size: The size of @value. +* +* This hook is currently used to save dm-verity's root hash or the existence +* of a validated signed dm-verity root hash into LSM blob. +* +* Return: %0 on success. If an error occurs, the function will return the +* -errno. +*/ +int ipe_bdev_setintegrity (struct block_device *bdev,enum lsm_integrity_type type, +const void *value,size_t size) +{ +const struct dm_verity_digest *digest =NULL ; +struct ipe_bdev *blob =ipe_bdev (bdev); +struct digest_info *info =NULL ; + +if (type ==LSM_INT_DMVERITY_ROOTHASH ) { +if (!value) { +ipe_digest_free (blob->root_hash); + blob->root_hash =NULL ; + +return 0 ; + } + digest = value; + + info =kzalloc (sizeof (*info),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->digest =kmemdup (digest->digest, digest->digest_len, +GFP_KERNEL ); +if (!info->digest)
security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 270
Quoted 10 lines
security/ipe/hooks.c +10
-0+ goto dmv_roothash_err; + + info->alg =kstrdup (digest->alg,GFP_KERNEL ); +if (!info->alg) + goto dmv_roothash_err; + + info->digest_len = digest->digest_len; + +if (blob->root_hash) +ipe_digest_free (blob->root_hash);
The above if/free looks like a new addition from v18 and I'm not quite sure why the blob->root_hash NULL check is necessary as ipe_digest_free() does a IS_ERR_OR_NULL() check right at the top.
Likely harmless and doubtful to have any noticable performance impact, but I wanted to mention it just in case ...
Quoted 6 lines
security/ipe/hooks.c +6
-0+ blob->root_hash = info; + +return 0 ; +dmv_roothash_err: +ipe_digest_free (info); +
security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 286
Quoted 10 lines
security/ipe/hooks.c +10
-0+ return -ENOMEM; + }else if (type ==LSM_INT_DMVERITY_SIG_VALID ) { +ipe_set_dmverity_signature (blob, value, size); + +return 0 ; + } + +return -EINVAL ; +} +#endif /* CONFIG_IPE_PROP_DM_VERITY */
--
paul-moore.com
Re: [PATCH v19 13/20] ipe: add support for dm-verity as a trust provider
Quoted 184 lines · Paul Moore
Quoted 92 lines · On May 24, 2024 Fan Wu <[email protected]> wrote:
Allows author of IPE policy to indicate trust for a singular dm-verity volume, identified by roothash, through "
dmverity_roothash" and all signed and validated dm-verity volumes, through "dmverity_signature".Signed-off-by Deven Bowers <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v2:
+ No Changesv3:
+ No changesv4:
+ No changesv5:
+ No changesv6:
+ Fix an improper cleanup that can result in
a leakv7:
+ Squash patch 08/12, 10/12 to [11/16]v8:
+ Undo squash of 08/12, 10/12 - separatingdrivers/md/fromsecurity/&block/
+ Use common-audit function fordmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduceddm_verity_digeststructure introduced in patch 14/20.v9:
+ Adapt to the new parserv10:
+ Select theKconfigwhen all dependencies are enabledv11:
+ No changesv12:
+ Refactor to use struct digest_info* instead of void*
+ Correct audit formatv13:
+ Remove theCONFIG_IPE_PROP_DM_VERITYdependency inside the parser to make the policy grammar independent of the kernel config.v14:
+ No changesv15:
+ Fix one grammar issue in KCONFIG
+ Switch to usesecurity_bdev_setintegrity()hookv16:
+ Refactor for enum integrity typev17:
+ Add years to license header
+ Fix code and documentation style issues
+ Return-EINVALinipe_bdev_setintegritywhen passed type is not supported
+ Use new enum nameLSM_INT_DMVERITY_SIG_VALIDv18:
+ AddKconfigIPE_PROP_DM_VERITY_SIGNATUREand make bothDM_VERITYconfig auto-selectedv19:
+ No changes--- security/ipe/Kconfig | 27 ++++++++ security/ipe/Makefile | 1 + security/ipe/audit.c | 29 ++++++++- security/ipe/digest.c | 118 +++++++++++++++++++++++++++++++++++ security/ipe/digest.h | 26 ++++++++ security/ipe/eval.c | 93 ++++++++++++++++++++++++++- security/ipe/eval.h | 12 ++++ security/ipe/hooks.c | 93 +++++++++++++++++++++++++++ security/ipe/hooks.h | 8 +++ security/ipe/ipe.c | 15 +++++ security/ipe/ipe.h | 4 ++ security/ipe/policy.h | 3 + security/ipe/policy_parser.c | 24 ++++++- 13 files changed, 449 insertions(+), 4 deletions(-)create mode 100644
security/ipe/digest.c
create mode 100644security/ipe/digest.h...
Quoted 73 lines
security/ipe/hooks.c +65
-0@@ -191,3 +193,94 @@ void ipe_unpack_initramfs(void) {ipe_sb (current->fs->root.mnt->mnt_sb)->initramfs = true; } + +#ifdef CONFIG_IPE_PROP_DM_VERITY +/** +* ipe_bdev_free_security() - Free IPE's LSM blob of block_devices. +* @bdev: Supplies a pointer to a block_device that contains the structure +* to free. +*/ +void ipe_bdev_free_security (struct block_device *bdev) +{ +struct ipe_bdev *blob =ipe_bdev (bdev); + +ipe_digest_free (blob->root_hash); +} + +#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE +static void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ + blob->dm_verity_signed = size >0 && value; +} +#else +static inline void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ +} +#endif /* CONFIG_IPE_PROP_DM_VERITY_SIGNATURE */ + +/** +* ipe_bdev_setintegrity() - Save integrity data from a bdev to IPE's LSM blob. +* @bdev: Supplies a pointer to a block_device that contains the LSM blob. +* @type: Supplies the integrity type. +* @value: Supplies the value to store. +* @size: The size of @value. +* +* This hook is currently used to save dm-verity's root hash or the existence +* of a validated signed dm-verity root hash into LSM blob. +* +* Return: %0 on success. If an error occurs, the function will return the +* -errno. +*/ +int ipe_bdev_setintegrity (struct block_device *bdev,enum lsm_integrity_type type, +const void *value,size_t size) +{ +const struct dm_verity_digest *digest =NULL ; +struct ipe_bdev *blob =ipe_bdev (bdev); +struct digest_info *info =NULL ; + +if (type ==LSM_INT_DMVERITY_ROOTHASH ) { +if (!value) { +ipe_digest_free (blob->root_hash); + blob->root_hash =NULL ; + +return 0 ; + } + digest = value; + + info =kzalloc (sizeof (*info),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->digest =kmemdup (digest->digest, digest->digest_len, +GFP_KERNEL ); +if (!info->digest)security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 270
Quoted 10 lines
security/ipe/hooks.c +10
-0+ goto dmv_roothash_err; + + info->alg =kstrdup (digest->alg,GFP_KERNEL ); +if (!info->alg) + goto dmv_roothash_err; + + info->digest_len = digest->digest_len; + +if (blob->root_hash) +ipe_digest_free (blob->root_hash);The above if/free looks like a new addition from v18 and I'm not quite sure why the
blob->root_hashNULL check is necessary asipe_digest_free()does aIS_ERR_OR_NULL()check right at the top.
Quoted 3 lines
Likely harmless and doubtful to have any noticable performance impact, but I wanted to mention it just in case ...
Yes directly call ipe_digest_free() should be enough.
Also this new free is introduced because the mapped device with an existing dm-verity target can be suspended and associated with a new dm-verity target. In this case, the root hash associated with the security blob will be stale and needs to be freed before setting the new data.
-Fan
Quoted 19 lines
Quoted 6 lines
security/ipe/hooks.c +6
-0+ blob->root_hash = info; + +return 0 ; +dmv_roothash_err: +ipe_digest_free (info); +security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 286
Quoted 10 lines
security/ipe/hooks.c +10
-0+ return -ENOMEM; + }else if (type ==LSM_INT_DMVERITY_SIG_VALID ) { +ipe_set_dmverity_signature (blob, value, size); + +return 0 ; + } + +return -EINVAL ; +} +#endif /* CONFIG_IPE_PROP_DM_VERITY */ --
paul-moore.com
Jarkko Sakkinen
maintainerRe: [PATCH v19 13/20] ipe: add support for dm-verity as a trust provider
Quoted 199 lines · Fan Wu
Quoted 184 lines · Paul Moore
Quoted 92 lines · On May 24, 2024 Fan Wu <[email protected]> wrote:
Allows author of IPE policy to indicate trust for a singular dm-verity volume, identified by roothash, through "
dmverity_roothash" and all signed and validated dm-verity volumes, through "dmverity_signature".Signed-off-by Deven Bowers <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v2:
+ No Changesv3:
+ No changesv4:
+ No changesv5:
+ No changesv6:
+ Fix an improper cleanup that can result in
a leakv7:
+ Squash patch 08/12, 10/12 to [11/16]v8:
+ Undo squash of 08/12, 10/12 - separatingdrivers/md/fromsecurity/&block/
+ Use common-audit function fordmverity_signature.
+ Change implementation for storing the dm-verity digest to use the newly introduceddm_verity_digeststructure introduced in patch 14/20.v9:
+ Adapt to the new parserv10:
+ Select theKconfigwhen all dependencies are enabledv11:
+ No changesv12:
+ Refactor to use struct digest_info* instead of void*
+ Correct audit formatv13:
+ Remove theCONFIG_IPE_PROP_DM_VERITYdependency inside the parser to make the policy grammar independent of the kernel config.v14:
+ No changesv15:
+ Fix one grammar issue in KCONFIG
+ Switch to usesecurity_bdev_setintegrity()hookv16:
+ Refactor for enum integrity typev17:
+ Add years to license header
+ Fix code and documentation style issues
+ Return-EINVALinipe_bdev_setintegritywhen passed type is not supported
+ Use new enum nameLSM_INT_DMVERITY_SIG_VALIDv18:
+ AddKconfigIPE_PROP_DM_VERITY_SIGNATUREand make bothDM_VERITYconfig auto-selectedv19:
+ No changes--- security/ipe/Kconfig | 27 ++++++++ security/ipe/Makefile | 1 + security/ipe/audit.c | 29 ++++++++- security/ipe/digest.c | 118 +++++++++++++++++++++++++++++++++++ security/ipe/digest.h | 26 ++++++++ security/ipe/eval.c | 93 ++++++++++++++++++++++++++- security/ipe/eval.h | 12 ++++ security/ipe/hooks.c | 93 +++++++++++++++++++++++++++ security/ipe/hooks.h | 8 +++ security/ipe/ipe.c | 15 +++++ security/ipe/ipe.h | 4 ++ security/ipe/policy.h | 3 + security/ipe/policy_parser.c | 24 ++++++- 13 files changed, 449 insertions(+), 4 deletions(-)create mode 100644
security/ipe/digest.c
create mode 100644security/ipe/digest.h...
Quoted 73 lines
security/ipe/hooks.c +65
-0@@ -191,3 +193,94 @@ void ipe_unpack_initramfs(void) {ipe_sb (current->fs->root.mnt->mnt_sb)->initramfs = true; } + +#ifdef CONFIG_IPE_PROP_DM_VERITY +/** +* ipe_bdev_free_security() - Free IPE's LSM blob of block_devices. +* @bdev: Supplies a pointer to a block_device that contains the structure +* to free. +*/ +void ipe_bdev_free_security (struct block_device *bdev) +{ +struct ipe_bdev *blob =ipe_bdev (bdev); + +ipe_digest_free (blob->root_hash); +} + +#ifdef CONFIG_IPE_PROP_DM_VERITY_SIGNATURE +static void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ + blob->dm_verity_signed = size >0 && value; +} +#else +static inline void ipe_set_dmverity_signature (struct ipe_bdev *blob, +const void *value, +size_t size) +{ +} +#endif /* CONFIG_IPE_PROP_DM_VERITY_SIGNATURE */ + +/** +* ipe_bdev_setintegrity() - Save integrity data from a bdev to IPE's LSM blob. +* @bdev: Supplies a pointer to a block_device that contains the LSM blob. +* @type: Supplies the integrity type. +* @value: Supplies the value to store. +* @size: The size of @value. +* +* This hook is currently used to save dm-verity's root hash or the existence +* of a validated signed dm-verity root hash into LSM blob. +* +* Return: %0 on success. If an error occurs, the function will return the +* -errno. +*/ +int ipe_bdev_setintegrity (struct block_device *bdev,enum lsm_integrity_type type, +const void *value,size_t size) +{ +const struct dm_verity_digest *digest =NULL ; +struct ipe_bdev *blob =ipe_bdev (bdev); +struct digest_info *info =NULL ; + +if (type ==LSM_INT_DMVERITY_ROOTHASH ) { +if (!value) { +ipe_digest_free (blob->root_hash); + blob->root_hash =NULL ; + +return 0 ; + } + digest = value; + + info =kzalloc (sizeof (*info),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->digest =kmemdup (digest->digest, digest->digest_len, +GFP_KERNEL ); +if (!info->digest)security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 270
Quoted 10 lines
security/ipe/hooks.c +10
-0+ goto dmv_roothash_err; + + info->alg =kstrdup (digest->alg,GFP_KERNEL ); +if (!info->alg) + goto dmv_roothash_err; + + info->digest_len = digest->digest_len; + +if (blob->root_hash) +ipe_digest_free (blob->root_hash);The above if/free looks like a new addition from v18 and I'm not quite sure why the
blob->root_hashNULL check is necessary asipe_digest_free()does aIS_ERR_OR_NULL()check right at the top.Quoted 3 lines
Likely harmless and doubtful to have any noticable performance impact, but I wanted to mention it just in case ...
Yes directly call
ipe_digest_free()should be enough.Also this new free is introduced because the mapped device with an existing dm-verity target can be suspended and associated with a new dm-verity target. In this case, the root hash associated with the security blob will be stale and needs to be freed before setting the new data.
Quoted 6 lines
-Fan
Quoted 4 lines
security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 274
Quoted 4 lines
security/ipe/hooks.c +4
-0+ blob->root_hash = info; + +return 0 ; +dmv_roothash_err:
Just a nitpick but 9/10 'err' is a prefix...
Also now this patch set uses 'err'' ambiguously given the use as name of the variable to store a return code. Similar naming pattern would do miracles.
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
security/ipe/hooks.c +7
-0+ipe_digest_free (info); + +return -ENOMEM ; + }else if (type ==LSM_INT_DMVERITY_SIG_VALID ) { +ipe_set_dmverity_signature (blob, value, size); + +return 0 ;
Quoted 8 lines
Quoted 8 lines
security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 286
Quoted 5 lines
security/ipe/hooks.c +5
-0+ } + +return -EINVAL ; +} +#endif /* CONFIG_IPE_PROP_DM_VERITY */ --
paul-moore.com
BR, Jarkko
Jarkko Sakkinen
maintainerRe: [PATCH v19 13/20] ipe: add support for dm-verity as a trust provider
In reply to Paul MooreQuoted 19 lines · Paul Moore
Quoted 18 lines · On May 24, 2024 Fan Wu <[email protected]> wrote:
security/ipe/hooks.c +18
-0+if (type ==LSM_INT_DMVERITY_ROOTHASH ) { +if (!value) { +ipe_digest_free (blob->root_hash); + blob->root_hash =NULL ; + +return 0 ; + } + digest = value; + + info =kzalloc (sizeof (*info),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + + info->digest =kmemdup (digest->digest, digest->digest_len, +GFP_KERNEL ); +if (!info->digest) + goto dmv_roothash_err; +
Quoted 8 lines
security/ipe/hooks.c void ipe_unpack_initramfs(void) · line 270
Quoted 8 lines
security/ipe/hooks.c +8
-0+ info->alg =kstrdup (digest->alg,GFP_KERNEL ); +if (!info->alg) + goto dmv_roothash_err; + + info->digest_len = digest->digest_len; + +if (blob->root_hash) +ipe_digest_free (blob->root_hash);
I'd restructure this as:
if (type == LSM_INT_DMVERITY_SIG_VALID {
/* ... */
return 0;
}
if (type != LSM_INT_DMVERITY_ROOTHASH)
return -EINVAL;
* ... */Right? Less packed to the right ;-)
BR, Jarkko
PATCH v19 14/20 security: add security_inode_setintegrity() hook
In reply to Fan WuThis patch introduces a new hook to save inode's integrity data. For example, for fsverity enabled files, LSMs can use this hook to save the verified fsverity builtin signature into the inode's security blob, and LSMs can make access decisions based on the data inside the signature, like the signer certificate.
--
v1-v14:
+ Not present
v15:
+ Introduced
v16:
+ Switch to call_int_hook()
v17:
+ Fix a typo
v18:
+ No changes
v19:
+ Refactor hook declaration
--- include/linux/lsm_hook_defs.h | 2 ++ include/linux/security.h | 10 ++++++++++ security/security.c | 20 ++++++++++++++++++++ 3 files changed, 32 insertions(+)
include/linux/lsm_hook_defs.h +2 -0
@@ -178,6 +178,8 @@ LSM_HOOK(void, LSM_RET_VOID, inode_getsecid, struct inode *inode, u32 *secid) LSM_HOOK(int, 0, inode_copy_up, struct dentry *src, struct cred **new) LSM_HOOK(int, -EOPNOTSUPP, inode_copy_up_xattr, struct dentry *src, const char *name) +LSM_HOOK(int, 0, inode_setintegrity, const struct inode *inode, + enum lsm_integrity_type type, const void *value, size_t size) LSM_HOOK(int, 0, kernfs_init_security, struct kernfs_node *kn_dir, struct kernfs_node *kn) LSM_HOOK(int, 0, file_permission, struct file *file, int mask)
include/linux/security.h +10 -0
@@ -410,6 +410,9 @@ int security_inode_listsecurity(struct inode *inode, char *buffer, size_t buffervoid security_inode_getsecid (struct inode *inode,u32 *secid);int security_inode_copy_up (struct dentry *src,struct cred **new);int security_inode_copy_up_xattr (struct dentry *src,const char *name); +int security_inode_setintegrity (const struct inode *inode, +enum lsm_integrity_type type,const void *value, +size_t size);int security_kernfs_init_security (struct kernfs_node *kn_dir,struct kernfs_node *kn);int security_file_permission (struct file *file,int mask);
@@ -1026,6 +1029,13 @@ static inline int security_inode_copy_up(struct dentry *src, struct cred **new)return 0 ; } +static inline int security_inode_setintegrity (const struct inode *inode, +enum lsm_integrity_type type, +const void *value,size_t size) +{ +return 0 ; +} +static inline int security_kernfs_init_security (struct kernfs_node *kn_dir,struct kernfs_node *kn) {
security/security.c +20 -0
@@ -2682,6 +2682,26 @@ int security_inode_copy_up_xattr(struct dentry *src, const char *name) }EXPORT_SYMBOL (security_inode_copy_up_xattr); +/** +* security_inode_setintegrity() - Set the inode's integrity data +* @inode: inode +* @type: type of integrity, e.g. hash digest, signature, etc +* @value: the integrity value +* @size: size of the integrity value +* +* Register a verified integrity measurement of a inode with LSMs. +* LSMs should free the previously saved data if @value is NULL. +* +* Return: Returns 0 on success, negative values on failure. +*/ +int security_inode_setintegrity (const struct inode *inode, +enum lsm_integrity_type type,const void *value, +size_t size) +{ +return call_int_hook (inode_setintegrity, inode, type, value, size); +} +EXPORT_SYMBOL (security_inode_setintegrity); +/** * security_kernfs_init_security() - Init LSM context for a kernfs node * @kn_dir: parent kernfs node
Signature · 1 line
2.44.0
PATCH v19 15/20 fsverity: expose verified fsverity built-in signatures to LSMs
In reply to Fan WuThis 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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
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.
---
v1-v6:
+ Not present
v7:
Introduced
v8:
+ Split fs/verity/ changes and security/ changes into separate patches
+ Change signature of fsverity_create_info to accept non-const inode
+ Change signature of fsverity_verify_signature to accept non-const inode
+ Don't cast-away const from inode.
+ Digest functionality dropped in favor of:
("fs-verity: define a function to return the integrity protected
file digest")
+ Reworded commit description and title to match changes.
+ Fix a bug wherein no LSM implements the particular fsverity @name (or LSM is disabled), and returns -EOPNOTSUPP, causing errors.
v9:
+ No changes
v10:
+ Rename the signature blob key
+ Cleanup redundant code
+ Make the hook call depends on CONFIG_FS_VERITY_BUILTIN_SIGNATURES
v11:
+ No changes
v12:
+ Add constification to the hook call
v13:
+ No changes
v14:
+ Add doc/comment to built-in signature verification
v15:
+ Add more docs related to IPE
+ Switch the hook call to security_inode_setintegrity()
v16:
+ Explicitly mention "fsverity builtin signatures" in the commit message
+ Amend documentation in fsverity.rst
+ Fix format issue
+ Change enum name
v17:
+ Fix various documentation issues
+ Use new enum name LSM_INT_FSVERITY_BUILTINSIG_VALID
v18:
+ Fix typos
+ Move the inode_setintegrity hook call into fsverity_verify_signature()
v19:
+ Cleanup code w.r.t inode_setintegrity hook refactoring
--- Documentation/filesystems/fsverity.rst | 23 +++++++++++++++++++++-- fs/verity/signature.c | 18 +++++++++++++++++- include/linux/security.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-)
Documentation/filesystems/fsverity.rst +21 -2
@@ -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.
fs/verity/signature.c +17 -1
@@ -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, +le32_to_cpu (sig_size)); + +if (err) { +fsverity_err (inode,"Error %d exposing file signature to LSMs" , + err); +return err; + } +return 0 ; }
include/linux/security.h +1 -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 , };/*
Signature · 1 line
2.44.0
Paul Moore
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 92 lines · On May 24, 2024 Fan Wu <[email protected]> wrote:
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
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 thefsverity_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 <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v1-v6:
+ Not presentv7:
Introducedv8:
+ Splitfs/verity/changes andsecurity/changes into separate patches
+ Change signature offsverity_create_infoto accept non-const inode
+ Change signature offsverity_verify_signatureto accept non-const inode
+ Don't cast-away const from inode.
+ Digest functionality dropped in favor of:
("fs-verity: define a function to return the integrity protected
file digest")
+ Reworded commit description and title to match changes.
+ Fix a bug wherein no LSM implements the particular fsverity @name (or LSM is disabled), and returns-EOPNOTSUPP, causing errors.v9:
+ No changesv10:
+ Rename the signature blob key
+ Cleanup redundant code
+ Make the hook call depends onCONFIG_FS_VERITY_BUILTIN_SIGNATURESv11:
+ No changesv12:
+ Add constification to the hook callv13:
+ No changesv14:
+ Add doc/comment to built-in signature verificationv15:
+ Add more docs related to IPE
+ Switch the hook call tosecurity_inode_setintegrity()v16:
+ Explicitly mention "fsverity builtin signatures" in the commit message
+ Amend documentation infsverity.rst
+ Fix format issue
+ Change enum namev17:
+ Fix various documentation issues
+ Use new enum nameLSM_INT_FSVERITY_BUILTINSIG_VALIDv18:
+ Fix typos
+ Move theinode_setintegrityhook call intofsverity_verify_signature()v19:
+ Cleanup code w.r.tinode_setintegrityhook refactoring--- Documentation/filesystems/fsverity.rst | 23 +++++++++++++++++++++-- fs/verity/signature.c | 18 +++++++++++++++++- include/linux/security.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-)
...
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 12 lines
fs/verity/signature.c +4
-0@@ -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, +le32_to_cpu (sig_size));
I like this much better without the explicit inode cast :)
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 126
Quoted 8 lines
fs/verity/signature.c +6
-0+if (err) { +fsverity_err (inode,"Error %d exposing file signature to LSMs" , + err); +return err; + } +return 0 ; }
--
paul-moore.com
Jarkko Sakkinen
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 6 lines · Paul Moore
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 4 lines
fs/verity/signature.c +4
-0+ err =security_inode_setintegrity (inode, +LSM_INT_FSVERITY_BUILTINSIG_VALID , + signature, +le32_to_cpu (sig_size));I like this much better without the explicit inode cast :)
Would be nice btw if that was 'ret' or 'rc' because err is such a common name for exception handler alike goto-labels... Looks confusing just because of that :-)
BR, Jarkko
Eric Biggers
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Paul Moore
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 4 lines
fs/verity/signature.c +4
-0+ err =security_inode_setintegrity (inode, +LSM_INT_FSVERITY_BUILTINSIG_VALID , + signature, +le32_to_cpu (sig_size));I like this much better without the explicit inode cast :)
Quoted 4 lines
Would be nice btw if that was 'ret' or 'rc' because err is such a common name for exception handler alike goto-labels... Looks confusing just because of that :-)
A lot of kernel code, including the rest of fs/verity/, uses the convention that "0 or negative errno" return values are named 'err' (and return values that aren't necessarily an errno are named something else). So it's fine as-is.
- Eric
Jarkko Sakkinen
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 9 lines · Eric Biggers
Quoted 8 lines · Jarkko Sakkinen
Quoted 6 lines · Paul Moore
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 4 lines
fs/verity/signature.c +4
-0+ err =security_inode_setintegrity (inode, +LSM_INT_FSVERITY_BUILTINSIG_VALID , + signature, +le32_to_cpu (sig_size));I like this much better without the explicit inode cast :)
Quoted 8 lines
Quoted 4 lines
Would be nice btw if that was 'ret' or 'rc' because err is such a common name for exception handler alike goto-labels... Looks confusing just because of that :-)
A lot of kernel code, including the rest of
fs/verity/, uses the convention that "0 or negative errno" return values are named 'err' (and return values that aren't necessarily an errno are named something else). So it's fine as-is.
Right, just hadn't seen such naming convention before.
BR, Jarkko
Paul Moore
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
In reply to Fan WuQuoted 86 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
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 thefsverity_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 <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v1-v6:
+ Not presentv7:
Introducedv8:
+ Splitfs/verity/changes andsecurity/changes into separate patches
+ Change signature offsverity_create_infoto accept non-const inode
+ Change signature offsverity_verify_signatureto accept non-const inode
+ Don't cast-away const from inode.
+ Digest functionality dropped in favor of:
("fs-verity: define a function to return the integrity protected
file digest")
+ Reworded commit description and title to match changes.
+ Fix a bug wherein no LSM implements the particular fsverity @name (or LSM is disabled), and returns-EOPNOTSUPP, causing errors.v9:
+ No changesv10:
+ Rename the signature blob key
+ Cleanup redundant code
+ Make the hook call depends onCONFIG_FS_VERITY_BUILTIN_SIGNATURESv11:
+ No changesv12:
+ Add constification to the hook callv13:
+ No changesv14:
+ Add doc/comment to built-in signature verificationv15:
+ Add more docs related to IPE
+ Switch the hook call tosecurity_inode_setintegrity()v16:
+ Explicitly mention "fsverity builtin signatures" in the commit message
+ Amend documentation infsverity.rst
+ Fix format issue
+ Change enum namev17:
+ Fix various documentation issues
+ Use new enum nameLSM_INT_FSVERITY_BUILTINSIG_VALIDv18:
+ Fix typos
+ Move theinode_setintegrityhook call intofsverity_verify_signature()
Quoted 7 lines
v19:
+ Cleanup code w.r.tinode_setintegrityhook refactoring--- Documentation/filesystems/fsverity.rst | 23 +++++++++++++++++++++-- fs/verity/signature.c | 18 +++++++++++++++++- include/linux/security.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-)
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Signature · 1 line
paul-moore.com
Eric Biggers
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 95 lines · Paul Moore
Quoted 86 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
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 thefsverity_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 <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v1-v6:
+ Not presentv7:
Introducedv8:
+ Splitfs/verity/changes andsecurity/changes into separate patches
+ Change signature offsverity_create_infoto accept non-const inode
+ Change signature offsverity_verify_signatureto accept non-const inode
+ Don't cast-away const from inode.
+ Digest functionality dropped in favor of:
("fs-verity: define a function to return the integrity protected
file digest")
+ Reworded commit description and title to match changes.
+ Fix a bug wherein no LSM implements the particular fsverity @name (or LSM is disabled), and returns-EOPNOTSUPP, causing errors.v9:
+ No changesv10:
+ Rename the signature blob key
+ Cleanup redundant code
+ Make the hook call depends onCONFIG_FS_VERITY_BUILTIN_SIGNATURESv11:
+ No changesv12:
+ Add constification to the hook callv13:
+ No changesv14:
+ Add doc/comment to built-in signature verificationv15:
+ Add more docs related to IPE
+ Switch the hook call tosecurity_inode_setintegrity()v16:
+ Explicitly mention "fsverity builtin signatures" in the commit message
+ Amend documentation infsverity.rst
+ Fix format issue
+ Change enum namev17:
+ Fix various documentation issues
+ Use new enum nameLSM_INT_FSVERITY_BUILTINSIG_VALIDv18:
+ Fix typos
+ Move theinode_setintegrityhook call intofsverity_verify_signature()Quoted 7 lines
v19:
+ Cleanup code w.r.tinode_setintegrityhook refactoring--- Documentation/filesystems/fsverity.rst | 23 +++++++++++++++++++++-- fs/verity/signature.c | 18 +++++++++++++++++- include/linux/security.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-)
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 4 lines
fs/verity/signature.c +4
-0+ err =security_inode_setintegrity (inode, +LSM_INT_FSVERITY_BUILTINSIG_VALID , + signature, +le32_to_cpu (sig_size));
This is doing le32_to_cpu() on a variable of type size_t, which will do the wrong thing on big endian systems and will generate a 'sparse' warning.
Also, the commit message still incorrectly claims that this patch allows "restricting kernel module loading from specified fsverity files via fsverity digests". As I said before (sigh...), this is not correct as that can be done without this patch.
- Eric
Re: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 108 lines · Eric Biggers
Quoted 95 lines · Paul Moore
Quoted 86 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
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 thefsverity_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 <[email protected]>Signed-off-by Fan Wu <[email protected]>---
v1-v6:
+ Not presentv7:
Introducedv8:
+ Splitfs/verity/changes andsecurity/changes into separate patches
+ Change signature offsverity_create_infoto accept non-const inode
+ Change signature offsverity_verify_signatureto accept non-const inode
+ Don't cast-away const from inode.
+ Digest functionality dropped in favor of:
("fs-verity: define a function to return the integrity protected
file digest")
+ Reworded commit description and title to match changes.
+ Fix a bug wherein no LSM implements the particular fsverity @name (or LSM is disabled), and returns-EOPNOTSUPP, causing errors.v9:
+ No changesv10:
+ Rename the signature blob key
+ Cleanup redundant code
+ Make the hook call depends onCONFIG_FS_VERITY_BUILTIN_SIGNATURESv11:
+ No changesv12:
+ Add constification to the hook callv13:
+ No changesv14:
+ Add doc/comment to built-in signature verificationv15:
+ Add more docs related to IPE
+ Switch the hook call tosecurity_inode_setintegrity()v16:
+ Explicitly mention "fsverity builtin signatures" in the commit message
+ Amend documentation infsverity.rst
+ Fix format issue
+ Change enum namev17:
+ Fix various documentation issues
+ Use new enum nameLSM_INT_FSVERITY_BUILTINSIG_VALIDv18:
+ Fix typos
+ Move theinode_setintegrityhook call intofsverity_verify_signature()Quoted 7 lines
v19:
+ Cleanup code w.r.tinode_setintegrityhook refactoring--- Documentation/filesystems/fsverity.rst | 23 +++++++++++++++++++++-- fs/verity/signature.c | 18 +++++++++++++++++- include/linux/security.h | 1 + 3 files changed, 39 insertions(+), 3 deletions(-)Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
Quoted 8 lines
fs/verity/signature.c int fsverity_verify_signature(const struct fsverity_info *vi, · line 117
Quoted 4 lines
fs/verity/signature.c +4
-0+ err =security_inode_setintegrity (inode, +LSM_INT_FSVERITY_BUILTINSIG_VALID , + signature, +le32_to_cpu (sig_size));This is doing
le32_to_cpu()on a variable of typesize_t, which will do the wrong thing on big endian systems and will generate a 'sparse' warning.
Sorry for the mistake. As sig_size is already converted in open.c, there is indeed no need to call this function again. I will remove this unnecessary conversion.
Quoted 6 lines
Also, the commit message still incorrectly claims that this patch allows "restricting kernel module loading from specified fsverity files via fsverity digests". As I said before (sigh...), this is not correct as that can be done without this patch.
- Eric
As for the commit message, my intention was to provide an example of a policy that with the patch IPE can enforce, not to claim that this specific restriction requires the patch. However, I will remove it as it seems to be causing confusion. -Fan
Paul Moore
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
In reply to Eric BiggersQuoted 13 lines · Eric Biggers
Quoted 12 lines · Paul Moore
Quoted 11 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
...
Quoted 11 lines
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
I too have been reviewing this patchset across multiple years and have worked with Fan to fix locking issues, parsing issues, the initramfs approach, etc. My interest in getting this landed is simply a combination of fulfilling my role as LSM maintainer as well as being Fan's coworker. While I realize you don't work with Fan, you are listed as the fs-verity maintainer and as such I've been looking to you to help review and authorize the fs-verity related code. If you are too busy, frustrated, or <fill in the blank> to continue reviewing this patchset it would be helpful if you could identify an authorized fs-verity reviewer. I don't see any besides you and Ted listed in the MAINTAINERS file, but perhaps the fs-verity entry is dated.
Regardless, I appreciate your time and feedback thus far and I'm sure Fan does as well.
Signature · 1 line
paul-moore.com
Eric Biggers
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 25 lines · Paul Moore
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Paul Moore
Quoted 11 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
...
Quoted 8 lines
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
Quoted 7 lines
Quoted 3 lines
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
I too have been reviewing this patchset across multiple years and have worked with Fan to fix locking issues, parsing issues, the initramfs approach, etc.
Sure, but none of the patches actually have your Reviewed-by.
Quoted 10 lines
My interest in getting this landed is simply a
combination of fulfilling my role as LSM maintainer as well as being Fan's coworker. While I realize you don't work with Fan, you are listed as the fs-verity maintainer and as such I've been looking to you to help review and authorize the fs-verity related code. If you are too busy, frustrated, or <fill in the blank> to continue reviewing this patchset it would be helpful if you could identify an authorized fs-verity reviewer. I don't see any besides you and Ted listed in theMAINTAINERSfile, but perhaps the fs-verity entry is dated.
Quoted 2 lines
Regardless, I appreciate your time and feedback thus far and I'm sure Fan does as well.
Maintainers are expected to do reviews and acks, but not to the extent of extensive hand-holding of a half-baked submission.
- Eric
Paul Moore
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 30 lines · Eric Biggers
Quoted 29 lines · Paul Moore
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Paul Moore
Quoted 11 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
...
Quoted 11 lines
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
Quoted 5 lines
Quoted 3 lines
I too have been reviewing this patchset across multiple years and have worked with Fan to fix locking issues, parsing issues, the initramfs approach, etc.
Sure, but none of the patches actually have your Reviewed-by.
As a general rule I don't post Acked-by/Reviewed-by tags for patches that are targeting a subsystem that I maintain. The logic being that I'm going to be adding my Signed-off-by tag to the patches and arguing these in front of Linus, so adding a Acked-by/Reviewed-by simply creates more work later on where I have to strip them off and replace them with my sign-off.
If the lack of a Reviewed-by tag is *really* what is preventing you from reviewing the fs-verity patch, I can post that starting with the next revision, but I'm guessing the lack of my tag isn't your core issue (or at least I would argue it shouldn't be).
Quoted 10 lines
Quoted 10 lines
My interest in getting this landed is simply a
combination of fulfilling my role as LSM maintainer as well as being Fan's coworker. While I realize you don't work with Fan, you are listed as the fs-verity maintainer and as such I've been looking to you to help review and authorize the fs-verity related code. If you are too busy, frustrated, or <fill in the blank> to continue reviewing this patchset it would be helpful if you could identify an authorized fs-verity reviewer. I don't see any besides you and Ted listed in theMAINTAINERSfile, but perhaps the fs-verity entry is dated.
Quoted 5 lines
Quoted 2 lines
Regardless, I appreciate your time and feedback thus far and I'm sure Fan does as well.
Maintainers are expected to do reviews and acks, but not to the extent of extensive hand-holding of a half-baked submission.
Considering the current state of this patchset I don't believe that verdict to be fair, or very considerate.
We clearly have different styles and approaches towards subsystem maintainer roles. I've had the good fortune to work with both hostile and helpful senior developers during the early years of my time working in the Linux kernel, and it helped reinforce the impact patience and mentoring can have on contributors who are new to the Linux kernel or perhaps system programming in general. While I'm far from perfect in this regard, I do hope and recommend that all of us in maintainer, or senior developer, roles remember to exercise some additional patience and education when working with new contributors.
Signature · 1 line
paul-moore.com
Eric Biggers
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 68 lines · Paul Moore
Quoted 30 lines · Eric Biggers
Quoted 29 lines · Paul Moore
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Paul Moore
Quoted 11 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
...
Quoted 11 lines
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
Quoted 5 lines
Quoted 3 lines
I too have been reviewing this patchset across multiple years and have worked with Fan to fix locking issues, parsing issues, the initramfs approach, etc.
Sure, but none of the patches actually have your Reviewed-by.
As a general rule I don't post Acked-by/Reviewed-by tags for patches that are targeting a subsystem that I maintain. The logic being that I'm going to be adding my Signed-off-by tag to the patches and arguing these in front of Linus, so adding a Acked-by/Reviewed-by simply creates more work later on where I have to strip them off and replace them with my sign-off.
If the lack of a Reviewed-by tag is *really* what is preventing you from reviewing the fs-verity patch, I can post that starting with the next revision, but I'm guessing the lack of my tag isn't your core issue (or at least I would argue it shouldn't be).
Quoted 10 lines
Quoted 10 lines
My interest in getting this landed is simply a
combination of fulfilling my role as LSM maintainer as well as being Fan's coworker. While I realize you don't work with Fan, you are listed as the fs-verity maintainer and as such I've been looking to you to help review and authorize the fs-verity related code. If you are too busy, frustrated, or <fill in the blank> to continue reviewing this patchset it would be helpful if you could identify an authorized fs-verity reviewer. I don't see any besides you and Ted listed in theMAINTAINERSfile, but perhaps the fs-verity entry is dated.Quoted 5 lines
Quoted 2 lines
Regardless, I appreciate your time and feedback thus far and I'm sure Fan does as well.
Maintainers are expected to do reviews and acks, but not to the extent of extensive hand-holding of a half-baked submission.
Considering the current state of this patchset I don't believe that verdict to be fair, or very considerate.
Quoted 10 lines
We clearly have different styles and approaches towards subsystem maintainer roles. I've had the good fortune to work with both hostile and helpful senior developers during the early years of my time working in the Linux kernel, and it helped reinforce the impact patience and mentoring can have on contributors who are new to the Linux kernel or perhaps system programming in general. While I'm far from perfect in this regard, I do hope and recommend that all of us in maintainer, or senior developer, roles remember to exercise some additional patience and education when working with new contributors.
It's not clear to me that you've done a close review of the verity related patches, including not just this one but the dm-verity related ones and the fsverity and dm-verity support in IPE itself, given the issues that I've been finding in them in the last couple months. As I said before, I'm not too enthusiastic about IPE myself, for various reasons I've explained, so I've really been looking to the people who actually want it to help drive it forward.
Anyway, as I also said, the fsverity and dm-verity support does seem to be improved now after all the rounds of feedback, and I think it's close to the finish line. I just hope you can understand that I'm also a bit burnt out now, and getting asked for an ack on this patch again and then seeing a bug in it (despite it having been simplified to only a few lines now) and also still misleading information in the commit message that I asked to be fixed before, is a bit frustrating. I think it's reasonable to expect a bit better, especially for a security oriented feature.
Thanks,
- Eric
Paul Moore
maintainerRe: [PATCH v19 15/20] fsverity: expose verified fsverity built-in signatures to LSMs
Quoted 80 lines · Eric Biggers
Quoted 68 lines · Paul Moore
Quoted 30 lines · Eric Biggers
Quoted 29 lines · Paul Moore
Quoted 13 lines · Eric Biggers
Quoted 12 lines · Paul Moore
Quoted 11 lines · Fan Wu
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 permit the execution of all files with verified built-in fsverity signatures while restricting kernel module loading from specified fsverity files via fsverity digests.
...
Quoted 11 lines
Quoted 4 lines
Eric, can you give this patch in particular a look to make sure you are okay with everything? I believe Fan has addressed all of your previous comments and it would be nice to have your Ack/Review tag if you are okay with the current revision.
Sorry, I've just gotten a bit tired of finding so many basic issues in this patchset even after years of revisions.
This patch in particular is finally looking better. There are a couple issues that I still see. (BTW, you're welcome to review it too to help find these things, given that you seem to have an interest in getting this landed...):
Quoted 5 lines
Quoted 3 lines
I too have been reviewing this patchset across multiple years and have worked with Fan to fix locking issues, parsing issues, the initramfs approach, etc.
Sure, but none of the patches actually have your Reviewed-by.
As a general rule I don't post Acked-by/Reviewed-by tags for patches that are targeting a subsystem that I maintain. The logic being that I'm going to be adding my Signed-off-by tag to the patches and arguing these in front of Linus, so adding a Acked-by/Reviewed-by simply creates more work later on where I have to strip them off and replace them with my sign-off.
If the lack of a Reviewed-by tag is *really* what is preventing you from reviewing the fs-verity patch, I can post that starting with the next revision, but I'm guessing the lack of my tag isn't your core issue (or at least I would argue it shouldn't be).
Quoted 10 lines
Quoted 10 lines
My interest in getting this landed is simply a
combination of fulfilling my role as LSM maintainer as well as being Fan's coworker. While I realize you don't work with Fan, you are listed as the fs-verity maintainer and as such I've been looking to you to help review and authorize the fs-verity related code. If you are too busy, frustrated, or <fill in the blank> to continue reviewing this patchset it would be helpful if you could identify an authorized fs-verity reviewer. I don't see any besides you and Ted listed in theMAINTAINERSfile, but perhaps the fs-verity entry is dated.Quoted 5 lines
Quoted 2 lines
Regardless, I appreciate your time and feedback thus far and I'm sure Fan does as well.
Maintainers are expected to do reviews and acks, but not to the extent of extensive hand-holding of a half-baked submission.
Considering the current state of this patchset I don't believe that verdict to be fair, or very considerate.
Quoted 10 lines
We clearly have different styles and approaches towards subsystem maintainer roles. I've had the good fortune to work with both hostile and helpful senior developers during the early years of my time working in the Linux kernel, and it helped reinforce the impact patience and mentoring can have on contributors who are new to the Linux kernel or perhaps system programming in general. While I'm far from perfect in this regard, I do hope and recommend that all of us in maintainer, or senior developer, roles remember to exercise some additional patience and education when working with new contributors.
Quoted 4 lines
It's not clear to me that you've done a close review of the verity related patches, including not just this one but the dm-verity related ones and the fsverity and dm-verity support in IPE itself, given the issues that I've been finding in them in the last couple months.
I have not been able to give the fs-verify or dm-verity patches the same level of scrutiny as the associated subsystem maintainers simply because I lack the deep history and background; I rely on the associated maintainers to catch the important "gotchas" as we've seen in the patchset.
Quoted 3 lines
As I said before, I'm not too
enthusiastic about IPE myself, for various reasons I've explained, so I've really been looking to the people who actually want it to help drive it forward.
Once again, that is what I have been doing in my effort to get this to a point where it can be merged and sent to Linus. I've spent numerous hours reviewing patches on-list (and catching quite a few issues), and working with Fan off-list, to ensure these patches continue to improve. I'm asking you to review the fs-verity patch(es) for two main reasons: 1) to identify any fs-verity interaction problems, 2) as a courtesy since you are the fs-verity maintainer and I want you to be aware of this and accepting of the code being introduced in the subsystem you are responsible for maintaining.
Quoted 3 lines
Anyway, as I also said, the fsverity and dm-verity support does seem to be improved now after all the rounds of feedback, and I think it's close to the finish line.
I agree. I appreciate your help in reviewing this patchset, and those that came before it. I've seen Fan voice his appreciation too on-list.
Quoted 1 line
I just hope you can understand that I'm also a bit burnt out now,
I can understand that, and I'm sympathetic. I've been doing this long enough to have gone through my own cycles of burnout and rejuvenation and I know how disheartening it can be at times.
Quoted 5 lines
and getting asked for an ack on this patch again and then seeing a bug in it (despite it having been simplified to only a few lines now) and also still misleading information in the commit message that I asked to be fixed before, is a bit frustrating. I think it's reasonable to expect a bit better, especially for a security oriented feature.
I firmly believe that no one writes perfect code, and no one performs a perfect review. As far as I'm concerned, the important bit is that you respond, learn, and strive to do better next time.
Signature · 1 line
paul-moore.com
PATCH v19 16/20 ipe: enable support for fs-verity as a trust provider
In reply to Fan WuEnable IPE policy authors to indicate trust for a singular fsverity file, identified by the digest information, through "fsverity_digest" and all files using valid fsverity builtin signatures via "fsverity_signature".
This enables file-level integrity claims to be expressed in IPE, allowing individual files to be authorized, giving some flexibility for policy authors. Such file-level claims are important to be expressed for enforcing the integrity of packages, as well as address some of the scalability issues in a sole dm-verity based solution (# of loop back devices, etc).
This solution cannot be done in userspace as the minimum threat that IPE should mitigate is an attacker downloads malicious payload with all required dependencies. These dependencies can lack the userspace check, bypassing the protection entirely. A similar attack succeeds if the userspace component is replaced with a version that does not perform the check. As a result, this can only be done in the common entry point - the kernel.
---
v1-v6:
+ Not present
v7:
Introduced
v8:
* Undo squash of 08/12, 10/12 - separating drivers/md/ from security/
* Use common-audit function for fsverity_signature.
+ Change fsverity implementation to use fsverity_get_digest
+ prevent unnecessary copy of fs-verity signature data, instead just check for presence of signature data.
+ Remove free_inode_security hook, as the digest is now acquired at runtime instead of via LSM blob.
v9:
+ Adapt to the new parser
v10:
+ Update the fsverity get digest call
v11:
+ No changes
v12:
+ Fix audit format
+ Simplify property evaluation
v13:
+ Remove the CONFIG_IPE_PROP_FS_VERITY dependency inside the parser to make the policy grammar independent of the kernel config.
v14:
+ No changes
v15:
+ Fix on grammar issue in Kconfig
+ Switch hook to security_inode_setintegrity()
v16:
+ Rewrite fsverity signature part in Kconfig
v17:
+ Fix documentation issues
+ Use new enum name LSM_INT_FSVERITY_BUILTINSIG_VALID
v18:
+ Add Kconfig IPE_PROP_FS_VERITY_BUILTIN_SIG and make both FS_VERITY Kconfigs auto-selected
v19:
+ No changes
--- security/ipe/Kconfig | 26 ++++++++ security/ipe/audit.c | 17 +++++ security/ipe/eval.c | 123 ++++++++++++++++++++++++++++++++++- security/ipe/eval.h | 12 ++++ security/ipe/hooks.c | 29 +++++++++ security/ipe/hooks.h | 6 ++ security/ipe/ipe.c | 13 ++++ security/ipe/ipe.h | 3 + security/ipe/policy.h | 3 + security/ipe/policy_parser.c | 6 ++ 10 files changed, 237 insertions(+), 1 deletion(-)
security/ipe/Kconfig +26 -0
@@ -10,6 +10,8 @@ menuconfig SECURITY_IPE select SYSTEM_DATA_VERIFICATION select IPE_PROP_DM_VERITY if DM_VERITY select IPE_PROP_DM_VERITY_SIGNATURE if DM_VERITY && DM_VERITY_VERIFY_ROOTHASH_SIG + select IPE_PROP_FS_VERITY if FS_VERITY + select IPE_PROP_FS_VERITY_BUILTIN_SIG if FS_VERITY && FS_VERITY_BUILTIN_SIGNATURES help This option enables the Integrity Policy Enforcement LSM allowing users to define a policy to enforce a trust-based access
@@ -39,6 +41,30 @@ config IPE_PROP_DM_VERITY_SIGNATURE volume, which has been mounted with a valid signed root hash, is evaluated. + 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. + endmenu endif
security/ipe/audit.c +17 -0
@@ -53,6 +53,9 @@ static const char *const audit_prop_names[__IPE_PROP_MAX] = {"dmverity_roothash=" ,"dmverity_signature=FALSE" ,"dmverity_signature=TRUE" , +"fsverity_digest=" , +"fsverity_signature=FALSE" , + "fsverity_signature=TRUE", };/**
@@ -66,6 +69,17 @@ static void audit_dmv_roothash(struct audit_buffer *ab, const void *rh)ipe_digest_audit (ab, rh); } +/** +* audit_fsv_digest() - audit the digest of a fsverity_digest property. +* @ab: Supplies a pointer to the audit_buffer to append to. +* @d: Supplies a pointer to the digest structure. +*/ +static void audit_fsv_digest (struct audit_buffer *ab,const void *d) +{ +audit_log_format (ab,"%s" , audit_prop_names[IPE_PROP_FSV_DIGEST ]); +ipe_digest_audit (ab, d); +} +/** * audit_rule() - audit an IPE policy rule. * @ab: Supplies a pointer to the audit_buffer to append to.
@@ -82,6 +96,9 @@ static void audit_rule(struct audit_buffer *ab, const struct ipe_rule *r)case IPE_PROP_DMV_ROOTHASH :audit_dmv_roothash (ab, ptr->value);break ; +case IPE_PROP_FSV_DIGEST : +audit_fsv_digest (ab, ptr->value); +break ;default :audit_log_format (ab,"%s" , audit_prop_names[ptr->type]);break ;
security/ipe/eval.c +122 -1
159 lines not on this page · raw message
security/ipe/eval.h +12 -0
@@ -31,6 +31,12 @@ struct ipe_bdev { };#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +struct ipe_inode { +bool fs_verity_signed; +}; +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ +struct ipe_eval_ctx {enum ipe_op_type op;enum ipe_hook_type hook;
@@ -40,6 +46,12 @@ struct ipe_eval_ctx {#ifdef CONFIG_IPE_PROP_DM_VERITY const struct ipe_bdev *ipe_bdev;#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY +const struct inode *ino; +#endif /* CONFIG_IPE_PROP_FS_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +const struct ipe_inode *ipe_inode; +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ };enum ipe_match {
security/ipe/hooks.c +29 -0
@@ -284,3 +284,32 @@ int ipe_bdev_setintegrity(struct block_device *bdev, enum lsm_integrity_type typ return -EINVAL; }#endif /* CONFIG_IPE_PROP_DM_VERITY */ + +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +/** +* ipe_inode_setintegrity() - save integrity data from a inode to IPE's LSM blob. +* @inode: The inode to source the security blob from. +* @type: Supplies the integrity type. +* @value: The value to be stored. +* @size: The size of @value. +* +* This hook is currently used to save the existence of a validated fs-verity +* builtin signature into LSM blob. +* +* Return: %0 on success. If an error occurs, the function will return the +* -errno. +*/ +int ipe_inode_setintegrity (const struct inode *inode, +enum lsm_integrity_type type, +const void *value,size_t size) +{ +struct ipe_inode *inode_sec =ipe_inode (inode); + +if (type ==LSM_INT_FSVERITY_BUILTINSIG_VALID ) { + inode_sec->fs_verity_signed = size >0 && value; +return 0 ; + } + +return -EINVAL ; +} +#endif /* CONFIG_CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */
security/ipe/hooks.h +6 -0
@@ -9,6 +9,7 @@#include <linux/binfmts.h> #include <linux/security.h> #include <linux/blk_types.h> +#include <linux/fsverity.h> enum ipe_hook_type {IPE_HOOK_BPRM_CHECK =0 ,
@@ -43,4 +44,9 @@ int ipe_bdev_setintegrity(struct block_device *bdev, enum lsm_integrity_type typ const void *value, size_t len);#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +int ipe_inode_setintegrity (const struct inode *inode,enum lsm_integrity_type type, +const void *value,size_t size); +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ +#endif /* _IPE_HOOKS_H */
security/ipe/ipe.c +13 -0
@@ -16,6 +16,9 @@ static struct lsm_blob_sizes ipe_blobs __ro_after_init = {#ifdef CONFIG_IPE_PROP_DM_VERITY .lbs_bdev = sizeof(struct ipe_bdev),#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG + .lbs_inode = sizeof(struct ipe_inode), +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ };static const struct lsm_id ipe_lsmid = {
@@ -35,6 +38,13 @@ struct ipe_bdev *ipe_bdev(struct block_device *b) }#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +struct ipe_inode *ipe_inode (const struct inode *inode) +{ +return inode->i_security + ipe_blobs.lbs_inode; +} +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ +static struct security_hook_list ipe_hooks[]__ro_after_init = {LSM_HOOK_INIT (bprm_check_security, ipe_bprm_check_security),LSM_HOOK_INIT (mmap_file, ipe_mmap_file),
@@ -46,6 +56,9 @@ static struct security_hook_list ipe_hooks[] __ro_after_init = { LSM_HOOK_INIT(bdev_free_security, ipe_bdev_free_security), LSM_HOOK_INIT(bdev_setintegrity, ipe_bdev_setintegrity),#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG + LSM_HOOK_INIT(inode_setintegrity, ipe_inode_setintegrity), +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ };/**
security/ipe/ipe.h +3 -0
@@ -19,5 +19,8 @@ extern bool ipe_enabled;#ifdef CONFIG_IPE_PROP_DM_VERITY struct ipe_bdev *ipe_bdev (struct block_device *b);#endif /* CONFIG_IPE_PROP_DM_VERITY */ +#ifdef CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG +struct ipe_inode *ipe_inode (const struct inode *inode); +#endif /* CONFIG_IPE_PROP_FS_VERITY_BUILTIN_SIG */ #endif /* _IPE_H */
security/ipe/policy.h +3 -0
@@ -36,6 +36,9 @@ enum ipe_prop_type {IPE_PROP_DMV_ROOTHASH ,IPE_PROP_DMV_SIG_FALSE ,IPE_PROP_DMV_SIG_TRUE , +IPE_PROP_FSV_DIGEST , +IPE_PROP_FSV_SIG_FALSE , +IPE_PROP_FSV_SIG_TRUE , __IPE_PROP_MAX };
security/ipe/policy_parser.c +6 -0
@@ -278,6 +278,9 @@ static const match_table_t property_tokens = { {IPE_PROP_DMV_ROOTHASH, "dmverity_roothash=%s"}, {IPE_PROP_DMV_SIG_FALSE, "dmverity_signature=FALSE"}, {IPE_PROP_DMV_SIG_TRUE, "dmverity_signature=TRUE"}, + {IPE_PROP_FSV_DIGEST, "fsverity_digest=%s"}, + {IPE_PROP_FSV_SIG_FALSE, "fsverity_signature=FALSE"}, + {IPE_PROP_FSV_SIG_TRUE, "fsverity_signature=TRUE"}, {IPE_PROP_INVALID, NULL} };
@@ -310,6 +313,7 @@ static int parse_property(char *t, struct ipe_rule *r)switch (token) {case IPE_PROP_DMV_ROOTHASH : +case IPE_PROP_FSV_DIGEST : dup =match_strdup (&args[0 ]);if (!dup) { rc = -ENOMEM ;
@@ -325,6 +329,8 @@ static int parse_property(char *t, struct ipe_rule *r)case IPE_PROP_BOOT_VERIFIED_TRUE :case IPE_PROP_DMV_SIG_FALSE :case IPE_PROP_DMV_SIG_TRUE : +case IPE_PROP_FSV_SIG_FALSE : +case IPE_PROP_FSV_SIG_TRUE : p->type = token;break ;default :
Signature · 1 line
2.44.0
PATCH v19 17/20 scripts: add boot policy generation program
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Enables an IPE policy to be enforced from kernel start, enabling access control based on trust from kernel startup. This is accomplished by transforming an IPE policy indicated by CONFIG_IPE_BOOT_POLICY into a c-string literal that is parsed at kernel startup as an unsigned policy.
---
v2:
+ No Changes
v3:
+ No Changes
v4:
+ No Changes
v5:
+ No Changes
v6:
+ No Changes
v7:
+ Move from 01/11 to 14/16
+ Don't return errno directly.
+ Make output of script more user-friendly
+ Add escaping for tab and '?'
+ Mark argv pointer const
+ Invert return code check in the boot policy parsing code path.
v8:
+ No significant changes.
v9:
+ No changes
v10:
+ Update the init part code for rcu changes in the eval loop patch
v11:
+ Fix code style issues
v12:
+ No changes
v13:
+ No changes
v14:
+ No changes
v15:
+ Fix one grammar issue in Kconfig
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- scripts/Makefile | 1 + scripts/ipe/Makefile | 2 + scripts/ipe/polgen/.gitignore | 2 + scripts/ipe/polgen/Makefile | 5 ++ scripts/ipe/polgen/polgen.c | 145 ++++++++++++++++++++++++++++++++++ security/ipe/.gitignore | 2 + security/ipe/Kconfig | 10 +++ security/ipe/Makefile | 11 +++ security/ipe/fs.c | 8 ++ security/ipe/ipe.c | 12 +++ 10 files changed, 198 insertions(+) create mode 100644 scripts/ipe/Makefile create mode 100644 scripts/ipe/polgen/.gitignore create mode 100644 scripts/ipe/polgen/Makefile create mode 100644 scripts/ipe/polgen/polgen.c create mode 100644 security/ipe/.gitignore
scripts/Makefile +1 -0
@@ -55,6 +55,7 @@ targets += module.lds subdir-$(CONFIG_GCC_PLUGINS) += gcc-plugins subdir-$(CONFIG_MODVERSIONS) += genksyms subdir-$(CONFIG_SECURITY_SELINUX) += selinux +subdir-$(CONFIG_SECURITY_IPE) += ipe # Let clean descend into subdirs subdir- += basic dtc gdb kconfig mod
scripts/ipe/Makefile new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +subdir-y := polgen
scripts/ipe/polgen/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +polgen
scripts/ipe/polgen/Makefile new file +5 -0
@@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 +hostprogs-always-y := polgen +HOST_EXTRACFLAGS += \ + -I$(srctree)/include \ + -I$(srctree)/include/uapi \
scripts/ipe/polgen/polgen.c new file +145 -0
145 lines not on this page · raw message
security/ipe/.gitignore new file +2 -0
@@ -0,0 +1,2 @@ +# SPDX-License-Identifier: GPL-2.0-only +boot-policy.c
security/ipe/Kconfig +10 -0
@@ -21,6 +21,16 @@ menuconfig SECURITY_IPE If unsure, answer N. if SECURITY_IPE +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. + menu "IPE Trust Providers" config IPE_PROP_DM_VERITY
security/ipe/Makefile +11 -0
@@ -5,7 +5,16 @@ # Makefile for building the IPE module as part of the kernel tree. # +quiet_cmd_polgen = IPE_POL $(2) + cmd_polgen = scripts/ipe/polgen/polgen security/ipe/boot-policy.c $(2) + +targets += boot-policy.c + +$(obj)/boot-policy.c: scripts/ipe/polgen/polgen $(CONFIG_IPE_BOOT_POLICY) FORCE + $(call if_changed,polgen,$(CONFIG_IPE_BOOT_POLICY)) + obj-$(CONFIG_SECURITY_IPE) += \ + boot-policy.o \ digest.o \ eval.o \ hooks.o \
@@ -15,3 +24,5 @@ obj-$(CONFIG_SECURITY_IPE) += \ policy_fs.o \ policy_parser.o \ audit.o \ + +clean-files := boot-policy.c \
security/ipe/fs.c +8 -0
@@ -190,6 +190,7 @@ static const struct file_operations enforce_fops = {static int __init ipe_init_securityfs (void ) {int rc =0 ; +struct ipe_policy *ap;if (!ipe_enabled)return -EOPNOTSUPP ;
@@ -220,6 +221,13 @@ static int __init ipe_init_securityfs(void) goto err; } + ap =rcu_access_pointer (ipe_active_policy); +if (ap) { + rc =ipe_new_policyfs_node (ap); +if (rc) + goto err; + } + np =securityfs_create_file ("new_policy" ,0200 , root,NULL , &np_fops);if (IS_ERR (np)) { rc =PTR_ERR (np);
security/ipe/ipe.c +12 -0
@@ -9,6 +9,7 @@#include "hooks.h" #include "eval.h" +extern const char *const ipe_boot_policy;bool ipe_enabled;static struct lsm_blob_sizes ipe_blobs__ro_after_init = {
@@ -74,9 +75,20 @@ static struct security_hook_list ipe_hooks[] __ro_after_init = {*/ static int __init ipe_init (void ) { +struct ipe_policy *p =NULL ; +security_add_hooks (ipe_hooks,ARRAY_SIZE (ipe_hooks), &ipe_lsmid); ipe_enabled = true; +if (ipe_boot_policy) { + p =ipe_new_policy (ipe_boot_policy,strlen (ipe_boot_policy), +NULL ,0 ); +if (IS_ERR (p)) +return PTR_ERR (p); + +rcu_assign_pointer (ipe_active_policy, p); + } +return 0 ; }
Signature · 1 line
2.44.0
PATCH v19 18/20 ipe: kunit test for parser
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Add various happy/unhappy unit tests for both IPE's policy parser.
Besides, a test suite for IPE functionality is available at
https://github.com/microsoft/ipe/tree/test-suite
---
v1-v6:
+ Not present
v7:
Introduced
v8:
+ Remove the kunit tests with respect to the fsverity digest, as these require significant changes to work with the new method of acquiring the digest at runtime.
v9:
+ Remove the kunit tests related to ipe_context
v10:
+ No changes
v11:
+ No changes
v12:
+ No changes
v13:
+ No changes
v14:
+ No changes
v15:
+ No changes
v16:
+ No changes
v17:
+ Add years to license header
+ Fix code and documentation style issues
v18:
+ No changes
v19:
+ No changes
--- security/ipe/Kconfig | 17 +++ security/ipe/Makefile | 3 + security/ipe/policy_tests.c | 296 ++++++++++++++++++++++++++++++++++++ 3 files changed, 316 insertions(+) create mode 100644 security/ipe/policy_tests.c
security/ipe/Kconfig +17 -0
@@ -77,4 +77,21 @@ config IPE_PROP_FS_VERITY_BUILTIN_SIG endmenu +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. + endif
security/ipe/Makefile +3 -0
@@ -26,3 +26,6 @@ obj-$(CONFIG_SECURITY_IPE) += \ audit.o \ clean-files := boot-policy.c \ + +obj-$(CONFIG_SECURITY_IPE_KUNIT_TEST) += \ + policy_tests.o \
security/ipe/policy_tests.c new file +296 -0
296 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH v19 19/20 Documentation: add ipe documentation
In reply to Fan WuFrom: Deven Bowers <[email protected]>
Add IPE's admin and developer documentation to the kernel tree.
---
v2:
+ No Changes
v3:
+ Add Acked-by
+ Fixup code block syntax
+ Fix a minor grammatical issue.
v4:
+ Update documentation with the results of other code changes.
v5:
+ No changes
v6:
+ No changes
v7:
+ Add additional developer-level documentation
+ Update admin-guide docs to reflect changes.
+ Drop Acked-by due to significant changes
+ Added section about audit events in admin-guide
v8:
+ Correct terminology from "audit event" to "audit record"
+ Add associated documentation with the correct "audit event" terminology.
+ Add some context to the historical motivation for IPE and design philosophy.
+ Add some content about the securityfs layout in the policies directory.
+ Various spelling and grammatical corrections.
v9:
+ Correct spelling of "pitfalls"
+ Update the docs w.r.t the new parser and new audit formats
v10:
+ Refine user docs per upstream suggestions
+ Update audit events part
v11:
+ No changes
v12:
+ Update audit formats
+ Update initramfs related docs
+ Add test suite link
v13:
+ No changes
v14:
+ No changes
v15:
+ Update boot_verified part
+ Fix format issues
+ Add IPE doc link to fsverity.rst
v16:
+ Explicitly mention fsverity builtin signature
v17:
+ Rewrite many parts of Documentation/admin-guide/LSM/ipe.rst
+ Fix incorrect path name of policyfs interfaces
v18:
+ Improve policy examples
+ Remove insecure hash algorithms and adapt the documentation accordingly
+ Update the documentation regarding the new Kconfig switches
v19:
+ Fix warnings and link formats
--- Documentation/admin-guide/LSM/index.rst | 1 + Documentation/admin-guide/LSM/ipe.rst | 792 ++++++++++++++++++ .../admin-guide/kernel-parameters.txt | 12 + Documentation/filesystems/fsverity.rst | 6 +- Documentation/security/index.rst | 1 + Documentation/security/ipe.rst | 446 ++++++++++ 6 files changed, 1257 insertions(+), 1 deletion(-) create mode 100644 Documentation/admin-guide/LSM/ipe.rst create mode 100644 Documentation/security/ipe.rst
Documentation/admin-guide/LSM/index.rst +1 -0
@@ -47,3 +47,4 @@ subdirectories. tomoyo Yama SafeSetID + ipe
Documentation/admin-guide/LSM/ipe.rst new file +792 -0
792 lines not on this page · raw message
Documentation/admin-guide/kernel-parameters.txt +12 -0
@@ -2351,6 +2351,18 @@ ipcmni_extend [KNL,EARLY] Extend the maximum number of unique System V IPC identifiers from 32,768 to 16,777,216. + ipe.enforce= [IPE] + Format: <bool> + Determine whether IPE starts in permissive (0) or + enforce (1) mode. The default is enforce. + + ipe.success_audit= + [IPE] + Format: <bool> + Start IPE with success auditing enabled, emitting + an audit event when a binary is allowed. The default + is 0. + irqaffinity= [SMP] Set the default irq affinity mask The argument is a cpu list, as described above.
Documentation/filesystems/fsverity.rst +5 -1
@@ -92,7 +92,9 @@ authenticating fs-verity file hashes include: "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. + files with a verified fs-verity's built-in signature. For + details on configuring IPE policies and understanding its operational + modes, please refer to :doc:`IPE admin guide </admin-guide/LSM/ipe>`. - Trusted userspace code in combination with `Built-in signature verification`_. This approach should be used only with great care.
@@ -508,6 +510,8 @@ be carefully considered before using them: 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. + Please refer to :doc:`IPE admin guide </admin-guide/LSM/ipe>` for + more details. - 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
Documentation/security/index.rst +1 -0
@@ -19,3 +19,4 @@ Security Documentation digsig landlock secrets/index + ipe
Documentation/security/ipe.rst new file +446 -0
446 lines not on this page · raw message
Signature · 1 line
2.44.0
PATCH v19 20/20 MAINTAINERS: ipe: add ipe maintainer information
In reply to Fan WuUpdate MAINTAINERS to include ipe maintainer information.
--
v1-v16:
+ Not present
v17:
+ Introduced
v18:
+ No changes
v19:
+ No changes
--- MAINTAINERS | 10 ++++++++++ 1 file changed, 10 insertions(+)
MAINTAINERS +10 -0
@@ -10934,6 +10934,16 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/zohar/linux-integrity.git F: security/integrity/ F: security/integrity/ima/ +INTEGRITY POLICY ENFORCEMENT (IPE) +M: Fan Wu <[email protected]> +L: [email protected] +S: Supported +T: git https://github.com/microsoft/ipe.git +F: Documentation/admin-guide/LSM/ipe.rst +F: Documentation/security/ipe.rst +F: scripts/ipe/ +F: security/ipe/ + INTEL 810/815 FRAMEBUFFER DRIVER M: Antonino Daplas <[email protected]> L: [email protected]
Signature · 1 line
2.44.0