All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selinux: apply execstack check on thread stacks
@ 2016-04-08 17:55 Stephen Smalley
  2016-04-26 19:51 ` Paul Moore
  0 siblings, 1 reply; 2+ messages in thread
From: Stephen Smalley @ 2016-04-08 17:55 UTC (permalink / raw)
  To: selinux; +Cc: paul, nnk, Stephen Smalley

The execstack check was only being applied on the main
process stack.  Thread stacks allocated via mmap were
only subject to the execmem permission check.  Augment
the check to apply to the current thread stack as well.
Note that this does NOT prevent making a different thread's
stack executable.

Suggested-by: Nick Kralevich <nnk@google.com>
Acked-by: Nick Kralevich <nnk@google.com>
Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
---
 security/selinux/hooks.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
index fce7dc8..d495dac 100644
--- a/security/selinux/hooks.c
+++ b/security/selinux/hooks.c
@@ -3465,8 +3465,9 @@ static int selinux_file_mprotect(struct vm_area_struct *vma,
 		    vma->vm_end <= vma->vm_mm->brk) {
 			rc = cred_has_perm(cred, cred, PROCESS__EXECHEAP);
 		} else if (!vma->vm_file &&
-			   vma->vm_start <= vma->vm_mm->start_stack &&
-			   vma->vm_end >= vma->vm_mm->start_stack) {
+			   ((vma->vm_start <= vma->vm_mm->start_stack &&
+			     vma->vm_end >= vma->vm_mm->start_stack) ||
+			    vma_is_stack_for_task(vma, current))) {
 			rc = current_has_perm(current, PROCESS__EXECSTACK);
 		} else if (vma->vm_file && vma->anon_vma) {
 			/*
-- 
2.5.5

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

* Re: [PATCH] selinux: apply execstack check on thread stacks
  2016-04-08 17:55 [PATCH] selinux: apply execstack check on thread stacks Stephen Smalley
@ 2016-04-26 19:51 ` Paul Moore
  0 siblings, 0 replies; 2+ messages in thread
From: Paul Moore @ 2016-04-26 19:51 UTC (permalink / raw)
  To: Stephen Smalley; +Cc: selinux, nnk

On Friday, April 08, 2016 01:55:03 PM Stephen Smalley wrote:
> The execstack check was only being applied on the main
> process stack.  Thread stacks allocated via mmap were
> only subject to the execmem permission check.  Augment
> the check to apply to the current thread stack as well.
> Note that this does NOT prevent making a different thread's
> stack executable.
> 
> Suggested-by: Nick Kralevich <nnk@google.com>
> Acked-by: Nick Kralevich <nnk@google.com>
> Signed-off-by: Stephen Smalley <sds@tycho.nsa.gov>
> ---
>  security/selinux/hooks.c | 5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)

Applied, thanks.

> diff --git a/security/selinux/hooks.c b/security/selinux/hooks.c
> index fce7dc8..d495dac 100644
> --- a/security/selinux/hooks.c
> +++ b/security/selinux/hooks.c
> @@ -3465,8 +3465,9 @@ static int selinux_file_mprotect(struct vm_area_struct
> *vma, vma->vm_end <= vma->vm_mm->brk) {
>  			rc = cred_has_perm(cred, cred, PROCESS__EXECHEAP);
>  		} else if (!vma->vm_file &&
> -			   vma->vm_start <= vma->vm_mm->start_stack &&
> -			   vma->vm_end >= vma->vm_mm->start_stack) {
> +			   ((vma->vm_start <= vma->vm_mm->start_stack &&
> +			     vma->vm_end >= vma->vm_mm->start_stack) ||
> +			    vma_is_stack_for_task(vma, current))) {
>  			rc = current_has_perm(current, PROCESS__EXECSTACK);
>  		} else if (vma->vm_file && vma->anon_vma) {
>  			/*

-- 
paul moore
www.paul-moore.com

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

end of thread, other threads:[~2016-04-26 19:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-04-08 17:55 [PATCH] selinux: apply execstack check on thread stacks Stephen Smalley
2016-04-26 19:51 ` Paul Moore

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.