Skip to content

Commit 274f62e

Browse files
stephensmalleypcmoore
authored andcommitted
selinux: fix handling of uninitialized selinux state in get_bools/classes
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 <[email protected]> Signed-off-by: Paul Moore <[email protected]>
1 parent d3cc2cd commit 274f62e

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

security/selinux/ss/services.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2811,6 +2811,13 @@ int security_get_bools(struct selinux_state *state,
28112811
struct policydb *policydb;
28122812
int i, rc;
28132813

2814+
if (!state->initialized) {
2815+
*len = 0;
2816+
*names = NULL;
2817+
*values = NULL;
2818+
return 0;
2819+
}
2820+
28142821
read_lock(&state->ss->policy_rwlock);
28152822

28162823
policydb = &state->ss->policydb;
@@ -3141,6 +3148,12 @@ int security_get_classes(struct selinux_state *state,
31413148
struct policydb *policydb = &state->ss->policydb;
31423149
int rc;
31433150

3151+
if (!state->initialized) {
3152+
*nclasses = 0;
3153+
*classes = NULL;
3154+
return 0;
3155+
}
3156+
31443157
read_lock(&state->ss->policy_rwlock);
31453158

31463159
rc = -ENOMEM;

0 commit comments

Comments
 (0)