Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 235088
b: refs/heads/master
c: a68a27b
h: refs/heads/master
v: v3
  • Loading branch information
Mimi Zohar committed Feb 10, 2011
1 parent 44d1d82 commit f7a7f09
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 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: 75a25637bf8a1b8fbed2368c0a3ec15c66a534f1
refs/heads/master: a68a27b6f2354273bacc39c3dd06456edb202230
3 changes: 1 addition & 2 deletions trunk/include/linux/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -794,8 +794,7 @@ struct inode {
#endif

#ifdef CONFIG_IMA
/* protected by i_lock */
unsigned int i_readcount; /* struct files open RO */
atomic_t i_readcount; /* struct files open RO */
#endif
atomic_t i_writecount;
#ifdef CONFIG_SECURITY
Expand Down
7 changes: 4 additions & 3 deletions trunk/security/integrity/ima/ima_iint.c
Original file line number Diff line number Diff line change
Expand Up @@ -137,10 +137,11 @@ void ima_inode_free(struct inode *inode)
{
struct ima_iint_cache *iint;

if (inode->i_readcount)
printk(KERN_INFO "%s: readcount: %u\n", __func__, inode->i_readcount);
if (atomic_read(&inode->i_readcount))
printk(KERN_INFO "%s: readcount: %u\n", __func__,
atomic_read(&inode->i_readcount));

inode->i_readcount = 0;
atomic_set(&inode->i_readcount, 0);

if (!IS_IMA(inode))
return;
Expand Down
11 changes: 6 additions & 5 deletions trunk/security/integrity/ima/ima_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ void ima_counts_get(struct file *file)
goto out;

if (mode & FMODE_WRITE) {
if (inode->i_readcount && IS_IMA(inode))
if (atomic_read(&inode->i_readcount) && IS_IMA(inode))
send_tomtou = true;
goto out;
}
Expand All @@ -127,7 +127,7 @@ void ima_counts_get(struct file *file)
out:
/* remember the vfs deals with i_writecount */
if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ)
inode->i_readcount++;
atomic_inc(&inode->i_readcount);

spin_unlock(&inode->i_lock);

Expand All @@ -149,15 +149,16 @@ static void ima_dec_counts(struct inode *inode, struct file *file)
assert_spin_locked(&inode->i_lock);

if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) {
if (unlikely(inode->i_readcount == 0)) {
if (unlikely(atomic_read(&inode->i_readcount) == 0)) {
if (!ima_limit_imbalance(file)) {
printk(KERN_INFO "%s: open/free imbalance (r:%u)\n",
__func__, inode->i_readcount);
__func__,
atomic_read(&inode->i_readcount));
dump_stack();
}
return;
}
inode->i_readcount--;
atomic_dec(&inode->i_readcount);
}
}

Expand Down

0 comments on commit f7a7f09

Please sign in to comment.