IMA: drop the inode opencount since it isn't needed for operation
authorEric Paris <eparis@redhat.com>
Mon, 25 Oct 2010 18:41:26 +0000 (14:41 -0400)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 26 Oct 2010 18:37:17 +0000 (11:37 -0700)
The opencount was used to help debugging to make sure that everything
which created a struct file also correctly made the IMA calls.  Since we
moved all of that into the VFS this isn't as necessary.  We should be
able to get the same amount of debugging out of just the reader and
write count.

Signed-off-by: Eric Paris <eparis@redhat.com>
Acked-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
security/integrity/ima/ima.h
security/integrity/ima/ima_iint.c
security/integrity/ima/ima_main.c

index 7557791e954d53d1f176a0e518d7b8db1b7ddd7f..3d701084eac6990b597588eaf69e3bf3cabbb93c 100644 (file)
@@ -108,7 +108,6 @@ struct ima_iint_cache {
        struct mutex mutex;     /* protects: version, flags, digest */
        long readcount;         /* measured files readcount */
        long writecount;        /* measured files writecount */
-       long opencount;         /* opens reference count */
        struct kref refcount;   /* ima_iint_cache reference count */
 };
 
index 8395f0f5e9b918925839ff4293361b3e363793e8..8e64313ed182c18898305225bad72c3b1c55eaa5 100644 (file)
@@ -134,11 +134,6 @@ void iint_free(struct kref *kref)
                       iint->writecount);
                iint->writecount = 0;
        }
-       if (iint->opencount != 0) {
-               printk(KERN_INFO "%s: opencount: %ld\n", __func__,
-                      iint->opencount);
-               iint->opencount = 0;
-       }
        kref_init(&iint->refcount);
        kmem_cache_free(iint_cache, iint);
 }
@@ -172,7 +167,6 @@ static void init_once(void *foo)
        mutex_init(&iint->mutex);
        iint->readcount = 0;
        iint->writecount = 0;
-       iint->opencount = 0;
        kref_init(&iint->refcount);
 }
 
index e662b89d407944103dc121b9ccb37f7e68ac62e1..995bd1b98fa8cc0d3cad7839f51b51c369a7f9b4 100644 (file)
@@ -122,7 +122,6 @@ static void ima_inc_counts(struct ima_iint_cache *iint, fmode_t mode)
 {
        BUG_ON(!mutex_is_locked(&iint->mutex));
 
-       iint->opencount++;
        if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
                iint->readcount++;
        if (mode & FMODE_WRITE)
@@ -181,7 +180,6 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
        mode_t mode = file->f_mode;
        BUG_ON(!mutex_is_locked(&iint->mutex));
 
-       iint->opencount--;
        if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
                iint->readcount--;
        if (mode & FMODE_WRITE) {
@@ -192,13 +190,11 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
                }
        }
 
-       if (((iint->opencount < 0) ||
-            (iint->readcount < 0) ||
+       if (((iint->readcount < 0) ||
             (iint->writecount < 0)) &&
            !ima_limit_imbalance(file)) {
-               printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld o:%ld)\n",
-                      __func__, iint->readcount, iint->writecount,
-                      iint->opencount);
+               printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld)\n",
+                      __func__, iint->readcount, iint->writecount);
                dump_stack();
        }
 }