Skip to content

Commit

Permalink
selinux: fix handling of uninitialized selinux state in get_bools/cla…
Browse files Browse the repository at this point in the history
…sses

If security_get_bools/classes are called before the selinux state is
initialized (i.e. before first policy load), then they should just
return immediately with no booleans/classes.

Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
  • Loading branch information
Stephen Smalley authored and Paul Moore committed Mar 20, 2018
1 parent d3cc2cd commit 274f62e
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -2811,6 +2811,13 @@ int security_get_bools(struct selinux_state *state,
struct policydb *policydb;
int i, rc;

if (!state->initialized) {
*len = 0;
*names = NULL;
*values = NULL;
return 0;
}

read_lock(&state->ss->policy_rwlock);

policydb = &state->ss->policydb;
Expand Down Expand Up @@ -3141,6 +3148,12 @@ int security_get_classes(struct selinux_state *state,
struct policydb *policydb = &state->ss->policydb;
int rc;

if (!state->initialized) {
*nclasses = 0;
*classes = NULL;
return 0;
}

read_lock(&state->ss->policy_rwlock);

rc = -ENOMEM;
Expand Down

0 comments on commit 274f62e

Please sign in to comment.