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: <CAKH8qBsoc8Upz=NvOtD=SOfVPcEnW-2wghbM1zYBacBwmGNvAQ@mail.gmail.com>
Date:   Tue, 13 Sep 2022 15:30:53 -0700
From:   Stanislav Fomichev <sdf@...gle.com>
To:     Wang Yufen <wangyufen@...wei.com>
Cc:     ast@...nel.org, daniel@...earbox.net, john.fastabend@...il.com,
        andrii@...nel.org, martin.lau@...ux.dev, song@...nel.org,
        yhs@...com, kpsingh@...nel.org, haoluo@...gle.com,
        jolsa@...nel.org, bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [bpf-next v2] bpf: use kvmemdup_bpfptr helper

On Tue, Sep 13, 2022 at 1:29 AM Wang Yufen <wangyufen@...wei.com> wrote:
>
> Use kvmemdup_bpfptr helper instead of open-coding to
> simplify the code.
>
> Signed-off-by: Wang Yufen <wangyufen@...wei.com>

Acked-by: Stanislav Fomichev <sdf@...gle.com>

> ---
>  kernel/bpf/syscall.c | 13 ++++---------
>  1 file changed, 4 insertions(+), 9 deletions(-)
>
> diff --git a/kernel/bpf/syscall.c b/kernel/bpf/syscall.c
> index 4fb08c4..f862406 100644
> --- a/kernel/bpf/syscall.c
> +++ b/kernel/bpf/syscall.c
> @@ -1416,19 +1416,14 @@ static int map_update_elem(union bpf_attr *attr, bpfptr_t uattr)
>         }
>
>         value_size = bpf_map_value_size(map);
> -
> -       err = -ENOMEM;
> -       value = kvmalloc(value_size, GFP_USER | __GFP_NOWARN);
> -       if (!value)
> +       value = kvmemdup_bpfptr(uvalue, value_size);
> +       if (IS_ERR(value)) {
> +               err = PTR_ERR(value);
>                 goto free_key;
> -
> -       err = -EFAULT;
> -       if (copy_from_bpfptr(value, uvalue, value_size) != 0)
> -               goto free_value;
> +       }
>
>         err = bpf_map_update_value(map, f, key, value, attr->flags);
>
> -free_value:
>         kvfree(value);
>  free_key:
>         kvfree(key);
> --
> 1.8.3.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ