aboutsummaryrefslogtreecommitdiffstats
path: root/security/selinux
diff options
context:
space:
mode:
Diffstat (limited to 'security/selinux')
-rw-r--r--security/selinux/ss/sidtab.c18
1 files changed, 7 insertions, 11 deletions
diff --git a/security/selinux/ss/sidtab.c b/security/selinux/ss/sidtab.c
index ba3541640491..a81ded104129 100644
--- a/security/selinux/ss/sidtab.c
+++ b/security/selinux/ss/sidtab.c
@@ -14,10 +14,6 @@
14#define SIDTAB_HASH(sid) \ 14#define SIDTAB_HASH(sid) \
15(sid & SIDTAB_HASH_MASK) 15(sid & SIDTAB_HASH_MASK)
16 16
17#define INIT_SIDTAB_LOCK(s) spin_lock_init(&s->lock)
18#define SIDTAB_LOCK(s, x) spin_lock_irqsave(&s->lock, x)
19#define SIDTAB_UNLOCK(s, x) spin_unlock_irqrestore(&s->lock, x)
20
21int sidtab_init(struct sidtab *s) 17int sidtab_init(struct sidtab *s)
22{ 18{
23 int i; 19 int i;
@@ -30,7 +26,7 @@ int sidtab_init(struct sidtab *s)
30 s->nel = 0; 26 s->nel = 0;
31 s->next_sid = 1; 27 s->next_sid = 1;
32 s->shutdown = 0; 28 s->shutdown = 0;
33 INIT_SIDTAB_LOCK(s); 29 spin_lock_init(&s->lock);
34 return 0; 30 return 0;
35} 31}
36 32
@@ -180,7 +176,7 @@ int sidtab_context_to_sid(struct sidtab *s,
180 176
181 sid = sidtab_search_context(s, context); 177 sid = sidtab_search_context(s, context);
182 if (!sid) { 178 if (!sid) {
183 SIDTAB_LOCK(s, flags); 179 spin_lock_irqsave(&s->lock, flags);
184 /* Rescan now that we hold the lock. */ 180 /* Rescan now that we hold the lock. */
185 sid = sidtab_search_context(s, context); 181 sid = sidtab_search_context(s, context);
186 if (sid) 182 if (sid)
@@ -199,7 +195,7 @@ int sidtab_context_to_sid(struct sidtab *s,
199 if (ret) 195 if (ret)
200 s->next_sid--; 196 s->next_sid--;
201unlock_out: 197unlock_out:
202 SIDTAB_UNLOCK(s, flags); 198 spin_unlock_irqrestore(&s->lock, flags);
203 } 199 }
204 200
205 if (ret) 201 if (ret)
@@ -264,19 +260,19 @@ void sidtab_set(struct sidtab *dst, struct sidtab *src)
264{ 260{
265 unsigned long flags; 261 unsigned long flags;
266 262
267 SIDTAB_LOCK(src, flags); 263 spin_lock_irqsave(&src->lock, flags);
268 dst->htable = src->htable; 264 dst->htable = src->htable;
269 dst->nel = src->nel; 265 dst->nel = src->nel;
270 dst->next_sid = src->next_sid; 266 dst->next_sid = src->next_sid;
271 dst->shutdown = 0; 267 dst->shutdown = 0;
272 SIDTAB_UNLOCK(src, flags); 268 spin_unlock_irqrestore(&src->lock, flags);
273} 269}
274 270
275void sidtab_shutdown(struct sidtab *s) 271void sidtab_shutdown(struct sidtab *s)
276{ 272{
277 unsigned long flags; 273 unsigned long flags;
278 274
279 SIDTAB_LOCK(s, flags); 275 spin_lock_irqsave(&s->lock, flags);
280 s->shutdown = 1; 276 s->shutdown = 1;
281 SIDTAB_UNLOCK(s, flags); 277 spin_unlock_irqrestore(&s->lock, flags);
282} 278}