All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selinux: clean up avc node cache when disabling selinux
@ 2009-06-24 21:54 Thomas Liu
  2009-06-24 21:57 ` Eric Paris
  2009-06-24 21:58 ` [PATCH -v2] " Thomas Liu
  0 siblings, 2 replies; 5+ messages in thread
From: Thomas Liu @ 2009-06-24 21:54 UTC (permalink / raw)
  To: selinux; +Cc: sds, jmorris, eparis

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.

Signed-off-by: Thomas Liu <tliu@redhat.com>
---
diff -uprN -X kernel-vanilla/Documentation/dontdiff kernel-vanilla/security/selinux/avc.c kernel/security/selinux/avc.c
--- kernel-vanilla/security/selinux/avc.c	2009-06-24 15:51:29.227941185 -0400
+++ kernel/security/selinux/avc.c	2009-06-24 17:46:30.292941891 -0400
@@ -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.c kernel/security/selinux/hooks.c
--- kernel-vanilla/security/selinux/hooks.c	2009-06-24 15:51:29.229939614 -0400
+++ kernel/security/selinux/hooks.c	2009-06-24 16:13:14.828941026 -0400
@@ -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;
 
diff -uprN -X kernel-vanilla/Documentation/dontdiff kernel-vanilla/security/selinux/include/avc.h kernel/security/selinux/include/avc.h
--- kernel-vanilla/security/selinux/include/avc.h	2009-06-24 15:51:29.230938689 -0400
+++ kernel/security/selinux/include/avc.h	2009-06-24 17:46:42.540941620 -0400
@@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *ab
 int 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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] selinux: clean up avc node cache when disabling selinux
  2009-06-24 21:54 [PATCH] selinux: clean up avc node cache when disabling selinux Thomas Liu
@ 2009-06-24 21:57 ` Eric Paris
  2009-06-24 21:58 ` [PATCH -v2] " Thomas Liu
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Paris @ 2009-06-24 21:57 UTC (permalink / raw)
  To: Thomas Liu; +Cc: selinux, sds, jmorris, eparis

On Wed, 2009-06-24 at 17:54 -0400, Thomas Liu wrote:
> 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.
> 
> Signed-off-by: Thomas Liu <tliu@redhat.com>
> ---
> diff -uprN -X kernel-vanilla/Documentation/dontdiff kernel-vanilla/security/selinux/avc.c kernel/security/selinux/avc.c
> --- kernel-vanilla/security/selinux/avc.c	2009-06-24 15:51:29.227941185 -0400
> +++ kernel/security/selinux/avc.c	2009-06-24 17:46:30.292941891 -0400
> @@ -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.c kernel/security/selinux/hooks.c
> --- kernel-vanilla/security/selinux/hooks.c	2009-06-24 15:51:29.229939614 -0400
> +++ kernel/security/selinux/hooks.c	2009-06-24 16:13:14.828941026 -0400
> @@ -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?

> +
>  	/* 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.h kernel/security/selinux/include/avc.h
> --- kernel-vanilla/security/selinux/include/avc.h	2009-06-24 15:51:29.230938689 -0400
> +++ kernel/security/selinux/include/avc.h	2009-06-24 17:46:42.540941620 -0400
> @@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *ab
>  int 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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH -v2] selinux: clean up avc node cache when disabling selinux
  2009-06-24 21:54 [PATCH] selinux: clean up avc node cache when disabling selinux Thomas Liu
  2009-06-24 21:57 ` Eric Paris
@ 2009-06-24 21:58 ` Thomas Liu
  2009-06-24 22:08   ` Eric Paris
  2009-06-24 22:30   ` James Morris
  1 sibling, 2 replies; 5+ messages in thread
From: Thomas Liu @ 2009-06-24 21:58 UTC (permalink / raw)
  To: selinux; +Cc: sds, jmorris, eparis

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.

Signed-off-by: Thomas Liu <tliu@redhat.com>
---
diff -uprN -X kernel-vanilla/Documentation/dontdiff kernel-vanilla/security/selinux/avc.c kernel/security/selinux/avc.c
--- kernel-vanilla/security/selinux/avc.c	2009-06-24 15:51:29.227941185 -0400
+++ kernel/security/selinux/avc.c	2009-06-24 17:46:30.292941891 -0400
@@ -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.c kernel/security/selinux/hooks.c
--- kernel-vanilla/security/selinux/hooks.c	2009-06-24 15:51:29.229939614 -0400
+++ kernel/security/selinux/hooks.c	2009-06-24 16:13:14.828941026 -0400
@@ -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;
 
diff -uprN -X kernel-vanilla/Documentation/dontdiff kernel-vanilla/security/selinux/include/avc.h kernel/security/selinux/include/avc.h
--- kernel-vanilla/security/selinux/include/avc.h	2009-06-24 15:51:29.230938689 -0400
+++ kernel/security/selinux/include/avc.h	2009-06-24 17:46:42.540941620 -0400
@@ -134,6 +134,9 @@ void avc_dump_av(struct audit_buffer *ab
 int 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 majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -v2] selinux: clean up avc node cache when disabling selinux
  2009-06-24 21:58 ` [PATCH -v2] " Thomas Liu
@ 2009-06-24 22:08   ` Eric Paris
  2009-06-24 22:30   ` James Morris
  1 sibling, 0 replies; 5+ messages in thread
From: Eric Paris @ 2009-06-24 22:08 UTC (permalink / raw)
  To: Thomas Liu; +Cc: selinux, sds, jmorris, eparis

On Wed, 2009-06-24 at 17:58 -0400, Thomas Liu wrote:
> 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.
> 
> Signed-off-by: Thomas Liu <tliu@redhat.com>

Acked-by: Eric Paris <eparis@redhat.com>


--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH -v2] selinux: clean up avc node cache when disabling selinux
  2009-06-24 21:58 ` [PATCH -v2] " Thomas Liu
  2009-06-24 22:08   ` Eric Paris
@ 2009-06-24 22:30   ` James Morris
  1 sibling, 0 replies; 5+ messages in thread
From: James Morris @ 2009-06-24 22:30 UTC (permalink / raw)
  To: Thomas Liu; +Cc: selinux, sds, eparis

On Wed, 24 Jun 2009, Thomas Liu wrote:

> 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.
> 
> Signed-off-by: Thomas Liu <tliu@redhat.com>


Applied to
git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/security-testing-2.6#next


-- 
James Morris
<jmorris@namei.org>

--
This message was distributed to subscribers of the selinux mailing list.
If you no longer wish to subscribe, send mail to majordomo@tycho.nsa.gov with
the words "unsubscribe selinux" without quotes as the message.

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2009-06-24 22:30 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-06-24 21:54 [PATCH] selinux: clean up avc node cache when disabling selinux Thomas Liu
2009-06-24 21:57 ` Eric Paris
2009-06-24 21:58 ` [PATCH -v2] " Thomas Liu
2009-06-24 22:08   ` Eric Paris
2009-06-24 22:30   ` James Morris

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.