aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima_iint.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2010-10-25 14:41:59 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 14:37:18 -0400
commita178d2027d3198b0a04517d764326ab71cd73da2 (patch)
treed81b9336328ba1741231b318a6f8187f627581fd /security/integrity/ima/ima_iint.c
parentb9593d309d17c57e9ddc3934d641902533896ca9 (diff)
IMA: move read counter into struct inode
IMA currently allocated an inode integrity structure for every inode in core. This stucture is about 120 bytes long. Most files however (especially on a system which doesn't make use of IMA) will never need any of this space. The problem is that if IMA is enabled we need to know information about the number of readers and the number of writers for every inode on the box. At the moment we collect that information in the per inode iint structure and waste the rest of the space. This patch moves those counters into the struct inode so we can eventually stop allocating an IMA integrity structure except when absolutely needed. This patch does the minimum needed to move the location of the data. Further cleanups, especially the location of counter updates, may still be possible. 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>
Diffstat (limited to 'security/integrity/ima/ima_iint.c')
-rw-r--r--security/integrity/ima/ima_iint.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c
index e68891f8d55a..0936a7197e47 100644
--- a/security/integrity/ima/ima_iint.c
+++ b/security/integrity/ima/ima_iint.c
@@ -124,11 +124,6 @@ void iint_free(struct kref *kref)
124 refcount); 124 refcount);
125 iint->version = 0; 125 iint->version = 0;
126 iint->flags = 0UL; 126 iint->flags = 0UL;
127 if (iint->readcount != 0) {
128 printk(KERN_INFO "%s: readcount: %u\n", __func__,
129 iint->readcount);
130 iint->readcount = 0;
131 }
132 kref_init(&iint->refcount); 127 kref_init(&iint->refcount);
133 kmem_cache_free(iint_cache, iint); 128 kmem_cache_free(iint_cache, iint);
134} 129}
@@ -143,6 +138,11 @@ void ima_inode_free(struct inode *inode)
143{ 138{
144 struct ima_iint_cache *iint; 139 struct ima_iint_cache *iint;
145 140
141 if (inode->i_readcount)
142 printk(KERN_INFO "%s: readcount: %u\n", __func__, inode->i_readcount);
143
144 inode->i_readcount = 0;
145
146 spin_lock(&ima_iint_lock); 146 spin_lock(&ima_iint_lock);
147 iint = __ima_iint_find(inode); 147 iint = __ima_iint_find(inode);
148 if (iint) 148 if (iint)
@@ -160,7 +160,6 @@ static void init_once(void *foo)
160 iint->version = 0; 160 iint->version = 0;
161 iint->flags = 0UL; 161 iint->flags = 0UL;
162 mutex_init(&iint->mutex); 162 mutex_init(&iint->mutex);
163 iint->readcount = 0;
164 kref_init(&iint->refcount); 163 kref_init(&iint->refcount);
165} 164}
166 165