Skip to content

Commit

Permalink
[PATCH] selinux: fix avc_alloc_node() oom with no policy loaded
Browse files Browse the repository at this point in the history
This patch should fix the avc_alloc_node() oom condition that Andrew
reported when no policy is loaded in SELinux.

Prior to this patch, when no policy was loaded, the SELinux "security
server" (policy engine) was only returning allowed decisions for the
requested permissions for each access check.  This caused the cache to
thrash when trying to use SELinux for real work with no policy loaded
(typically, the no policy loaded state is only for bootstrapping to the
point where we can load an initial policy).

This patch changes the SELinux security server to return the complete
allowed access vector at once, and then to reset the cache after the
initial policy load to flush the initial cache state created during
bootstrapping.

Signed-off-by: Stephen Smalley <[email protected]>
Signed-off-by: James Morris <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
Stephen Smalley authored and Linus Torvalds committed May 17, 2005
1 parent b810748 commit 4c443d1
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions security/selinux/ss/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -476,8 +476,8 @@ int security_compute_av(u32 ssid,
int rc = 0;

if (!ss_initialized) {
avd->allowed = requested;
avd->decided = requested;
avd->allowed = 0xffffffff;
avd->decided = 0xffffffff;
avd->auditallow = 0;
avd->auditdeny = 0xffffffff;
avd->seqno = latest_granting;
Expand Down Expand Up @@ -1196,9 +1196,11 @@ int security_load_policy(void *data, size_t len)
}
policydb_loaded_version = policydb.policyvers;
ss_initialized = 1;

seqno = ++latest_granting;
LOAD_UNLOCK;
selinux_complete_init();
avc_ss_reset(seqno);
selnl_notify_policyload(seqno);
return 0;
}

Expand Down

0 comments on commit 4c443d1

Please sign in to comment.