Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 217413
b: refs/heads/master
c: 497f323
h: refs/heads/master
i:
  217411: 0f8401e
v: v3
  • Loading branch information
Eric Paris authored and Linus Torvalds committed Oct 26, 2010
1 parent b665070 commit d41bcc1
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: b575156dafef208415ff0842c392733d16d4ccf1
refs/heads/master: 497f32337073a2da102c49a53779097b5394711b
4 changes: 2 additions & 2 deletions trunk/security/integrity/ima/ima.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,8 +106,8 @@ struct ima_iint_cache {
unsigned long flags;
u8 digest[IMA_DIGEST_SIZE];
struct mutex mutex; /* protects: version, flags, digest */
long readcount; /* measured files readcount */
long writecount; /* measured files writecount */
unsigned int readcount; /* measured files readcount */
unsigned int writecount;/* measured files writecount */
struct kref refcount; /* ima_iint_cache reference count */
};

Expand Down
4 changes: 2 additions & 2 deletions trunk/security/integrity/ima/ima_iint.c
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,12 @@ void iint_free(struct kref *kref)
iint->version = 0;
iint->flags = 0UL;
if (iint->readcount != 0) {
printk(KERN_INFO "%s: readcount: %ld\n", __func__,
printk(KERN_INFO "%s: readcount: %u\n", __func__,
iint->readcount);
iint->readcount = 0;
}
if (iint->writecount != 0) {
printk(KERN_INFO "%s: writecount: %ld\n", __func__,
printk(KERN_INFO "%s: writecount: %u\n", __func__,
iint->writecount);
iint->writecount = 0;
}
Expand Down
15 changes: 10 additions & 5 deletions trunk/security/integrity/ima/ima_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -178,22 +178,27 @@ 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)
iint->flags &= ~IMA_MEASURED;
}
}

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();
}
Expand Down

0 comments on commit d41bcc1

Please sign in to comment.