2009-10-18 11:40:34

by Anton Blanchard

[permalink] [raw]
Subject: [PATCH] exec: setup_arg_pages fails to return errors


In setup_arg_pages we work hard to assign a value to ret, but on exit
we always return 0.

Also remove a now duplicated exit path and branch to out_unlock instead.

Signed-off-by: Anton Blanchard <[email protected]>
---

Index: linux.trees.git/fs/exec.c
===================================================================
--- linux.trees.git.orig/fs/exec.c 2009-09-28 12:17:10.000000000 +1000
+++ linux.trees.git/fs/exec.c 2009-09-28 12:17:58.000000000 +1000
@@ -624,10 +624,8 @@ int setup_arg_pages(struct linux_binprm
/* Move stack pages down in memory. */
if (stack_shift) {
ret = shift_arg_pages(vma, stack_shift);
- if (ret) {
- up_write(&mm->mmap_sem);
- return ret;
- }
+ if (ret)
+ goto out_unlock;
}

#ifdef CONFIG_STACK_GROWSUP
@@ -641,7 +639,7 @@ int setup_arg_pages(struct linux_binprm

out_unlock:
up_write(&mm->mmap_sem);
- return 0;
+ return ret;
}
EXPORT_SYMBOL(setup_arg_pages);


2009-10-21 04:09:23

by Serge E. Hallyn

[permalink] [raw]
Subject: Re: [PATCH] exec: setup_arg_pages fails to return errors

Quoting Anton Blanchard ([email protected]):
>
> In setup_arg_pages we work hard to assign a value to ret, but on exit
> we always return 0.
>
> Also remove a now duplicated exit path and branch to out_unlock instead.
>
> Signed-off-by: Anton Blanchard <[email protected]>

Yikes!

Acked-by: Serge Hallyn <[email protected]>

> ---
>
> Index: linux.trees.git/fs/exec.c
> ===================================================================
> --- linux.trees.git.orig/fs/exec.c 2009-09-28 12:17:10.000000000 +1000
> +++ linux.trees.git/fs/exec.c 2009-09-28 12:17:58.000000000 +1000
> @@ -624,10 +624,8 @@ int setup_arg_pages(struct linux_binprm
> /* Move stack pages down in memory. */
> if (stack_shift) {
> ret = shift_arg_pages(vma, stack_shift);
> - if (ret) {
> - up_write(&mm->mmap_sem);
> - return ret;
> - }
> + if (ret)
> + goto out_unlock;
> }
>
> #ifdef CONFIG_STACK_GROWSUP
> @@ -641,7 +639,7 @@ int setup_arg_pages(struct linux_binprm
>
> out_unlock:
> up_write(&mm->mmap_sem);
> - return 0;
> + return ret;
> }
> EXPORT_SYMBOL(setup_arg_pages);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/

2009-10-21 05:18:46

by Cong Wang

[permalink] [raw]
Subject: Re: [PATCH] exec: setup_arg_pages fails to return errors

On Sun, Oct 18, 2009 at 7:39 PM, Anton Blanchard <[email protected]> wrote:
>
> In setup_arg_pages we work hard to assign a value to ret, but on exit
> we always return 0.
>
> Also remove a now duplicated exit path and branch to out_unlock instead.
>
> Signed-off-by: Anton Blanchard <[email protected]>
> ---


Reviewed-by: WANG Cong <[email protected]>

>
> Index: linux.trees.git/fs/exec.c
> ===================================================================
> --- linux.trees.git.orig/fs/exec.c      2009-09-28 12:17:10.000000000 +1000
> +++ linux.trees.git/fs/exec.c   2009-09-28 12:17:58.000000000 +1000
> @@ -624,10 +624,8 @@ int setup_arg_pages(struct linux_binprm
>        /* Move stack pages down in memory. */
>        if (stack_shift) {
>                ret = shift_arg_pages(vma, stack_shift);
> -               if (ret) {
> -                       up_write(&mm->mmap_sem);
> -                       return ret;
> -               }
> +               if (ret)
> +                       goto out_unlock;
>        }
>
>  #ifdef CONFIG_STACK_GROWSUP
> @@ -641,7 +639,7 @@ int setup_arg_pages(struct linux_binprm
>
>  out_unlock:
>        up_write(&mm->mmap_sem);
> -       return 0;
> +       return ret;
>  }
>  EXPORT_SYMBOL(setup_arg_pages);
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at  http://www.tux.org/lkml/
>