Converting a valid context to string and hashing that is inefficient because the conversion is slow. Instead we can hash the stucture contents directly, which is about 10 times faster. After that, it is possible to move the hashing under sidtab.c, which avoids the complexity of calling context_add_hash() all over the place. Ondrej Mosnacek (2): selinux: hash context structure directly selinux: move context hashing under sidtab security/selinux/Makefile | 2 +- security/selinux/ss/context.c | 28 +++++++++++ security/selinux/ss/context.h | 11 +---- security/selinux/ss/ebitmap.c | 14 ++++++ security/selinux/ss/ebitmap.h | 1 + security/selinux/ss/policydb.c | 5 -- security/selinux/ss/services.c | 86 ++++++++++------------------------ security/selinux/ss/services.h | 3 -- security/selinux/ss/sidtab.c | 32 ++++++++----- security/selinux/ss/sidtab.h | 1 + 10 files changed, 92 insertions(+), 91 deletions(-) create mode 100644 security/selinux/ss/context.c -- 2.25.2