public inbox for linux-security-module@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v4 00/13] ima: Introduce staging mechanism
@ 2026-03-26 17:29 Roberto Sassu
  2026-03-26 17:29 ` [PATCH v4 01/13] ima: Remove ima_h_table structure Roberto Sassu
                   ` (12 more replies)
  0 siblings, 13 replies; 18+ messages in thread
From: Roberto Sassu @ 2026-03-26 17:29 UTC (permalink / raw)
  To: corbet, skhan, zohar, dmitry.kasatkin, eric.snowberg, paul,
	jmorris, serge
  Cc: linux-doc, linux-kernel, linux-integrity, linux-security-module,
	gregorylumen, chenste, nramas, Roberto Sassu

From: Roberto Sassu <roberto.sassu@huawei.com>

Introduction
============

The IMA measurements list is currently stored in the kernel memory. Memory
occupation grows linearly with the number of entries, and can become a
problem especially in environments with reduced resources.

While there is an advantage in keeping the IMA measurements list in kernel
memory, so that it is always available for reading from the securityfs
interfaces, storing it elsewhere would make it possible to free precious
memory for other kernel components.

Storing the IMA measurements list outside the kernel does not introduce
security issues, since its integrity is anyway protected by the TPM.

Hence, the new IMA staging mechanism is introduced to allow user space
to remove the desired portion of the measurements list from the kernel.

The IMA staging mechanism can be enabled from the kernel configuration with
the CONFIG_IMA_STAGING option.

If it is enabled, IMA duplicates the current measurements interfaces (both
binary and ASCII), by adding the ``_staged`` file suffix. Unlike the
existing counterparts, the ``_staged`` interfaces have write permission for
the root user and group, and require the process to have CAP_SYS_ADMIN set.

The staging mechanism supports two flavors.

Staging with prompt:

 1. ``echo A > <_staged interface>``: the user requests IMA to stage the
    entire measurements list;
 2. ``cat <_staged interface>``: the user reads the staged measurements;
 3. ``echo D > <_staged interface>`` : the user request IMA to delete
    staged measurements.

Staging and deleting:

 1. ``cat <_non_staged interface>``: the user reads the current
    measurements list and determines what the value N for staging should
    be;
 2. ``echo N > <_staged interface>``: the user requests IMA to delete N
    measurements from the current measurements list.

Since with the staging mechanism measurements entries are removed from the
kernel, the user needs to save the staged ones in a storage and concatenate
them together, so that it can present them to remote attestation agents as
if staging was never done.


Patch set content
=================

Patches 1-8 are preparatory patches to quickly replace the hash table,
maintain separate counters for the different measurements list types,
mediate access to the measurements list interface, and simplify the staging
patches.

Patch 9 introduces the staging with prompt flavor. Patch 10 makes it
possible to flush the hash table when deleting all the staged measurements.
Patch 11 introduces the staging and deleting flavor. Patch 12 avoids staged
measurements entries to be stored twice if there is contention between the
measurements interfaces and kexec. Patch 13 adds the documentation of the
staging mechanism.


Changelog
=========

v3:
 - Add Kconfig option to enable the staging mechanism (suggested by Mimi)
 - Change the meaning of BINARY_STAGED to be just the staged measurements
 - Separate the two staging flavors in two different functions:
   ima_queue_staged_delete_all() for staging with prompt,
   ima_queue_staged_delete_partial() for staging and deleting
 - Delete N entries without staging first (suggested by Mimi)
 - Avoid duplicate staged entries if there is contention between the
   measurements list interfaces and kexec

v2:
 - New patch to move measurements and violation counters outside the
   ima_h_table structure
 - New patch to quickly replace the hash table
 - Forbid partial deletion when flushing hash table (suggested by Mimi)
 - Ignore ima_flush_htable if CONFIG_IMA_DISABLE_HTABLE is enabled
 - BINARY_SIZE_* renamed to BINARY_* for better clarity
 - Removed ima_measurements_staged_exist and testing list empty instead
 - ima_queue_stage_trim() and ima_queue_delete_staged_trimmed() renamed to
   ima_queue_stage() and ima_queue_delete_staged()
 - New delete interval [1, ULONG_MAX - 1]
 - Rename ima_measure_lock to ima_measure_mutex
 - Move seq_open() and seq_release() outside the ima_measure_mutex lock
 - Drop ima_measurements_staged_read() and use seq_read() instead
 - Optimize create_securityfs_measurement_lists() changes
 - New file name format with _staged suffix at the end of the file name
 - Use _rcu list variant in ima_dump_measurement_list()
 - Remove support for direct trimming and splice the remaining entries to
   the active list (suggested by Mimi)
 - Hot swap the hash table if flushing is requested

v1:
 - Support for direct trimming without staging
 - Support unstaging on kexec (requested by Gregory Lumen)

Roberto Sassu (13):
  ima: Remove ima_h_table structure
  ima: Replace static htable queue with dynamically allocated array
  ima: Introduce per binary measurements list type ima_num_entries
    counter
  ima: Introduce per binary measurements list type binary_runtime_size
    value
  ima: Introduce _ima_measurements_start() and _ima_measurements_next()
  ima: Mediate open/release method of the measurements list
  ima: Use snprintf() in create_securityfs_measurement_lists
  ima: Introduce ima_dump_measurement()
  ima: Add support for staging measurements with prompt
  ima: Add support for flushing the hash table when staging measurements
  ima: Support staging and deleting N measurements entries
  ima: Return error on deleting staged measurements after kexec
  doc: security: Add documentation of the IMA staging mechanism

 .../admin-guide/kernel-parameters.txt         |   4 +
 Documentation/security/IMA-staging.rst        | 159 +++++++++
 Documentation/security/index.rst              |   1 +
 MAINTAINERS                                   |   2 +
 security/integrity/ima/Kconfig                |  16 +
 security/integrity/ima/ima.h                  |  28 +-
 security/integrity/ima/ima_api.c              |   2 +-
 security/integrity/ima/ima_fs.c               | 302 +++++++++++++++--
 security/integrity/ima/ima_init.c             |   5 +
 security/integrity/ima/ima_kexec.c            |  47 ++-
 security/integrity/ima/ima_queue.c            | 310 ++++++++++++++++--
 11 files changed, 803 insertions(+), 73 deletions(-)
 create mode 100644 Documentation/security/IMA-staging.rst

-- 
2.43.0


^ permalink raw reply	[flat|nested] 18+ messages in thread

end of thread, other threads:[~2026-03-27 17:02 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-26 17:29 [PATCH v4 00/13] ima: Introduce staging mechanism Roberto Sassu
2026-03-26 17:29 ` [PATCH v4 01/13] ima: Remove ima_h_table structure Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 02/13] ima: Replace static htable queue with dynamically allocated array Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 03/13] ima: Introduce per binary measurements list type ima_num_entries counter Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 04/13] ima: Introduce per binary measurements list type binary_runtime_size value Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 05/13] ima: Introduce _ima_measurements_start() and _ima_measurements_next() Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 06/13] ima: Mediate open/release method of the measurements list Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 07/13] ima: Use snprintf() in create_securityfs_measurement_lists Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 08/13] ima: Introduce ima_dump_measurement() Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 09/13] ima: Add support for staging measurements with prompt Roberto Sassu
2026-03-26 22:44   ` steven chen
2026-03-27 16:45     ` Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 10/13] ima: Add support for flushing the hash table when staging measurements Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 11/13] ima: Support staging and deleting N measurements entries Roberto Sassu
2026-03-26 23:19   ` steven chen
2026-03-27 17:02     ` Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 12/13] ima: Return error on deleting staged measurements after kexec Roberto Sassu
2026-03-26 17:30 ` [PATCH v4 13/13] doc: security: Add documentation of the IMA staging mechanism Roberto Sassu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox