ima: remove unnecessary i_mutex locking from ima_rdwr_violation_check()
authorDmitry Kasatkin <d.kasatkin@samsung.com>
Fri, 13 Jun 2014 15:55:47 +0000 (18:55 +0300)
committerMimi Zohar <zohar@linux.vnet.ibm.com>
Thu, 17 Jul 2014 13:35:09 +0000 (09:35 -0400)
Before 2.6.39 inode->i_readcount was maintained by IMA. It was not atomic
and protected using spinlock. For 2.6.39, i_readcount was converted to
atomic and maintaining was moved VFS layer. Spinlock for some unclear
reason was replaced by i_mutex.

After analyzing the code, we came to conclusion that i_mutex locking is
unnecessary, especially when an IMA policy has not been defined.

This patch removes i_mutex locking from ima_rdwr_violation_check().

Signed-off-by: Dmitry Kasatkin <d.kasatkin@samsung.com>
Signed-off-by: Mimi Zohar <zohar@linux.vnet.ibm.com>
security/integrity/ima/ima_main.c

index 09baa335ebc79ed9c7054272dc38534e02c85175..cf1c3696c72e056733a7c559d13544449a40fb24 100644 (file)
@@ -88,8 +88,6 @@ static void ima_rdwr_violation_check(struct file *file)
        if (!S_ISREG(inode->i_mode) || !ima_initialized)
                return;
 
-       mutex_lock(&inode->i_mutex);    /* file metadata: permissions, xattr */
-
        if (mode & FMODE_WRITE) {
                if (atomic_read(&inode->i_readcount) && IS_IMA(inode)) {
                        struct integrity_iint_cache *iint;
@@ -104,8 +102,6 @@ static void ima_rdwr_violation_check(struct file *file)
                        send_writers = true;
        }
 
-       mutex_unlock(&inode->i_mutex);
-
        if (!send_tomtou && !send_writers)
                return;