aboutsummaryrefslogtreecommitdiffstats
path: root/security/integrity/ima/ima_main.c
diff options
context:
space:
mode:
authorEric Paris <eparis@redhat.com>2010-10-25 14:41:32 -0400
committerLinus Torvalds <torvalds@linux-foundation.org>2010-10-26 11:37:18 -0700
commit497f32337073a2da102c49a53779097b5394711b (patch)
tree203cbcd3f9462737d872e24fb2c847ce9a69de45 /security/integrity/ima/ima_main.c
parentb575156dafef208415ff0842c392733d16d4ccf1 (diff)
downloadmrst-s0i3-test-497f32337073a2da102c49a53779097b5394711b.tar.gz
mrst-s0i3-test-497f32337073a2da102c49a53779097b5394711b.tar.xz
mrst-s0i3-test-497f32337073a2da102c49a53779097b5394711b.zip
IMA: use unsigned int instead of long for counters
Currently IMA uses 2 longs in struct inode. To save space (and as it seems impossible to overflow 32 bits) we switch these to unsigned int. The switch to unsigned does require slightly different checks for underflow, but it isn't complex. 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_main.c')
-rw-r--r--security/integrity/ima/ima_main.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c
index 995bd1b98fa..5a1bf3df11f 100644
--- a/security/integrity/ima/ima_main.c
+++ b/security/integrity/ima/ima_main.c
@@ -178,11 +178,18 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
struct file *file)
{
mode_t mode = file->f_mode;
+ bool dump = false;
+
BUG_ON(!mutex_is_locked(&iint->mutex));
- if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
+ if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
+ if (unlikely(iint->readcount == 0))
+ dump = true;
iint->readcount--;
+ }
if (mode & FMODE_WRITE) {
+ if (unlikely(iint->writecount == 0))
+ dump = true;
iint->writecount--;
if (iint->writecount == 0) {
if (iint->version != inode->i_version)
@@ -190,10 +197,8 @@ static void ima_dec_counts(struct ima_iint_cache *iint, struct inode *inode,
}
}
- if (((iint->readcount < 0) ||
- (iint->writecount < 0)) &&
- !ima_limit_imbalance(file)) {
- printk(KERN_INFO "%s: open/free imbalance (r:%ld w:%ld)\n",
+ if (dump && !ima_limit_imbalance(file)) {
+ printk(KERN_INFO "%s: open/free imbalance (r:%u w:%u)\n",
__func__, iint->readcount, iint->writecount);
dump_stack();
}