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] [day] [month] [year] [list]
Date:   Tue, 22 Mar 2022 14:11:01 -0700
From:   Andrii Nakryiko <andrii.nakryiko@...il.com>
To:     Yihao Han <hanyihao@...o.com>
Cc:     Steven Rostedt <rostedt@...dmis.org>,
        Ingo Molnar <mingo@...hat.com>,
        Alexei Starovoitov <ast@...nel.org>,
        Daniel Borkmann <daniel@...earbox.net>,
        Andrii Nakryiko <andrii@...nel.org>,
        Martin KaFai Lau <kafai@...com>,
        Song Liu <songliubraving@...com>, Yonghong Song <yhs@...com>,
        John Fastabend <john.fastabend@...il.com>,
        KP Singh <kpsingh@...nel.org>,
        Networking <netdev@...r.kernel.org>, bpf <bpf@...r.kernel.org>,
        open list <linux-kernel@...r.kernel.org>, kernel@...o.com
Subject: Re: [PATCH] bpf: use vmemdup_user instead of kvmalloc and copy_from_user

On Tue, Mar 22, 2022 at 4:29 AM Yihao Han <hanyihao@...o.com> wrote:
>
> fix memdup_user.cocci warning:
> kernel/trace/bpf_trace.c:2450:12-20: WARNING opportunity
> for vmemdup_user
>
> Signed-off-by: Yihao Han <hanyihao@...o.com>
> ---
>  kernel/trace/bpf_trace.c | 10 +++-------
>  1 file changed, 3 insertions(+), 7 deletions(-)
>
> diff --git a/kernel/trace/bpf_trace.c b/kernel/trace/bpf_trace.c
> index 7fa2ebc07f60..aff2461c1ea2 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2447,13 +2447,9 @@ int bpf_kprobe_multi_link_attach(const union bpf_attr *attr, struct bpf_prog *pr
>
>         ucookies = u64_to_user_ptr(attr->link_create.kprobe_multi.cookies);
>         if (ucookies) {
> -               cookies = kvmalloc(size, GFP_KERNEL);
> -               if (!cookies) {
> -                       err = -ENOMEM;
> -                       goto error;
> -               }
> -               if (copy_from_user(cookies, ucookies, size)) {
> -                       err = -EFAULT;
> +               cookies = vmemdup_user(ucookies, size);

does kvfree() handle ERR_PTR() values properly? I doubt so. Did you
validate your change or just blindly applied some tool?

> +               if (IS_ERR(cookies)) {
> +                       err = PTR_ERR(cookies);
>                         goto error;
>                 }
>         }
> --
> 2.17.1
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ