From: Mimi Zohar <zohar@linux.ibm.com>
To: linux-integrity@vger.kernel.org
Cc: Mimi Zohar <zohar@linux.ibm.com>,
Frederick Lawler <fred@cloudflare.com>,
Jeff Layton <jlayton@kernel.org>,
Roberto Sassu <roberto.sassu@huaweicloud.com>
Subject: [PATCH] ima: detect file change code cleanup
Date: Fri, 6 Mar 2026 14:01:40 -0500 [thread overview]
Message-ID: <20260306190141.309937-1-zohar@linux.ibm.com> (raw)
Functionally no change, just simplify the ima_detect_file_change() code.
Signed-off-by: Mimi Zohar <zohar@linux.ibm.com>
---
@Fred, looking to merge with commit 0824f861605d ("ima: fallback to using
i_version to detect file change")
security/integrity/ima/ima_main.c | 19 +++++++------------
1 file changed, 7 insertions(+), 12 deletions(-)
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 6c49afa8dcc0..5cea53fc36df 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -194,18 +194,13 @@ static bool ima_detect_file_change(struct ima_iint_cache *iint,
result = vfs_getattr_nosec(&file->f_path, &stat, STATX_CHANGE_COOKIE,
AT_STATX_SYNC_AS_STAT);
- if (!result && stat.result_mask & STATX_CHANGE_COOKIE &&
- stat.change_cookie != iint->real_inode.version)
- return true;
- else if (!(stat.result_mask & STATX_CHANGE_COOKIE) &&
- IS_I_VERSION(inode) &&
- !(inode_eq_iversion(inode, iint->real_inode.version)))
- return true;
- else if (!(stat.result_mask & STATX_CHANGE_COOKIE) &&
- !(IS_I_VERSION(inode)))
- return true;
-
- return false;
+ if (!result && stat.result_mask & STATX_CHANGE_COOKIE)
+ return stat.change_cookie != iint->real_inode.version;
+
+ if (IS_I_VERSION(inode))
+ return !inode_eq_iversion(inode, iint->real_inode.version);
+
+ return true;
}
static void ima_check_last_writer(struct ima_iint_cache *iint,
--
2.53.0
next reply other threads:[~2026-03-06 19:01 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-06 19:01 Mimi Zohar [this message]
2026-03-06 19:58 ` [PATCH] ima: detect file change code cleanup Frederick Lawler
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=20260306190141.309937-1-zohar@linux.ibm.com \
--to=zohar@linux.ibm.com \
--cc=fred@cloudflare.com \
--cc=jlayton@kernel.org \
--cc=linux-integrity@vger.kernel.org \
--cc=roberto.sassu@huaweicloud.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