diff options
-rw-r--r-- | security/integrity/ima/ima.h | 1 | ||||
-rw-r--r-- | security/integrity/ima/ima_iint.c | 6 | ||||
-rw-r--r-- | security/integrity/ima/ima_main.c | 16 |
3 files changed, 6 insertions, 17 deletions
diff --git a/security/integrity/ima/ima.h b/security/integrity/ima/ima.h index 80aca3d2cb7..b546b90f5fa 100644 --- a/security/integrity/ima/ima.h +++ b/security/integrity/ima/ima.h @@ -108,7 +108,6 @@ struct ima_iint_cache { struct mutex mutex; /* protects: version, flags, digest */ /* protected by inode->i_lock */ unsigned int readcount; /* measured files readcount */ - unsigned int writecount;/* measured files writecount */ struct kref refcount; /* ima_iint_cache reference count */ }; diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c index db71a13f27f..e68891f8d55 100644 --- a/security/integrity/ima/ima_iint.c +++ b/security/integrity/ima/ima_iint.c @@ -129,11 +129,6 @@ void iint_free(struct kref *kref) iint->readcount); iint->readcount = 0; } - if (iint->writecount != 0) { - printk(KERN_INFO "%s: writecount: %u\n", __func__, - iint->writecount); - iint->writecount = 0; - } kref_init(&iint->refcount); kmem_cache_free(iint_cache, iint); } @@ -166,7 +161,6 @@ static void init_once(void *foo) iint->flags = 0UL; mutex_init(&iint->mutex); iint->readcount = 0; - iint->writecount = 0; kref_init(&iint->refcount); } diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 2f9b5d50424..24660bf3f82 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c @@ -94,8 +94,6 @@ static void ima_inc_counts(struct ima_iint_cache *iint, fmode_t mode) if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) iint->readcount++; - if (mode & FMODE_WRITE) - iint->writecount++; } /* @@ -173,18 +171,16 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode, iint->readcount--; } if (mode & FMODE_WRITE) { - if (unlikely(iint->writecount == 0)) + if (atomic_read(&inode->i_writecount) <= 0) dump = true; - iint->writecount--; - if (iint->writecount == 0) { - if (iint->version != inode->i_version) - iint->flags &= ~IMA_MEASURED; - } + if (atomic_read(&inode->i_writecount) == 1 && + iint->version != inode->i_version) + iint->flags &= ~IMA_MEASURED; } if (dump && !ima_limit_imbalance(file)) { - printk(KERN_INFO "%s: open/free imbalance (r:%u w:%u)\n", - __func__, iint->readcount, iint->writecount); + printk(KERN_INFO "%s: open/free imbalance (r:%u)\n", + __func__, iint->readcount); dump_stack(); } } |