blob: 7bf8b005a178c4529d5e69c1d3e8ed1bf4cedc94 [file] [log] [blame]
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -05001/*
2 * Copyright (C) 2011 IBM Corporation
3 *
4 * Author:
5 * Mimi Zohar <zohar@us.ibm.com>
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, version 2 of the License.
10 */
11#include <linux/module.h>
12#include <linux/file.h>
13#include <linux/fs.h>
14#include <linux/xattr.h>
15#include <linux/magic.h>
16#include <linux/ima.h>
17#include <linux/evm.h>
18
19#include "ima.h"
20
21static int __init default_appraise_setup(char *str)
22{
23 if (strncmp(str, "off", 3) == 0)
24 ima_appraise = 0;
Dmitry Kasatkin2faa6ef2014-05-08 13:11:29 +030025 else if (strncmp(str, "log", 3) == 0)
26 ima_appraise = IMA_APPRAISE_LOG;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -050027 else if (strncmp(str, "fix", 3) == 0)
28 ima_appraise = IMA_APPRAISE_FIX;
29 return 1;
30}
31
32__setup("ima_appraise=", default_appraise_setup);
33
34/*
35 * ima_must_appraise - set appraise flag
36 *
37 * Return 1 to appraise
38 */
Dmitry Kasatkind26e1932012-09-27 18:26:53 +030039int ima_must_appraise(struct inode *inode, int mask, enum ima_hooks func)
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -050040{
Mimi Zohar07f6a792011-03-09 22:25:48 -050041 if (!ima_appraise)
42 return 0;
43
Eric Richter725de7f2016-06-01 13:14:02 -050044 return ima_match_policy(inode, func, mask, IMA_APPRAISE, NULL);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -050045}
46
Dmitry Kasatkindef3e8b2012-09-20 22:38:53 +030047static int ima_fix_xattr(struct dentry *dentry,
Dmitry Kasatkinc7c8bb22013-04-25 10:43:56 +030048 struct integrity_iint_cache *iint)
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -050049{
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +030050 int rc, offset;
51 u8 algo = iint->ima_hash->algo;
52
53 if (algo <= HASH_ALGO_SHA1) {
54 offset = 1;
55 iint->ima_hash->xattr.sha1.type = IMA_XATTR_DIGEST;
56 } else {
57 offset = 0;
58 iint->ima_hash->xattr.ng.type = IMA_XATTR_DIGEST_NG;
59 iint->ima_hash->xattr.ng.algo = algo;
60 }
61 rc = __vfs_setxattr_noperm(dentry, XATTR_NAME_IMA,
62 &iint->ima_hash->xattr.data[offset],
63 (sizeof(iint->ima_hash->xattr) - offset) +
64 iint->ima_hash->length, 0);
65 return rc;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -050066}
67
Mimi Zohard79d72e2012-12-03 17:08:11 -050068/* Return specific func appraised cached result */
69enum integrity_status ima_get_cache_status(struct integrity_iint_cache *iint,
Mimi Zohar4ad87a32016-01-14 20:59:14 -050070 enum ima_hooks func)
Mimi Zohard79d72e2012-12-03 17:08:11 -050071{
Dmitry Kasatkin089bc8e2013-10-10 15:56:13 +090072 switch (func) {
Mimi Zohard79d72e2012-12-03 17:08:11 -050073 case MMAP_CHECK:
74 return iint->ima_mmap_status;
75 case BPRM_CHECK:
76 return iint->ima_bprm_status;
Mimi Zohard79d72e2012-12-03 17:08:11 -050077 case FILE_CHECK:
Mimi Zoharc6af8ef2015-11-19 12:39:22 -050078 case POST_SETATTR:
Mimi Zohard79d72e2012-12-03 17:08:11 -050079 return iint->ima_file_status;
Mimi Zoharc6af8ef2015-11-19 12:39:22 -050080 case MODULE_CHECK ... MAX_CHECK - 1:
81 default:
82 return iint->ima_read_status;
Mimi Zohard79d72e2012-12-03 17:08:11 -050083 }
84}
85
86static void ima_set_cache_status(struct integrity_iint_cache *iint,
Mimi Zohar4ad87a32016-01-14 20:59:14 -050087 enum ima_hooks func,
88 enum integrity_status status)
Mimi Zohard79d72e2012-12-03 17:08:11 -050089{
Dmitry Kasatkin089bc8e2013-10-10 15:56:13 +090090 switch (func) {
Mimi Zohard79d72e2012-12-03 17:08:11 -050091 case MMAP_CHECK:
92 iint->ima_mmap_status = status;
93 break;
94 case BPRM_CHECK:
95 iint->ima_bprm_status = status;
96 break;
Mimi Zohard79d72e2012-12-03 17:08:11 -050097 case FILE_CHECK:
Mimi Zoharc6af8ef2015-11-19 12:39:22 -050098 case POST_SETATTR:
Mimi Zohard79d72e2012-12-03 17:08:11 -050099 iint->ima_file_status = status;
Mimi Zoharc6af8ef2015-11-19 12:39:22 -0500100 break;
101 case MODULE_CHECK ... MAX_CHECK - 1:
102 default:
103 iint->ima_read_status = status;
104 break;
Mimi Zohard79d72e2012-12-03 17:08:11 -0500105 }
106}
107
Mimi Zohar4ad87a32016-01-14 20:59:14 -0500108static void ima_cache_flags(struct integrity_iint_cache *iint,
109 enum ima_hooks func)
Mimi Zohard79d72e2012-12-03 17:08:11 -0500110{
Dmitry Kasatkin089bc8e2013-10-10 15:56:13 +0900111 switch (func) {
Mimi Zohard79d72e2012-12-03 17:08:11 -0500112 case MMAP_CHECK:
113 iint->flags |= (IMA_MMAP_APPRAISED | IMA_APPRAISED);
114 break;
115 case BPRM_CHECK:
116 iint->flags |= (IMA_BPRM_APPRAISED | IMA_APPRAISED);
117 break;
Mimi Zohard79d72e2012-12-03 17:08:11 -0500118 case FILE_CHECK:
Mimi Zoharc6af8ef2015-11-19 12:39:22 -0500119 case POST_SETATTR:
Mimi Zohard79d72e2012-12-03 17:08:11 -0500120 iint->flags |= (IMA_FILE_APPRAISED | IMA_APPRAISED);
Mimi Zoharc6af8ef2015-11-19 12:39:22 -0500121 break;
122 case MODULE_CHECK ... MAX_CHECK - 1:
123 default:
124 iint->flags |= (IMA_READ_APPRAISED | IMA_APPRAISED);
125 break;
Mimi Zohard79d72e2012-12-03 17:08:11 -0500126 }
127}
128
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200129enum hash_algo ima_get_hash_algo(struct evm_ima_xattr_data *xattr_value,
130 int xattr_len)
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300131{
132 struct signature_v2_hdr *sig;
133
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300134 if (!xattr_value || xattr_len < 2)
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200135 /* return default hash algo */
136 return ima_hash_algo;
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300137
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300138 switch (xattr_value->type) {
139 case EVM_IMA_XATTR_DIGSIG:
140 sig = (typeof(sig))xattr_value;
141 if (sig->version != 2 || xattr_len <= sizeof(*sig))
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200142 return ima_hash_algo;
143 return sig->hash_algo;
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300144 break;
145 case IMA_XATTR_DIGEST_NG:
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200146 return xattr_value->digest[0];
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300147 break;
148 case IMA_XATTR_DIGEST:
149 /* this is for backward compatibility */
150 if (xattr_len == 21) {
151 unsigned int zero = 0;
152 if (!memcmp(&xattr_value->digest[16], &zero, 4))
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200153 return HASH_ALGO_MD5;
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300154 else
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200155 return HASH_ALGO_SHA1;
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300156 } else if (xattr_len == 17)
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200157 return HASH_ALGO_MD5;
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300158 break;
159 }
Dmitry Kasatkin1525b062014-10-30 12:39:39 +0200160
161 /* return default hash algo */
162 return ima_hash_algo;
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300163}
164
165int ima_read_xattr(struct dentry *dentry,
166 struct evm_ima_xattr_data **xattr_value)
167{
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200168 ssize_t ret;
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300169
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200170 ret = vfs_getxattr_alloc(dentry, XATTR_NAME_IMA, (char **)xattr_value,
171 0, GFP_NOFS);
172 if (ret == -EOPNOTSUPP)
173 ret = 0;
174 return ret;
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300175}
176
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500177/*
178 * ima_appraise_measurement - appraise file measurement
179 *
180 * Call evm_verifyxattr() to verify the integrity of 'security.ima'.
181 * Assuming success, compare the xattr hash with the collected measurement.
182 *
183 * Return 0 on success, error code otherwise
184 */
Mimi Zohar4ad87a32016-01-14 20:59:14 -0500185int ima_appraise_measurement(enum ima_hooks func,
186 struct integrity_iint_cache *iint,
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300187 struct file *file, const unsigned char *filename,
188 struct evm_ima_xattr_data *xattr_value,
Dmitry Kasatkin3034a142014-06-27 18:15:44 +0300189 int xattr_len, int opened)
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500190{
Mimi Zohar52a13282013-12-11 14:44:04 -0500191 static const char op[] = "appraise_data";
192 char *cause = "unknown";
Miklos Szeredie71b9df2016-09-16 12:44:20 +0200193 struct dentry *dentry = file_dentry(file);
David Howellsc6f493d2015-03-17 22:26:22 +0000194 struct inode *inode = d_backing_inode(dentry);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500195 enum integrity_status status = INTEGRITY_UNKNOWN;
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300196 int rc = xattr_len, hash_start = 0;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500197
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200198 if (!(inode->i_opflags & IOP_XATTR))
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500199 return INTEGRITY_UNKNOWN;
200
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500201 if (rc <= 0) {
202 if (rc && rc != -ENODATA)
203 goto out;
204
205 cause = "missing-hash";
Dmitry Kasatkinb151d6b2014-06-27 18:04:27 +0300206 status = INTEGRITY_NOLABEL;
Daniel Glöckner910342552017-02-24 15:05:14 +0100207 if (opened & FILE_CREATED)
Dmitry Kasatkinb151d6b2014-06-27 18:04:27 +0300208 iint->flags |= IMA_NEW_FILE;
Daniel Glöckner910342552017-02-24 15:05:14 +0100209 if ((iint->flags & IMA_NEW_FILE) &&
Mimi Zohar27a08562017-11-08 07:38:28 -0500210 (!(iint->flags & IMA_DIGSIG_REQUIRED) ||
211 (inode->i_size == 0)))
Dmitry Kasatkinb151d6b2014-06-27 18:04:27 +0300212 status = INTEGRITY_PASS;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500213 goto out;
214 }
215
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300216 status = evm_verifyxattr(dentry, XATTR_NAME_IMA, xattr_value, rc, iint);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500217 if ((status != INTEGRITY_PASS) && (status != INTEGRITY_UNKNOWN)) {
218 if ((status == INTEGRITY_NOLABEL)
219 || (status == INTEGRITY_NOXATTRS))
220 cause = "missing-HMAC";
221 else if (status == INTEGRITY_FAIL)
222 cause = "invalid-HMAC";
223 goto out;
224 }
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300225 switch (xattr_value->type) {
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300226 case IMA_XATTR_DIGEST_NG:
227 /* first byte contains algorithm id */
228 hash_start = 1;
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300229 case IMA_XATTR_DIGEST:
Dmitry Kasatkin0e5a2472012-06-08 13:58:49 +0300230 if (iint->flags & IMA_DIGSIG_REQUIRED) {
Richard Guy Briggs7e9001f2014-06-16 15:52:07 -0400231 cause = "IMA-signature-required";
Dmitry Kasatkin0e5a2472012-06-08 13:58:49 +0300232 status = INTEGRITY_FAIL;
233 break;
234 }
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300235 if (xattr_len - sizeof(xattr_value->type) - hash_start >=
236 iint->ima_hash->length)
Dmitry Kasatkind3634d02013-04-25 10:44:04 +0300237 /* xattr length may be longer. md5 hash in previous
238 version occupied 20 bytes in xattr, instead of 16
239 */
Dmitry Kasatkin3ea7a562013-08-12 11:22:51 +0300240 rc = memcmp(&xattr_value->digest[hash_start],
Dmitry Kasatkina35c3fb2013-04-25 10:44:04 +0300241 iint->ima_hash->digest,
242 iint->ima_hash->length);
Dmitry Kasatkinc7c8bb22013-04-25 10:43:56 +0300243 else
244 rc = -EINVAL;
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300245 if (rc) {
246 cause = "invalid-hash";
247 status = INTEGRITY_FAIL;
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300248 break;
249 }
250 status = INTEGRITY_PASS;
251 break;
252 case EVM_IMA_XATTR_DIGSIG:
253 iint->flags |= IMA_DIGSIG;
254 rc = integrity_digsig_verify(INTEGRITY_KEYRING_IMA,
Dmitry Kasatkinb1aaab22013-10-10 16:12:03 +0900255 (const char *)xattr_value, rc,
Dmitry Kasatkina35c3fb2013-04-25 10:44:04 +0300256 iint->ima_hash->digest,
257 iint->ima_hash->length);
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300258 if (rc == -EOPNOTSUPP) {
259 status = INTEGRITY_UNKNOWN;
260 } else if (rc) {
261 cause = "invalid-signature";
262 status = INTEGRITY_FAIL;
263 } else {
264 status = INTEGRITY_PASS;
265 }
266 break;
267 default:
268 status = INTEGRITY_UNKNOWN;
269 cause = "unknown-ima-data";
270 break;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500271 }
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300272
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500273out:
274 if (status != INTEGRITY_PASS) {
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300275 if ((ima_appraise & IMA_APPRAISE_FIX) &&
276 (!xattr_value ||
277 xattr_value->type != EVM_IMA_XATTR_DIGSIG)) {
Dmitry Kasatkindef3e8b2012-09-20 22:38:53 +0300278 if (!ima_fix_xattr(dentry, iint))
279 status = INTEGRITY_PASS;
Mimi Zohar05d1a712016-02-29 19:52:05 -0500280 } else if ((inode->i_size == 0) &&
281 (iint->flags & IMA_NEW_FILE) &&
282 (xattr_value &&
283 xattr_value->type == EVM_IMA_XATTR_DIGSIG)) {
284 status = INTEGRITY_PASS;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500285 }
286 integrity_audit_msg(AUDIT_INTEGRITY_DATA, inode, filename,
287 op, cause, rc, 0);
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300288 } else {
Mimi Zohard79d72e2012-12-03 17:08:11 -0500289 ima_cache_flags(iint, func);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500290 }
Mimi Zohard79d72e2012-12-03 17:08:11 -0500291 ima_set_cache_status(iint, func, status);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500292 return status;
293}
294
295/*
296 * ima_update_xattr - update 'security.ima' hash value
297 */
298void ima_update_xattr(struct integrity_iint_cache *iint, struct file *file)
299{
Miklos Szeredie71b9df2016-09-16 12:44:20 +0200300 struct dentry *dentry = file_dentry(file);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500301 int rc = 0;
302
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300303 /* do not collect and update hash for digital signatures */
304 if (iint->flags & IMA_DIGSIG)
305 return;
306
Roberto Sassu2cfbb322017-11-07 11:37:07 +0100307 if (iint->ima_file_status != INTEGRITY_PASS)
308 return;
309
Mimi Zoharcf222212016-01-14 17:57:47 -0500310 rc = ima_collect_measurement(iint, file, NULL, 0, ima_hash_algo);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500311 if (rc < 0)
312 return;
Dmitry Kasatkin86064042011-08-31 14:07:06 +0300313
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500314 ima_fix_xattr(dentry, iint);
315}
316
317/**
318 * ima_inode_post_setattr - reflect file metadata changes
319 * @dentry: pointer to the affected dentry
320 *
321 * Changes to a dentry's metadata might result in needing to appraise.
322 *
323 * This function is called from notify_change(), which expects the caller
324 * to lock the inode's i_mutex.
325 */
326void ima_inode_post_setattr(struct dentry *dentry)
327{
David Howellsc6f493d2015-03-17 22:26:22 +0000328 struct inode *inode = d_backing_inode(dentry);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500329 struct integrity_iint_cache *iint;
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200330 int must_appraise;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500331
Roberto Sassua7560242014-09-12 19:35:54 +0200332 if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode)
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200333 || !(inode->i_opflags & IOP_XATTR))
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500334 return;
335
336 must_appraise = ima_must_appraise(inode, MAY_ACCESS, POST_SETATTR);
337 iint = integrity_iint_find(inode);
338 if (iint) {
Mimi Zohard79d72e2012-12-03 17:08:11 -0500339 iint->flags &= ~(IMA_APPRAISE | IMA_APPRAISED |
340 IMA_APPRAISE_SUBMASK | IMA_APPRAISED_SUBMASK |
Mimi Zohar42a4c602016-02-29 08:30:12 -0500341 IMA_ACTION_RULE_FLAGS);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500342 if (must_appraise)
343 iint->flags |= IMA_APPRAISE;
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500344 }
345 if (!must_appraise)
Andreas Gruenbacher5d6c3192016-09-29 17:48:42 +0200346 __vfs_removexattr(dentry, XATTR_NAME_IMA);
Mimi Zohar2fe5d6d2012-02-13 10:15:05 -0500347}
Mimi Zohar42c63332011-03-10 18:54:15 -0500348
349/*
350 * ima_protect_xattr - protect 'security.ima'
351 *
352 * Ensure that not just anyone can modify or remove 'security.ima'.
353 */
354static int ima_protect_xattr(struct dentry *dentry, const char *xattr_name,
355 const void *xattr_value, size_t xattr_value_len)
356{
357 if (strcmp(xattr_name, XATTR_NAME_IMA) == 0) {
358 if (!capable(CAP_SYS_ADMIN))
359 return -EPERM;
360 return 1;
361 }
362 return 0;
363}
364
Mimi Zohar060bdebfb2014-03-17 23:24:18 -0400365static void ima_reset_appraise_flags(struct inode *inode, int digsig)
Mimi Zohar42c63332011-03-10 18:54:15 -0500366{
367 struct integrity_iint_cache *iint;
368
Roberto Sassua7560242014-09-12 19:35:54 +0200369 if (!(ima_policy_flag & IMA_APPRAISE) || !S_ISREG(inode->i_mode))
Mimi Zohar42c63332011-03-10 18:54:15 -0500370 return;
371
372 iint = integrity_iint_find(inode);
373 if (!iint)
374 return;
375
Dmitry Kasatkin45e24722012-09-12 20:51:32 +0300376 iint->flags &= ~IMA_DONE_MASK;
Eric Richtera4226382016-06-01 13:14:06 -0500377 iint->measured_pcrs = 0;
Mimi Zohar060bdebfb2014-03-17 23:24:18 -0400378 if (digsig)
379 iint->flags |= IMA_DIGSIG;
Mimi Zohar42c63332011-03-10 18:54:15 -0500380 return;
381}
382
383int ima_inode_setxattr(struct dentry *dentry, const char *xattr_name,
384 const void *xattr_value, size_t xattr_value_len)
385{
Mimi Zohar060bdebfb2014-03-17 23:24:18 -0400386 const struct evm_ima_xattr_data *xvalue = xattr_value;
Mimi Zohar42c63332011-03-10 18:54:15 -0500387 int result;
388
389 result = ima_protect_xattr(dentry, xattr_name, xattr_value,
390 xattr_value_len);
391 if (result == 1) {
Dmitry Kasatkinc68ed802014-10-23 15:53:21 +0300392 bool digsig;
393
Dmitry Kasatkina48fda92014-10-28 13:31:22 +0200394 if (!xattr_value_len || (xvalue->type >= IMA_XATTR_LAST))
395 return -EINVAL;
Dmitry Kasatkinc68ed802014-10-23 15:53:21 +0300396 digsig = (xvalue->type == EVM_IMA_XATTR_DIGSIG);
397 if (!digsig && (ima_appraise & IMA_APPRAISE_ENFORCE))
398 return -EPERM;
399 ima_reset_appraise_flags(d_backing_inode(dentry), digsig);
Mimi Zohar42c63332011-03-10 18:54:15 -0500400 result = 0;
401 }
402 return result;
403}
404
405int ima_inode_removexattr(struct dentry *dentry, const char *xattr_name)
406{
407 int result;
408
409 result = ima_protect_xattr(dentry, xattr_name, NULL, 0);
410 if (result == 1) {
David Howellsc6f493d2015-03-17 22:26:22 +0000411 ima_reset_appraise_flags(d_backing_inode(dentry), 0);
Mimi Zohar42c63332011-03-10 18:54:15 -0500412 result = 0;
413 }
414 return result;
415}