selinux: clean up avc node cache when disabling selinux
PATCH 1/1 selinux: clean up avc node cache when disabling selinux
Added a call to free the avc_node_cache when inside selinux_disable because it should not waste resources allocated during avc_init if SELinux is disabled and the cache will never be used.
---
security/selinux/avc.c +6 -0
@@ -970,3 +970,9 @@ u32 avc_policy_seqno(void) {return avc_cache.latest_notif; } + +void avc_disable (void ) +{ +if (avc_node_cachep) +kmem_cache_destroy (avc_node_cachep); +}
security/selinux/hooks.c +3 -0
@@ -5678,6 +5678,9 @@ int selinux_disable(void) selinux_disabled =1 ; selinux_enabled =0 ; +/* Try to destroy the avc node cache */ +avc_node_cache_free (); +/* Reset security_ops to the secondary module, dummy or capability. */ security_ops = secondary_ops;
security/selinux/include/avc.h +3 -0
@@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *abint avc_get_hash_stats (char *page);extern unsigned int avc_cache_threshold; +/* Attempt to free avc node cache */ +void avc_disable (void ); +#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);#endif
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 23 lines · Thomas Liu
Added a call to free the
avc_node_cachewhen insideselinux_disablebecause it should not waste resources allocated duringavc_initif SELinux is disabled and the cache will never be used.Signed-off-by Thomas Liu <[email protected]>---
diff -uprN -X kernel-vanilla/Documentation/dontdiffkernel-vanilla/security/selinux/avc.ckernel/security/selinux/avc.csecurity/selinux/avc.c +6
-0@@ -970,3 +970,9 @@ u32 avc_policy_seqno(void) {return avc_cache.latest_notif; } + +void avc_disable (void ) +{ +if (avc_node_cachep) +kmem_cache_destroy (avc_node_cachep); +}diff -uprN -X kernel-vanilla/Documentation/dontdiff
kernel-vanilla/security/selinux/hooks.ckernel/security/selinux/hooks.c
security/selinux/hooks.c int selinux_disable(void) · line 5682
Quoted 5 lines
security/selinux/hooks.c +2
-0@@ -5678,6 +5678,9 @@ int selinux_disable(void) selinux_disabled =1 ; selinux_enabled =0 ; +/* Try to destroy the avc node cache */ +avc_node_cache_free ();
whoops! did you compile it?
Quoted 9 lines
security/selinux/hooks.c +1
-0+/* Reset security_ops to the secondary module, dummy or capability. */ security_ops = secondary_ops;diff -uprN -X kernel-vanilla/Documentation/dontdiff
kernel-vanilla/security/selinux/include/avc.hkernel/security/selinux/include/avc.h
security/selinux/include/avc.h void avc_dump_av(struct audit_buffer *ab · line 142
Quoted 9 lines
security/selinux/include/avc.h +3
-0@@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *abint avc_get_hash_stats (char *page);extern unsigned int avc_cache_threshold; +/* Attempt to free avc node cache */ +void avc_disable (void ); +#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);#endif
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
PATCH 1/1 selinux: clean up avc node cache when disabling selinux
In reply to Thomas LiuAdded a call to free the avc_node_cache when inside selinux_disable because it should not waste resources allocated during avc_init if SELinux is disabled and the cache will never be used.
---
security/selinux/avc.c +6 -0
@@ -970,3 +970,9 @@ u32 avc_policy_seqno(void) {return avc_cache.latest_notif; } + +void avc_disable (void ) +{ +if (avc_node_cachep) +kmem_cache_destroy (avc_node_cachep); +}
security/selinux/hooks.c +3 -0
@@ -5678,6 +5678,9 @@ int selinux_disable(void) selinux_disabled =1 ; selinux_enabled =0 ; +/* Try to destroy the avc node cache */ +avc_disable (); +/* Reset security_ops to the secondary module, dummy or capability. */ security_ops = secondary_ops;
security/selinux/include/avc.h +3 -0
@@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *abint avc_get_hash_stats (char *page);extern unsigned int avc_cache_threshold; +/* Attempt to free avc node cache */ +void avc_disable (void ); +#ifdef CONFIG_SECURITY_SELINUX_AVC_STATS DECLARE_PER_CPU(struct avc_cache_stats, avc_cache_stats);#endif
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Thomas Liu
Added a call to free the
avc_node_cachewhen insideselinux_disablebecause it should not waste resources allocated duringavc_initif SELinux is disabled and the cache will never be used.Signed-off-by Thomas Liu <[email protected]>
--
This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.
Quoted 5 lines · Thomas Liu
Added a call to free the
avc_node_cachewhen insideselinux_disablebecause it should not waste resources allocated duringavc_initif SELinux is disabled and the cache will never be used.Signed-off-by Thomas Liu <[email protected]>
Applied togit://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next
Signature · 7 lines
James Morris <[email protected]> -- This message was distributed to subscribers of the selinux mailing list. If you no longer wish to subscribe, send mail to [email protected] with the words "unsubscribe selinux" without quotes as the message.