Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 99208
b: refs/heads/master
c: 972ccac
h: refs/heads/master
v: v3
  • Loading branch information
James Morris committed Jul 14, 2008
1 parent f03ff6c commit be3e899
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 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: 0804d1133c02cbdfba0055de774f2c21a8b777dc
refs/heads/master: 972ccac2b237967ed7e56a50eb181b5a0a484b79
21 changes: 9 additions & 12 deletions trunk/security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,7 @@ int selinux_policycap_openperm;
extern const struct selinux_class_perm selinux_class_perm;

static DEFINE_RWLOCK(policy_rwlock);

static DEFINE_MUTEX(load_mutex);
#define LOAD_LOCK mutex_lock(&load_mutex)
#define LOAD_UNLOCK mutex_unlock(&load_mutex)

static struct sidtab sidtab;
struct policydb policydb;
Expand Down Expand Up @@ -1456,17 +1453,17 @@ int security_load_policy(void *data, size_t len)
int rc = 0;
struct policy_file file = { data, len }, *fp = &file;

LOAD_LOCK;
mutex_lock(&load_mutex);

if (!ss_initialized) {
avtab_cache_init();
if (policydb_read(&policydb, fp)) {
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
avtab_cache_destroy();
return -EINVAL;
}
if (policydb_load_isids(&policydb, &sidtab)) {
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
policydb_destroy(&policydb);
avtab_cache_destroy();
return -EINVAL;
Expand All @@ -1475,7 +1472,7 @@ int security_load_policy(void *data, size_t len)
if (validate_classes(&policydb)) {
printk(KERN_ERR
"SELinux: the definition of a class is incorrect\n");
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
sidtab_destroy(&sidtab);
policydb_destroy(&policydb);
avtab_cache_destroy();
Expand All @@ -1485,7 +1482,7 @@ int security_load_policy(void *data, size_t len)
policydb_loaded_version = policydb.policyvers;
ss_initialized = 1;
seqno = ++latest_granting;
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
selinux_complete_init();
avc_ss_reset(seqno);
selnl_notify_policyload(seqno);
Expand All @@ -1499,12 +1496,12 @@ int security_load_policy(void *data, size_t len)
#endif

if (policydb_read(&newpolicydb, fp)) {
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
return -EINVAL;
}

if (sidtab_init(&newsidtab)) {
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
policydb_destroy(&newpolicydb);
return -ENOMEM;
}
Expand Down Expand Up @@ -1552,7 +1549,7 @@ int security_load_policy(void *data, size_t len)
seqno = ++latest_granting;
policydb_loaded_version = policydb.policyvers;
write_unlock_irq(&policy_rwlock);
LOAD_UNLOCK;
mutex_unlock(&load_mutex);

/* Free the old policydb and SID table. */
policydb_destroy(&oldpolicydb);
Expand All @@ -1566,7 +1563,7 @@ int security_load_policy(void *data, size_t len)
return 0;

err:
LOAD_UNLOCK;
mutex_unlock(&load_mutex);
sidtab_destroy(&newsidtab);
policydb_destroy(&newpolicydb);
return rc;
Expand Down

0 comments on commit be3e899

Please sign in to comment.