Previous versions of this patchset: https://lore.kernel.org/selinux/20181127103605.32765-1-omosnace@xxxxxxxxxx/T/ https://lore.kernel.org/selinux/20181113135255.26045-1-omosnace@xxxxxxxxxx/T/ The patches that have "[squash]" in the subject are posted separately for ease of review but will be folded into the previous patch in the final posting. Likewise, patches with "[fixup]" at the beginning odf the subject are logically separarted fixes/tweaks for the last non-fixup commit preceding them. Changes in v3: (new changes are only in the "[fixup]" patches) - fixed handling of SECSID_NULL (it is now remapped to unlabeled as before) * verified using selinux-testsuite - cosmetic tweak: add sidtab_lookup_initial() helper to make sidtab_search_core() a bit more readable - fixed converting of unmapped contexts * verified using the reproducer from Stephen Smalley - cosmetic tweak: drop the 'out' goto label in convert_context() - fixed SIDTAB_LEAF_ENTRIES to use SIDTAB_NODE_ALLOC_SIZE instead of using PAGE_SIZE directly Changes in v2: - dropped the first patch since it is already merged in -next - fixed initial SID table to not reserve an entry for SECSID_NULL - added back an equivalent of the reverse lookup cache - fixed checkpatch.pl errors and some warnings Testing: An x86_64 Fedora 29 kernel with this patchset applied passes selinux-testsuite and the reproducer from GH issue #38 [1]. I also made sure that the two bugs discovered in previous version are now fixed. [1] https://github.com/SELinuxProject/selinux-kernel/issues/38 Ondrej Mosnacek (9): selinux: use separate table for initial SID lookup [squash] do not store entry for SECSID_NULL [fixup] fix handling of SECSID_NULL [fixup] cosmetic tweak for sidtab_search_core() selinux: overhaul sidtab to fix bug and improve performance [fixup] fix handling of invalid context in convert_context [fixup] remove the now unneeded 'out' label [fixup] fix SIDTAB_LEAF_ENTRIES to use the correct size macro [squash] add back reverse lookup cache to sidtab security/selinux/ss/mls.c | 23 +- security/selinux/ss/mls.h | 3 +- security/selinux/ss/policydb.c | 10 +- security/selinux/ss/services.c | 200 +++++------ security/selinux/ss/services.h | 2 +- security/selinux/ss/sidtab.c | 616 +++++++++++++++++++++------------ security/selinux/ss/sidtab.h | 95 +++-- 7 files changed, 574 insertions(+), 375 deletions(-) -- 2.19.2