Skip to content

Commit

Permalink
SELinux: fix locking issue introduced with c6d3aaa
Browse files Browse the repository at this point in the history
Ensure that we release the policy read lock on all exit paths from
security_compute_av.

Signed-off-by:  Stephen D. Smalley <sds@tycho.nsa.gov>
Signed-off-by: James Morris <jmorris@namei.org>
  • Loading branch information
Stephen Smalley authored and James Morris committed Oct 20, 2009
1 parent 825332e commit b7f3008
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -935,19 +935,22 @@ int security_compute_av(u32 ssid,
u32 requested;
int rc;

read_lock(&policy_rwlock);

if (!ss_initialized)
goto allow;

read_lock(&policy_rwlock);
requested = unmap_perm(orig_tclass, orig_requested);
tclass = unmap_class(orig_tclass);
if (unlikely(orig_tclass && !tclass)) {
if (policydb.allow_unknown)
goto allow;
return -EINVAL;
rc = -EINVAL;
goto out;
}
rc = security_compute_av_core(ssid, tsid, tclass, requested, avd);
map_decision(orig_tclass, avd, policydb.allow_unknown);
out:
read_unlock(&policy_rwlock);
return rc;
allow:
Expand All @@ -956,7 +959,8 @@ int security_compute_av(u32 ssid,
avd->auditdeny = 0xffffffff;
avd->seqno = latest_granting;
avd->flags = 0;
return 0;
rc = 0;
goto out;
}

int security_compute_av_user(u32 ssid,
Expand Down

0 comments on commit b7f3008

Please sign in to comment.