kernel: selinux: rules: Remove unnecessary RCU dereference in get_policydb()
get_policydb() uses rcu_dereference() to read pointers to selinux_state.policy. But in the SELinux implementation, these pointers are assigned once during initialization and never changed with rcu_assign_pointer(), rendering the rcu_dereference() call in get_policydb() completely useless. This just adds unwanted overhead and implies concurrency pattern that is not even present in the kernel. Therefore, read the pointers directly since it's safe. * selinux_state.ss needs more context. Signed-off-by: Tashfin Shakeer Rhythm <tashfinshakeerrhythm@gmail.com>
This commit is contained in:
committed by
ShirkNeko
parent
ccee5e51c6
commit
8727664fa9
@@ -24,10 +24,10 @@ static struct policydb *get_policydb(void)
|
|||||||
// selinux_state does not exists before 4.19
|
// selinux_state does not exists before 4.19
|
||||||
#ifdef KSU_COMPAT_USE_SELINUX_STATE
|
#ifdef KSU_COMPAT_USE_SELINUX_STATE
|
||||||
#ifdef SELINUX_POLICY_INSTEAD_SELINUX_SS
|
#ifdef SELINUX_POLICY_INSTEAD_SELINUX_SS
|
||||||
struct selinux_policy *policy = rcu_dereference(selinux_state.policy);
|
struct selinux_policy *policy = selinux_state.policy;
|
||||||
db = &policy->policydb;
|
db = &policy->policydb;
|
||||||
#else
|
#else
|
||||||
struct selinux_ss *ss = rcu_dereference(selinux_state.ss);
|
struct selinux_ss *ss = selinux_state.ss;
|
||||||
db = &ss->policydb;
|
db = &ss->policydb;
|
||||||
#endif
|
#endif
|
||||||
#else
|
#else
|
||||||
|
|||||||
Reference in New Issue
Block a user