lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <b156861c-785e-c657-076d-d62a848d04db@huawei.com>
Date:   Mon, 21 Sep 2020 18:42:39 +0800
From:   Liu Shixin <liushixin2@...wei.com>
To:     Christian Brauner <christian.brauner@...ntu.com>
CC:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Arve Hjønnevåg <arve@...roid.com>,
        Todd Kjos <tkjos@...roid.com>,
        Martijn Coenen <maco@...roid.com>,
        Joel Fernandes <joel@...lfernandes.org>,
        Christian Brauner <christian@...uner.io>,
        "Hridya Valsaraju" <hridya@...gle.com>,
        Suren Baghdasaryan <surenb@...gle.com>,
        <devel@...verdev.osuosl.org>, <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH -next] binder: simplify the return expression of
 binder_mmap

On 2020/9/21 16:08, Christian Brauner wrote:

> On Mon, Sep 21, 2020 at 04:24:23PM +0800, Liu Shixin wrote:
>> Simplify the return expression.
>>
>> Signed-off-by: Liu Shixin <liushixin2@...wei.com>
>> ---
> Why not is all I can really say. :) But if this is about simplifying you
> could get rid of the "ret" and "failure string" variables, and the goto
> in that function completely by doing sm like this (__completely
> untested__):

Thanks for your advice. I will modify and test it.

Regards,
Liu Shixin

>
> diff --git a/drivers/android/binder.c b/drivers/android/binder.c
> index f936530a19b0..26f4dc81b008 100644
> --- a/drivers/android/binder.c
> +++ b/drivers/android/binder.c
> @@ -5182,9 +5182,7 @@ static const struct vm_operations_struct binder_vm_ops = {
>
>  static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
>  {
> -       int ret;
>         struct binder_proc *proc = filp->private_data;
> -       const char *failure_string;
>
>         if (proc->tsk != current->group_leader)
>                 return -EINVAL;
> @@ -5196,9 +5194,9 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
>                      (unsigned long)pgprot_val(vma->vm_page_prot));
>
>         if (vma->vm_flags & FORBIDDEN_MMAP_FLAGS) {
> -               ret = -EPERM;
> -               failure_string = "bad vm_flags";
> -               goto err_bad_arg;
> +               pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
> +                               proc->pid, vma->vm_start, vma->vm_end, "bad vm_flags", -EPERM);
> +               return -EPERM;
>         }
>         vma->vm_flags |= VM_DONTCOPY | VM_MIXEDMAP;
>         vma->vm_flags &= ~VM_MAYWRITE;
> @@ -5206,15 +5204,7 @@ static int binder_mmap(struct file *filp, struct vm_area_struct *vma)
>         vma->vm_ops = &binder_vm_ops;
>         vma->vm_private_data = proc;
>
> -       ret = binder_alloc_mmap_handler(&proc->alloc, vma);
> -       if (ret)
> -               return ret;
> -       return 0;
> -
> -err_bad_arg:
> -       pr_err("%s: %d %lx-%lx %s failed %d\n", __func__,
> -              proc->pid, vma->vm_start, vma->vm_end, failure_string, ret);
> -       return ret;
> +       return binder_alloc_mmap_handler(&proc->alloc, vma);
>  }
>
> Christian
> .
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ