diff options
author | Ondrej Mosnacek <omosnace@redhat.com> | 2020-04-17 10:11:56 +0200 |
---|---|---|
committer | Paul Moore <paul@paul-moore.com> | 2020-04-17 22:04:34 +0200 |
commit | 50077289804c9bd4e6cfd5b3a10d4da0487f7e42 (patch) | |
tree | d0eec42d8fa215c2a80419f934159286d5d025d5 /security/selinux/ss/ebitmap.h | |
parent | selinux: store role transitions in a hash table (diff) | |
download | linux-50077289804c9bd4e6cfd5b3a10d4da0487f7e42.tar.xz linux-50077289804c9bd4e6cfd5b3a10d4da0487f7e42.zip |
selinux: hash context structure directly
Always hashing the string representation is inefficient. Just hash the
contents of the structure directly (using jhash). If the context is
invalid (str & len are set), then hash the string as before, otherwise
hash the structured data.
Since the context hashing function is now faster (about 10 times), this
patch decreases the overhead of security_transition_sid(), which is
called from many hooks.
The jhash function seemed as a good choice, since it is used as the
default hashing algorithm in rhashtable.
Signed-off-by: Ondrej Mosnacek <omosnace@redhat.com>
Reviewed-by: Jeff Vander Stoep <jeffv@google.com>
Tested-by: Jeff Vander Stoep <jeffv@google.com>
[PM: fixed some spelling errors in the comments pointed out by JVS]
Signed-off-by: Paul Moore <paul@paul-moore.com>
Diffstat (limited to 'security/selinux/ss/ebitmap.h')
-rw-r--r-- | security/selinux/ss/ebitmap.h | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/security/selinux/ss/ebitmap.h b/security/selinux/ss/ebitmap.h index 9a23b81b8832..9eb2d0af2805 100644 --- a/security/selinux/ss/ebitmap.h +++ b/security/selinux/ss/ebitmap.h @@ -131,6 +131,7 @@ int ebitmap_set_bit(struct ebitmap *e, unsigned long bit, int value); void ebitmap_destroy(struct ebitmap *e); int ebitmap_read(struct ebitmap *e, void *fp); int ebitmap_write(struct ebitmap *e, void *fp); +u32 ebitmap_hash(const struct ebitmap *e, u32 hash); #ifdef CONFIG_NETLABEL int ebitmap_netlbl_export(struct ebitmap *ebmap, |