1 // SPDX-License-Identifier: GPL-2.0-only
3 * Copyright (C) 2011 IBM Corporation
6 * Mimi Zohar <zohar@us.ibm.com>
8 #include <linux/module.h>
9 #include <linux/init.h>
10 #include <linux/file.h>
11 #include <linux/binfmts.h>
13 #include <linux/xattr.h>
14 #include <linux/magic.h>
15 #include <linux/ima.h>
16 #include <linux/evm.h>
17 #include <linux/fsverity.h>
18 #include <keys/system_keyring.h>
19 #include <uapi/linux/fsverity.h>
23 #ifdef CONFIG_IMA_APPRAISE_BOOTPARAM
24 static char *ima_appraise_cmdline_default __initdata;
25 core_param(ima_appraise, ima_appraise_cmdline_default, charp, 0);
27 void __init ima_appraise_parse_cmdline(void)
29 const char *str = ima_appraise_cmdline_default;
30 bool sb_state = arch_ima_get_secureboot();
31 int appraisal_state = ima_appraise;
36 if (strncmp(str, "off", 3) == 0)
38 else if (strncmp(str, "log", 3) == 0)
39 appraisal_state = IMA_APPRAISE_LOG;
40 else if (strncmp(str, "fix", 3) == 0)
41 appraisal_state = IMA_APPRAISE_FIX;
42 else if (strncmp(str, "enforce", 7) == 0)
43 appraisal_state = IMA_APPRAISE_ENFORCE;
45 pr_err("invalid \"%s\" appraise option", str);
47 /* If appraisal state was changed, but secure boot is enabled,
50 if (!(appraisal_state & IMA_APPRAISE_ENFORCE))
51 pr_info("Secure boot enabled: ignoring ima_appraise=%s option",
54 ima_appraise = appraisal_state;
60 * is_ima_appraise_enabled - return appraise status
62 * Only return enabled, if not in ima_appraise="fix" or "log" modes.
64 bool is_ima_appraise_enabled(void)
66 return ima_appraise & IMA_APPRAISE_ENFORCE;
70 * ima_must_appraise - set appraise flag
72 * Return 1 to appraise or hash
74 int ima_must_appraise(struct mnt_idmap *idmap, struct inode *inode,
75 int mask, enum ima_hooks func)
82 security_current_getlsmprop_subj(&prop);
83 return ima_match_policy(idmap, inode, current_cred(), &prop,
84 func, mask, IMA_APPRAISE | IMA_HASH, NULL,
88 static int ima_fix_xattr(struct dentry *dentry, struct ima_iint_cache *iint)
91 u8 algo = iint->ima_hash->algo;
93 if (algo <= HASH_ALGO_SHA1) {
95 iint->ima_hash->xattr.sha1.type = IMA_XATTR_DIGEST;
98 iint->ima_hash->xattr.ng.type = IMA_XATTR_DIGEST_NG;
99 iint->ima_hash->xattr.ng.algo = algo;
101 rc = __vfs_setxattr_noperm(&nop_mnt_idmap, dentry, XATTR_NAME_IMA,
102 &iint->ima_hash->xattr.data[offset],
103 (sizeof(iint->ima_hash->xattr) - offset) +
104 iint->ima_hash->length, 0);
108 /* Return specific func appraised cached result */
109 enum integrity_status ima_get_cache_status(struct ima_iint_cache *iint,
114 case MMAP_CHECK_REQPROT:
115 return iint->ima_mmap_status;
117 return iint->ima_bprm_status;
119 return iint->ima_creds_status;
122 return iint->ima_file_status;
123 case MODULE_CHECK ... MAX_CHECK - 1:
125 return iint->ima_read_status;
129 static void ima_set_cache_status(struct ima_iint_cache *iint,
131 enum integrity_status status)
135 case MMAP_CHECK_REQPROT:
136 iint->ima_mmap_status = status;
139 iint->ima_bprm_status = status;
142 iint->ima_creds_status = status;
146 iint->ima_file_status = status;
148 case MODULE_CHECK ... MAX_CHECK - 1:
150 iint->ima_read_status = status;
155 static void ima_cache_flags(struct ima_iint_cache *iint, enum ima_hooks func)
159 case MMAP_CHECK_REQPROT:
160 iint->flags |= (IMA_MMAP_APPRAISED | IMA_APPRAISED);
163 iint->flags |= (IMA_BPRM_APPRAISED | IMA_APPRAISED);
166 iint->flags |= (IMA_CREDS_APPRAISED | IMA_APPRAISED);
170 iint->flags |= (IMA_FILE_APPRAISED | IMA_APPRAISED);
172 case MODULE_CHECK ... MAX_CHECK - 1:
174 iint->flags |= (IMA_READ_APPRAISED | IMA_APPRAISED);
179 enum hash_algo ima_get_hash_algo(const struct evm_ima_xattr_data *xattr_value,
182 struct signature_v2_hdr *sig;
185 if (!xattr_value || xattr_len < 2)
186 /* return default hash algo */
187 return ima_hash_algo;
189 switch (xattr_value->type) {
190 case IMA_VERITY_DIGSIG:
191 sig = (typeof(sig))xattr_value;
192 if (sig->version != 3 || xattr_len <= sizeof(*sig) ||
193 sig->hash_algo >= HASH_ALGO__LAST)
194 return ima_hash_algo;
195 return sig->hash_algo;
196 case EVM_IMA_XATTR_DIGSIG:
197 sig = (typeof(sig))xattr_value;
198 if (sig->version != 2 || xattr_len <= sizeof(*sig)
199 || sig->hash_algo >= HASH_ALGO__LAST)
200 return ima_hash_algo;
201 return sig->hash_algo;
202 case IMA_XATTR_DIGEST_NG:
203 /* first byte contains algorithm id */
204 ret = xattr_value->data[0];
205 if (ret < HASH_ALGO__LAST)
208 case IMA_XATTR_DIGEST:
209 /* this is for backward compatibility */
210 if (xattr_len == 21) {
211 unsigned int zero = 0;
212 if (!memcmp(&xattr_value->data[16], &zero, 4))
213 return HASH_ALGO_MD5;
215 return HASH_ALGO_SHA1;
216 } else if (xattr_len == 17)
217 return HASH_ALGO_MD5;
221 /* return default hash algo */
222 return ima_hash_algo;
225 int ima_read_xattr(struct dentry *dentry,
226 struct evm_ima_xattr_data **xattr_value, int xattr_len)
230 ret = vfs_getxattr_alloc(&nop_mnt_idmap, dentry, XATTR_NAME_IMA,
231 (char **)xattr_value, xattr_len, GFP_NOFS);
232 if (ret == -EOPNOTSUPP)
238 * calc_file_id_hash - calculate the hash of the ima_file_id struct data
239 * @type: xattr type [enum evm_ima_xattr_type]
240 * @algo: hash algorithm [enum hash_algo]
241 * @digest: pointer to the digest to be hashed
242 * @hash: (out) pointer to the hash
244 * IMA signature version 3 disambiguates the data that is signed by
245 * indirectly signing the hash of the ima_file_id structure data.
247 * Signing the ima_file_id struct is currently only supported for
248 * IMA_VERITY_DIGSIG type xattrs.
250 * Return 0 on success, error code otherwise.
252 static int calc_file_id_hash(enum evm_ima_xattr_type type,
253 enum hash_algo algo, const u8 *digest,
254 struct ima_digest_data *hash)
256 struct ima_file_id file_id = {
257 .hash_type = IMA_VERITY_DIGSIG, .hash_algorithm = algo};
258 unsigned int unused = HASH_MAX_DIGESTSIZE - hash_digest_size[algo];
260 if (type != IMA_VERITY_DIGSIG)
263 memcpy(file_id.hash, digest, hash_digest_size[algo]);
266 hash->length = hash_digest_size[algo];
268 return ima_calc_buffer_hash(&file_id, sizeof(file_id) - unused, hash);
272 * xattr_verify - verify xattr digest or signature
274 * Verify whether the hash or signature matches the file contents.
276 * Return 0 on success, error code otherwise.
278 static int xattr_verify(enum ima_hooks func, struct ima_iint_cache *iint,
279 struct evm_ima_xattr_data *xattr_value, int xattr_len,
280 enum integrity_status *status, const char **cause)
282 struct ima_max_digest_data hash;
283 struct signature_v2_hdr *sig;
284 int rc = -EINVAL, hash_start = 0;
287 switch (xattr_value->type) {
288 case IMA_XATTR_DIGEST_NG:
289 /* first byte contains algorithm id */
292 case IMA_XATTR_DIGEST:
293 if (*status != INTEGRITY_PASS_IMMUTABLE) {
294 if (iint->flags & IMA_DIGSIG_REQUIRED) {
295 if (iint->flags & IMA_VERITY_REQUIRED)
296 *cause = "verity-signature-required";
298 *cause = "IMA-signature-required";
299 *status = INTEGRITY_FAIL;
302 clear_bit(IMA_DIGSIG, &iint->atomic_flags);
304 set_bit(IMA_DIGSIG, &iint->atomic_flags);
306 if (xattr_len - sizeof(xattr_value->type) - hash_start >=
307 iint->ima_hash->length)
309 * xattr length may be longer. md5 hash in previous
310 * version occupied 20 bytes in xattr, instead of 16
312 rc = memcmp(&xattr_value->data[hash_start],
313 iint->ima_hash->digest,
314 iint->ima_hash->length);
318 *cause = "invalid-hash";
319 *status = INTEGRITY_FAIL;
322 *status = INTEGRITY_PASS;
324 case EVM_IMA_XATTR_DIGSIG:
325 set_bit(IMA_DIGSIG, &iint->atomic_flags);
327 mask = IMA_DIGSIG_REQUIRED | IMA_VERITY_REQUIRED;
328 if ((iint->flags & mask) == mask) {
329 *cause = "verity-signature-required";
330 *status = INTEGRITY_FAIL;
334 sig = (typeof(sig))xattr_value;
335 if (sig->version >= 3) {
336 *cause = "invalid-signature-version";
337 *status = INTEGRITY_FAIL;
340 rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA,
341 (const char *)xattr_value,
343 iint->ima_hash->digest,
344 iint->ima_hash->length);
345 if (rc == -EOPNOTSUPP) {
346 *status = INTEGRITY_UNKNOWN;
349 if (IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING) && rc &&
350 func == KEXEC_KERNEL_CHECK)
351 rc = integrity_digsig_verify(INTEGRITY_KEYRING_PLATFORM,
352 (const char *)xattr_value,
354 iint->ima_hash->digest,
355 iint->ima_hash->length);
357 *cause = "invalid-signature";
358 *status = INTEGRITY_FAIL;
360 *status = INTEGRITY_PASS;
363 case IMA_VERITY_DIGSIG:
364 set_bit(IMA_DIGSIG, &iint->atomic_flags);
366 if (iint->flags & IMA_DIGSIG_REQUIRED) {
367 if (!(iint->flags & IMA_VERITY_REQUIRED)) {
368 *cause = "IMA-signature-required";
369 *status = INTEGRITY_FAIL;
374 sig = (typeof(sig))xattr_value;
375 if (sig->version != 3) {
376 *cause = "invalid-signature-version";
377 *status = INTEGRITY_FAIL;
381 rc = calc_file_id_hash(IMA_VERITY_DIGSIG, iint->ima_hash->algo,
382 iint->ima_hash->digest,
383 container_of(&hash.hdr,
384 struct ima_digest_data, hdr));
386 *cause = "sigv3-hashing-error";
387 *status = INTEGRITY_FAIL;
391 rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA,
392 (const char *)xattr_value,
393 xattr_len, hash.digest,
396 *cause = "invalid-verity-signature";
397 *status = INTEGRITY_FAIL;
399 *status = INTEGRITY_PASS;
404 *status = INTEGRITY_UNKNOWN;
405 *cause = "unknown-ima-data";
413 * modsig_verify - verify modsig signature
415 * Verify whether the signature matches the file contents.
417 * Return 0 on success, error code otherwise.
419 static int modsig_verify(enum ima_hooks func, const struct modsig *modsig,
420 enum integrity_status *status, const char **cause)
424 rc = integrity_modsig_verify(INTEGRITY_KEYRING_IMA, modsig);
425 if (IS_ENABLED(CONFIG_INTEGRITY_PLATFORM_KEYRING) && rc &&
426 func == KEXEC_KERNEL_CHECK)
427 rc = integrity_modsig_verify(INTEGRITY_KEYRING_PLATFORM,
430 *cause = "invalid-signature";
431 *status = INTEGRITY_FAIL;
433 *status = INTEGRITY_PASS;
440 * ima_check_blacklist - determine if the binary is blacklisted.
442 * Add the hash of the blacklisted binary to the measurement list, based
445 * Returns -EPERM if the hash is blacklisted.
447 int ima_check_blacklist(struct ima_iint_cache *iint,
448 const struct modsig *modsig, int pcr)
450 enum hash_algo hash_algo;
451 const u8 *digest = NULL;
455 if (!(iint->flags & IMA_CHECK_BLACKLIST))
458 if (iint->flags & IMA_MODSIG_ALLOWED && modsig) {
459 ima_get_modsig_digest(modsig, &hash_algo, &digest, &digestsize);
461 rc = is_binary_blacklisted(digest, digestsize);
462 } else if (iint->flags & IMA_DIGSIG_REQUIRED && iint->ima_hash)
463 rc = is_binary_blacklisted(iint->ima_hash->digest, iint->ima_hash->length);
465 if ((rc == -EPERM) && (iint->flags & IMA_MEASURE))
466 process_buffer_measurement(&nop_mnt_idmap, NULL, digest, digestsize,
467 "blacklisted-hash", NONE,
468 pcr, NULL, false, NULL, 0);
473 static bool is_bprm_creds_for_exec(enum ima_hooks func, struct file *file)
475 struct linux_binprm *bprm;
477 if (func == BPRM_CHECK) {
478 bprm = container_of(&file, struct linux_binprm, file);
479 return bprm->is_check;
485 * ima_appraise_measurement - appraise file measurement
487 * Call evm_verifyxattr() to verify the integrity of 'security.ima'.
488 * Assuming success, compare the xattr hash with the collected measurement.
490 * Return 0 on success, error code otherwise
492 int ima_appraise_measurement(enum ima_hooks func, struct ima_iint_cache *iint,
493 struct file *file, const unsigned char *filename,
494 struct evm_ima_xattr_data *xattr_value,
495 int xattr_len, const struct modsig *modsig)
497 static const char op[] = "appraise_data";
498 int audit_msgno = AUDIT_INTEGRITY_DATA;
499 const char *cause = "unknown";
500 struct dentry *dentry = file_dentry(file);
501 struct inode *inode = d_backing_inode(dentry);
502 enum integrity_status status = INTEGRITY_UNKNOWN;
504 bool try_modsig = iint->flags & IMA_MODSIG_ALLOWED && modsig;
506 /* If not appraising a modsig, we need an xattr. */
507 if (!(inode->i_opflags & IOP_XATTR) && !try_modsig)
508 return INTEGRITY_UNKNOWN;
511 * Unlike any of the other LSM hooks where the kernel enforces file
512 * integrity, enforcing file integrity for the bprm_creds_for_exec()
513 * LSM hook with the AT_EXECVE_CHECK flag is left up to the discretion
514 * of the script interpreter(userspace). Differentiate kernel and
515 * userspace enforced integrity audit messages.
517 if (is_bprm_creds_for_exec(func, file))
518 audit_msgno = AUDIT_INTEGRITY_USERSPACE;
520 /* If reading the xattr failed and there's no modsig, error out. */
521 if (rc <= 0 && !try_modsig) {
522 if (rc && rc != -ENODATA)
525 if (iint->flags & IMA_DIGSIG_REQUIRED) {
526 if (iint->flags & IMA_VERITY_REQUIRED)
527 cause = "verity-signature-required";
529 cause = "IMA-signature-required";
531 cause = "missing-hash";
534 status = INTEGRITY_NOLABEL;
535 if (file->f_mode & FMODE_CREATED)
536 iint->flags |= IMA_NEW_FILE;
537 if ((iint->flags & IMA_NEW_FILE) &&
538 (!(iint->flags & IMA_DIGSIG_REQUIRED) ||
539 (inode->i_size == 0)))
540 status = INTEGRITY_PASS;
544 status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value,
548 case INTEGRITY_PASS_IMMUTABLE:
549 case INTEGRITY_UNKNOWN:
551 case INTEGRITY_NOXATTRS: /* No EVM protected xattrs. */
552 /* It's fine not to have xattrs when using a modsig. */
556 case INTEGRITY_NOLABEL: /* No security.evm xattr. */
557 cause = "missing-HMAC";
559 case INTEGRITY_FAIL_IMMUTABLE:
560 set_bit(IMA_DIGSIG, &iint->atomic_flags);
561 cause = "invalid-fail-immutable";
563 case INTEGRITY_FAIL: /* Invalid HMAC/signature. */
564 cause = "invalid-HMAC";
567 WARN_ONCE(true, "Unexpected integrity status %d\n", status);
571 rc = xattr_verify(func, iint, xattr_value, xattr_len, &status,
575 * If we have a modsig and either no imasig or the imasig's key isn't
576 * known, then try verifying the modsig.
579 (!xattr_value || xattr_value->type == IMA_XATTR_DIGEST_NG ||
581 rc = modsig_verify(func, modsig, &status, &cause);
585 * File signatures on some filesystems can not be properly verified.
586 * When such filesystems are mounted by an untrusted mounter or on a
587 * system not willing to accept such a risk, fail the file signature
590 if ((inode->i_sb->s_iflags & SB_I_IMA_UNVERIFIABLE_SIGNATURE) &&
591 ((inode->i_sb->s_iflags & SB_I_UNTRUSTED_MOUNTER) ||
592 (iint->flags & IMA_FAIL_UNVERIFIABLE_SIGS))) {
593 status = INTEGRITY_FAIL;
594 cause = "unverifiable-signature";
595 integrity_audit_msg(audit_msgno, inode, filename,
597 } else if (status != INTEGRITY_PASS) {
598 /* Fix mode, but don't replace file signatures. */
599 if ((ima_appraise & IMA_APPRAISE_FIX) && !try_modsig &&
601 xattr_value->type != EVM_IMA_XATTR_DIGSIG)) {
602 if (!ima_fix_xattr(dentry, iint))
603 status = INTEGRITY_PASS;
607 * Permit new files with file/EVM portable signatures, but
610 if (inode->i_size == 0 && iint->flags & IMA_NEW_FILE &&
611 test_bit(IMA_DIGSIG, &iint->atomic_flags)) {
612 status = INTEGRITY_PASS;
615 integrity_audit_msg(audit_msgno, inode, filename,
618 ima_cache_flags(iint, func);
621 ima_set_cache_status(iint, func, status);
626 * ima_update_xattr - update 'security.ima' hash value
628 void ima_update_xattr(struct ima_iint_cache *iint, struct file *file)
630 struct dentry *dentry = file_dentry(file);
633 /* do not collect and update hash for digital signatures */
634 if (test_bit(IMA_DIGSIG, &iint->atomic_flags))
637 if ((iint->ima_file_status != INTEGRITY_PASS) &&
638 !(iint->flags & IMA_HASH))
641 rc = ima_collect_measurement(iint, file, NULL, 0, ima_hash_algo, NULL);
645 inode_lock(file_inode(file));
646 ima_fix_xattr(dentry, iint);
647 inode_unlock(file_inode(file));
651 * ima_inode_post_setattr - reflect file metadata changes
652 * @idmap: idmap of the mount the inode was found from
653 * @dentry: pointer to the affected dentry
654 * @ia_valid: for the UID and GID status
656 * Changes to a dentry's metadata might result in needing to appraise.
658 * This function is called from notify_change(), which expects the caller
659 * to lock the inode's i_mutex.
661 static void ima_inode_post_setattr(struct mnt_idmap *idmap,
662 struct dentry *dentry, int ia_valid)
664 struct inode *inode = d_backing_inode(dentry);
665 struct ima_iint_cache *iint;
668 if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode)
669 || !(inode->i_opflags & IOP_XATTR))
672 action = ima_must_appraise(idmap, inode, MAY_ACCESS, POST_SETATTR);
673 iint = ima_iint_find(inode);
675 set_bit(IMA_CHANGE_ATTR, &iint->atomic_flags);
677 clear_bit(IMA_UPDATE_XATTR, &iint->atomic_flags);
682 * ima_protect_xattr - protect 'security.ima'
684 * Ensure that not just anyone can modify or remove 'security.ima'.
686 static int ima_protect_xattr(struct dentry *dentry, const char *xattr_name,
687 const void *xattr_value, size_t xattr_value_len)
689 if (strcmp(xattr_name, XATTR_NAME_IMA) == 0) {
690 if (!capable(CAP_SYS_ADMIN))
697 static void ima_reset_appraise_flags(struct inode *inode, int digsig)
699 struct ima_iint_cache *iint;
701 if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode))
704 iint = ima_iint_find(inode);
707 iint->measured_pcrs = 0;
708 set_bit(IMA_CHANGE_XATTR, &iint->atomic_flags);
710 set_bit(IMA_DIGSIG, &iint->atomic_flags);
712 clear_bit(IMA_DIGSIG, &iint->atomic_flags);
716 * validate_hash_algo() - Block setxattr with unsupported hash algorithms
717 * @dentry: object of the setxattr()
718 * @xattr_value: userland supplied xattr value
719 * @xattr_value_len: length of xattr_value
721 * The xattr value is mapped to its hash algorithm, and this algorithm
722 * must be built in the kernel for the setxattr to be allowed.
724 * Emit an audit message when the algorithm is invalid.
726 * Return: 0 on success, else an error.
728 static int validate_hash_algo(struct dentry *dentry,
729 const struct evm_ima_xattr_data *xattr_value,
730 size_t xattr_value_len)
732 char *path = NULL, *pathbuf = NULL;
733 enum hash_algo xattr_hash_algo;
734 const char *errmsg = "unavailable-hash-algorithm";
735 unsigned int allowed_hashes;
737 xattr_hash_algo = ima_get_hash_algo(xattr_value, xattr_value_len);
739 allowed_hashes = atomic_read(&ima_setxattr_allowed_hash_algorithms);
741 if (allowed_hashes) {
742 /* success if the algorithm is allowed in the ima policy */
743 if (allowed_hashes & (1U << xattr_hash_algo))
747 * We use a different audit message when the hash algorithm
748 * is denied by a policy rule, instead of not being built
749 * in the kernel image
751 errmsg = "denied-hash-algorithm";
753 if (likely(xattr_hash_algo == ima_hash_algo))
756 /* allow any xattr using an algorithm built in the kernel */
757 if (crypto_has_alg(hash_algo_name[xattr_hash_algo], 0, 0))
761 pathbuf = kmalloc(PATH_MAX, GFP_KERNEL);
765 path = dentry_path(dentry, pathbuf, PATH_MAX);
767 integrity_audit_msg(AUDIT_INTEGRITY_DATA, d_inode(dentry), path,
768 "set_data", errmsg, -EACCES, 0);
775 static int ima_inode_setxattr(struct mnt_idmap *idmap, struct dentry *dentry,
776 const char *xattr_name, const void *xattr_value,
777 size_t xattr_value_len, int flags)
779 const struct evm_ima_xattr_data *xvalue = xattr_value;
784 result = ima_protect_xattr(dentry, xattr_name, xattr_value,
787 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
790 err = validate_hash_algo(dentry, xvalue, xattr_value_len);
794 digsig = (xvalue->type == EVM_IMA_XATTR_DIGSIG);
795 } else if (!strcmp(xattr_name, XATTR_NAME_EVM) && xattr_value_len > 0) {
796 digsig = (xvalue->type == EVM_XATTR_PORTABLE_DIGSIG);
798 if (result == 1 || evm_revalidate_status(xattr_name)) {
799 ima_reset_appraise_flags(d_backing_inode(dentry), digsig);
806 static int ima_inode_set_acl(struct mnt_idmap *idmap, struct dentry *dentry,
807 const char *acl_name, struct posix_acl *kacl)
809 if (evm_revalidate_status(acl_name))
810 ima_reset_appraise_flags(d_backing_inode(dentry), 0);
815 static int ima_inode_removexattr(struct mnt_idmap *idmap, struct dentry *dentry,
816 const char *xattr_name)
820 result = ima_protect_xattr(dentry, xattr_name, NULL, 0);
821 if (result == 1 || evm_revalidate_status(xattr_name)) {
822 ima_reset_appraise_flags(d_backing_inode(dentry), 0);
829 static int ima_inode_remove_acl(struct mnt_idmap *idmap, struct dentry *dentry,
830 const char *acl_name)
832 return ima_inode_set_acl(idmap, dentry, acl_name, NULL);
835 static struct security_hook_list ima_appraise_hooks[] __ro_after_init = {
836 LSM_HOOK_INIT(inode_post_setattr, ima_inode_post_setattr),
837 LSM_HOOK_INIT(inode_setxattr, ima_inode_setxattr),
838 LSM_HOOK_INIT(inode_set_acl, ima_inode_set_acl),
839 LSM_HOOK_INIT(inode_removexattr, ima_inode_removexattr),
840 LSM_HOOK_INIT(inode_remove_acl, ima_inode_remove_acl),
843 void __init init_ima_appraise_lsm(const struct lsm_id *lsmid)
845 security_add_hooks(ima_appraise_hooks, ARRAY_SIZE(ima_appraise_hooks),