selinux: check level category sets once at load time
authorStephen Smalley <stephen.smalley.work@gmail.com>
Tue, 4 Aug 2026 13:57:00 +0000 (09:57 -0400)
committerPaul Moore <paul@paul-moore.com>
Tue, 4 Aug 2026 14:57:46 +0000 (10:57 -0400)
commit9c1cc4a7f79275ef93746f6247685763b475bfb0
treefe4eb0a5ffc8080646846beda39332c6f0591f86
parenta93d37a09b863810653f93d371fb197457d59deb
selinux: check level category sets once at load time

As reported by Jiri Vozar, commit 7edea6e8c8e8 ("selinux: beef up
isvalid checks") introduces a new loop in mls_level_isvalid() that
causes ~89-94% throughput regression in System V IPC message queue
operations (msgsnd/msgrcv).

Move the expensive part of the ebitmap checking to policy load time
instead as the reporter suggested.

Link: https://lore.kernel.org/selinux/CAMgFczCi2Z011dNf84Amc0Q-qnTt0+VUjWY+Y7zPyXdaH35Jvw@mail.gmail.com/
Fixes: 7edea6e8c8e8 ("selinux: beef up isvalid checks")
Reported-by: Jiri Vozar <jvozar@redhat.com>
Suggested-by: Jiri Vozar <jvozar@redhat.com>
Signed-off-by: Stephen Smalley <stephen.smalley.work@gmail.com>
Signed-off-by: Paul Moore <paul@paul-moore.com>
security/selinux/ss/mls.c
security/selinux/ss/policydb.c