twx-linux/security/integrity
Roberto Sassu 5b6eac63d1 ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr
commit 57a0ef02fefafc4b9603e33a18b669ba5ce59ba3 upstream.

Commit 0d73a55208e9 ("ima: re-introduce own integrity cache lock")
mistakenly reverted the performance improvement introduced in commit
42a4c603198f0 ("ima: fix ima_inode_post_setattr"). The unused bit mask was
subsequently removed by commit 11c60f23ed13 ("integrity: Remove unused
macro IMA_ACTION_RULE_FLAGS").

Restore the performance improvement by introducing the new mask
IMA_NONACTION_RULE_FLAGS, equal to IMA_NONACTION_FLAGS without
IMA_NEW_FILE, which is not a rule-specific flag.

Finally, reset IMA_NONACTION_RULE_FLAGS instead of IMA_NONACTION_FLAGS in
process_measurement(), if the IMA_CHANGE_ATTR atomic flag is set (after
file metadata modification).

With this patch, new files for which metadata were modified while they are
still open, can be reopened before the last file close (when security.ima
is written), since the IMA_NEW_FILE flag is not cleared anymore. Otherwise,
appraisal fails because security.ima is missing (files with IMA_NEW_FILE
set are an exception).

Cc: stable@vger.kernel.org # v4.16.x
Fixes: 0d73a55208e9 ("ima: re-introduce own integrity cache lock")
Signed-off-by: Roberto Sassu <roberto.sassu@huawei.com>
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2025-03-13 12:58:40 +01:00
..
evm evm: don't copy up 'security.evm' xattr 2024-08-29 17:33:31 +02:00
ima ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr 2025-03-13 12:58:40 +01:00
platform_certs Hi, 2023-08-29 08:05:18 -07:00
digsig_asymmetric.c ima: fix reference leak in asymmetric_verify() 2022-01-24 18:37:36 -05:00
digsig.c integrity: check whether imputed trust is enabled 2023-08-17 20:12:35 +00:00
iint.c ima: annotate iint mutex to avoid lockdep false positive warnings 2023-11-28 17:20:03 +00:00
integrity_audit.c integrity: check the return value of audit_log_start() 2022-02-02 11:44:23 -05:00
integrity.h ima: Reset IMA_NONACTION_RULE_FLAGS after post_setattr 2025-03-13 12:58:40 +01:00
Kconfig integrity: powerpc: Do not select CA_MACHINE_KEYRING 2023-11-28 17:20:01 +00:00
Makefile integrity: Introduce a Linux keyring called machine 2022-03-08 13:55:52 +02:00