diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2009-06-26 14:05:27 -0400 |
---|---|---|
committer | James Morris <jmorris@namei.org> | 2009-06-28 18:59:10 -0400 |
commit | 94e5d714f604d4cb4cb13163f01ede278e69258b (patch) | |
tree | 1f7f50f5eddf74e6930eaf0384538549f263b8fe /security | |
parent | 79b854c549c62c54fa27f87e04465c01db889f8d (diff) |
integrity: add ima_counts_put (updated)
This patch fixes an imbalance message as reported by J.R. Okajima.
The IMA file counters are incremented in ima_path_check. If the
actual open fails, such as ETXTBSY, decrement the counters to
prevent unnecessary imbalance messages.
Reported-by: J.R. Okajima <hooanon05@yahoo.co.jp>
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Signed-off-by: James Morris <jmorris@namei.org>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/ima/ima_main.c | 29 |
1 files changed, 28 insertions, 1 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 6f611874d10e..101c512564ec 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c | |||
@@ -238,7 +238,34 @@ out: | |||
238 | } | 238 | } |
239 | 239 | ||
240 | /* | 240 | /* |
241 | * ima_opens_get - increment file counts | 241 | * ima_counts_put - decrement file counts |
242 | * | ||
243 | * File counts are incremented in ima_path_check. On file open | ||
244 | * error, such as ETXTBSY, decrement the counts to prevent | ||
245 | * unnecessary imbalance messages. | ||
246 | */ | ||
247 | void ima_counts_put(struct path *path, int mask) | ||
248 | { | ||
249 | struct inode *inode = path->dentry->d_inode; | ||
250 | struct ima_iint_cache *iint; | ||
251 | |||
252 | if (!ima_initialized || !S_ISREG(inode->i_mode)) | ||
253 | return; | ||
254 | iint = ima_iint_find_insert_get(inode); | ||
255 | if (!iint) | ||
256 | return; | ||
257 | |||
258 | mutex_lock(&iint->mutex); | ||
259 | iint->opencount--; | ||
260 | if ((mask & MAY_WRITE) || (mask == 0)) | ||
261 | iint->writecount--; | ||
262 | else if (mask & (MAY_READ | MAY_EXEC)) | ||
263 | iint->readcount--; | ||
264 | mutex_unlock(&iint->mutex); | ||
265 | } | ||
266 | |||
267 | /* | ||
268 | * ima_counts_get - increment file counts | ||
242 | * | 269 | * |
243 | * - for IPC shm and shmat file. | 270 | * - for IPC shm and shmat file. |
244 | * - for nfsd exported files. | 271 | * - for nfsd exported files. |