From: Coiby Xu <coxu@redhat.com>
To: linux-integrity@vger.kernel.org
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Roberto Sassu <roberto.sassu@huawei.com>,
Dmitry Kasatkin <dmitry.kasatkin@gmail.com>,
Eric Snowberg <eric.snowberg@oracle.com>,
Paul Moore <paul@paul-moore.com>,
James Morris <jmorris@namei.org>,
"Serge E. Hallyn" <serge@hallyn.com>,
linux-security-module@vger.kernel.org (open list:SECURITY
SUBSYSTEM), linux-kernel@vger.kernel.org (open list)
Subject: [PATCH] ima: setting security.ima to fix security.evm for a file with IMA signature
Date: Tue, 9 Sep 2025 12:19:53 +0800 [thread overview]
Message-ID: <20250909041954.1626914-1-coxu@redhat.com> (raw)
When both IMA and EVM fix modes are enabled, accessing a file with IMA
signature won't cause security.evm to be fixed. But this doesn't happen
to a file with correct IMA hash already set because accessing it will
cause setting security.ima again which triggers fixing security.evm
thanks to security_inode_post_setxattr->evm_update_evmxattr.
Let's use the same mechanism to fix security.evm for a file with IMA
signature.
Signed-off-by: Coiby Xu <coxu@redhat.com>
---
security/integrity/ima/ima_appraise.c | 27 +++++++++++++++++++++------
1 file changed, 21 insertions(+), 6 deletions(-)
diff --git a/security/integrity/ima/ima_appraise.c b/security/integrity/ima/ima_appraise.c
index f435eff4667f..18c3907c5e44 100644
--- a/security/integrity/ima/ima_appraise.c
+++ b/security/integrity/ima/ima_appraise.c
@@ -595,12 +595,27 @@ int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,
integrity_audit_msg(audit_msgno, inode, filename,
op, cause, rc, 0);
} else if (status != INTEGRITY_PASS) {
- /* Fix mode, but don't replace file signatures. */
- if ((ima_appraise & IMA_APPRAISE_FIX) && !try_modsig &&
- (!xattr_value ||
- xattr_value->type != EVM_IMA_XATTR_DIGSIG)) {
- if (!ima_fix_xattr(dentry, iint))
- status = INTEGRITY_PASS;
+ /*
+ * Fix mode, but don't replace file signatures.
+ *
+ * When EVM fix mode is also enabled, security.evm will be
+ * fixed automatically when security.ima is set because of
+ * security_inode_post_setxattr->evm_update_evmxattr.
+ */
+ if ((ima_appraise & IMA_APPRAISE_FIX) && !try_modsig) {
+ if (!xattr_value ||
+ xattr_value->type != EVM_IMA_XATTR_DIGSIG) {
+ if (ima_fix_xattr(dentry, iint))
+ status = INTEGRITY_PASS;
+ } else if (xattr_value->type == EVM_IMA_XATTR_DIGSIG &&
+ evm_revalidate_status(XATTR_NAME_IMA)) {
+ if (!__vfs_setxattr_noperm(&nop_mnt_idmap,
+ dentry,
+ XATTR_NAME_IMA,
+ xattr_value,
+ xattr_len, 0))
+ status = INTEGRITY_PASS;
+ }
}
/*
base-commit: b320789d6883cc00ac78ce83bccbfe7ed58afcf0
--
2.51.0
next reply other threads:[~2025-09-09 4:20 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-09-09 4:19 Coiby Xu [this message]
2025-09-09 15:31 ` [PATCH] ima: setting security.ima to fix security.evm for a file with IMA signature Mimi Zohar
2025-09-10 1:20 ` Coiby Xu
2025-09-10 11:15 ` Mimi Zohar
2025-09-30 2:31 ` Coiby Xu
2025-09-15 21:05 ` Mimi Zohar
2025-09-24 8:03 ` Coiby Xu
2025-09-25 3:27 ` Mimi Zohar
2025-09-30 2:28 ` Coiby Xu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250909041954.1626914-1-coxu@redhat.com \
--to=coxu@redhat.com \
--cc=dmitry.kasatkin@gmail.com \
--cc=eric.snowberg@oracle.com \
--cc=jmorris@namei.org \
--cc=linux-integrity@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-security-module@vger.kernel.org \
--cc=paul@paul-moore.com \
--cc=roberto.sassu@huawei.com \
--cc=serge@hallyn.com \
--cc=zohar@linux.ibm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).