BACKPORT: FROMGIT: [PATCH] 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 <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Signed-off-by: Jebaitedneko <Jebaitedneko@gmail.com>
This commit is contained in:
Stephen Smalley
2021-06-29 15:35:09 +05:30
committed by kondors1995
parent 8db1158cdf
commit ed436f45ae

View File

@@ -2831,6 +2831,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;
@@ -3164,6 +3171,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;