diff options
author | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2010-11-02 10:10:56 -0400 |
---|---|---|
committer | Mimi Zohar <zohar@linux.vnet.ibm.com> | 2011-02-10 07:51:43 -0500 |
commit | a68a27b6f2354273bacc39c3dd06456edb202230 (patch) | |
tree | d73396dab134842ecd1e86d665718e75012e7e78 /security | |
parent | 75a25637bf8a1b8fbed2368c0a3ec15c66a534f1 (diff) |
IMA: convert i_readcount to atomic
Convert the inode's i_readcount from an unsigned int to atomic.
Signed-off-by: Mimi Zohar <zohar@us.ibm.com>
Acked-by: Eric Paris <eparis@redhat.com>
Diffstat (limited to 'security')
-rw-r--r-- | security/integrity/ima/ima_iint.c | 7 | ||||
-rw-r--r-- | security/integrity/ima/ima_main.c | 11 |
2 files changed, 10 insertions, 8 deletions
diff --git a/security/integrity/ima/ima_iint.c b/security/integrity/ima/ima_iint.c index c442e47b6785..f0053552fd58 100644 --- a/security/integrity/ima/ima_iint.c +++ b/security/integrity/ima/ima_iint.c | |||
@@ -137,10 +137,11 @@ void ima_inode_free(struct inode *inode) | |||
137 | { | 137 | { |
138 | struct ima_iint_cache *iint; | 138 | struct ima_iint_cache *iint; |
139 | 139 | ||
140 | if (inode->i_readcount) | 140 | if (atomic_read(&inode->i_readcount)) |
141 | printk(KERN_INFO "%s: readcount: %u\n", __func__, inode->i_readcount); | 141 | printk(KERN_INFO "%s: readcount: %u\n", __func__, |
142 | atomic_read(&inode->i_readcount)); | ||
142 | 143 | ||
143 | inode->i_readcount = 0; | 144 | atomic_set(&inode->i_readcount, 0); |
144 | 145 | ||
145 | if (!IS_IMA(inode)) | 146 | if (!IS_IMA(inode)) |
146 | return; | 147 | return; |
diff --git a/security/integrity/ima/ima_main.c b/security/integrity/ima/ima_main.c index 203de979d305..6e8cb931b8f1 100644 --- a/security/integrity/ima/ima_main.c +++ b/security/integrity/ima/ima_main.c | |||
@@ -113,7 +113,7 @@ void ima_counts_get(struct file *file) | |||
113 | goto out; | 113 | goto out; |
114 | 114 | ||
115 | if (mode & FMODE_WRITE) { | 115 | if (mode & FMODE_WRITE) { |
116 | if (inode->i_readcount && IS_IMA(inode)) | 116 | if (atomic_read(&inode->i_readcount) && IS_IMA(inode)) |
117 | send_tomtou = true; | 117 | send_tomtou = true; |
118 | goto out; | 118 | goto out; |
119 | } | 119 | } |
@@ -127,7 +127,7 @@ void ima_counts_get(struct file *file) | |||
127 | out: | 127 | out: |
128 | /* remember the vfs deals with i_writecount */ | 128 | /* remember the vfs deals with i_writecount */ |
129 | if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) | 129 | if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) |
130 | inode->i_readcount++; | 130 | atomic_inc(&inode->i_readcount); |
131 | 131 | ||
132 | spin_unlock(&inode->i_lock); | 132 | spin_unlock(&inode->i_lock); |
133 | 133 | ||
@@ -149,15 +149,16 @@ static void ima_dec_counts(struct inode *inode, struct file *file) | |||
149 | assert_spin_locked(&inode->i_lock); | 149 | assert_spin_locked(&inode->i_lock); |
150 | 150 | ||
151 | if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { | 151 | if ((mode & (FMODE_READ | FMODE_WRITE)) == FMODE_READ) { |
152 | if (unlikely(inode->i_readcount == 0)) { | 152 | if (unlikely(atomic_read(&inode->i_readcount) == 0)) { |
153 | if (!ima_limit_imbalance(file)) { | 153 | if (!ima_limit_imbalance(file)) { |
154 | printk(KERN_INFO "%s: open/free imbalance (r:%u)\n", | 154 | printk(KERN_INFO "%s: open/free imbalance (r:%u)\n", |
155 | __func__, inode->i_readcount); | 155 | __func__, |
156 | atomic_read(&inode->i_readcount)); | ||
156 | dump_stack(); | 157 | dump_stack(); |
157 | } | 158 | } |
158 | return; | 159 | return; |
159 | } | 160 | } |
160 | inode->i_readcount--; | 161 | atomic_dec(&inode->i_readcount); |
161 | } | 162 | } |
162 | } | 163 | } |
163 | 164 | ||