diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2020-02-26 16:54:52 +0100 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2020-02-27 19:23:20 -0500 |
commit | e0ac568de1fa0a38bea6d3c69a894d913a5ca59d (patch) | |
tree | b96a691c16032ea1f3c959034ef7fda70e59c3ef /security/selinux/ss/policydb.h | |
parent | e4cfa05e9bfe286457082477b32ecd17737bdbce (diff) | |
download | kernel_replicant_linux-e0ac568de1fa0a38bea6d3c69a894d913a5ca59d.tar.gz kernel_replicant_linux-e0ac568de1fa0a38bea6d3c69a894d913a5ca59d.tar.bz2 kernel_replicant_linux-e0ac568de1fa0a38bea6d3c69a894d913a5ca59d.zip |
selinux: reduce the use of hard-coded hash sizes
Instead allocate hash tables with just the right size based on the
actual number of elements (which is almost always known beforehand, we
just need to defer the hashtab allocation to the right time). The only
case when we don't know the size (with the current policy format) is the
new filename transitions hashtable. Here I just left the existing value.
After this patch, the time to load Fedora policy on x86_64 decreases
from 790 ms to 167 ms. If the unconfined module is removed, it decreases
from 750 ms to 122 ms. It is also likely that other operations are going
to be faster, mainly string_to_context_struct() or mls_compute_sid(),
but I didn't try to quantify that.
The memory usage of all hash table arrays increases from ~58 KB to
~163 KB (with Fedora policy on x86_64).
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Acked-by: Stephen Smalley <sds@tycho.nsa.gov>
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/ss/policydb.h')
-rw-r--r-- | security/selinux/ss/policydb.h | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/security/selinux/ss/policydb.h b/security/selinux/ss/policydb.h index 41ad78a1f17b..72e2932fb12d 100644 --- a/security/selinux/ss/policydb.h +++ b/security/selinux/ss/policydb.h @@ -321,8 +321,6 @@ extern int policydb_role_isvalid(struct policydb *p, unsigned int role); extern int policydb_read(struct policydb *p, void *fp); extern int policydb_write(struct policydb *p, void *fp); -#define PERM_SYMTAB_SIZE 32 - #define POLICYDB_CONFIG_MLS 1 /* the config flags related to unknown classes/perms are bits 2 and 3 */ |