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  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]
Date:   Thu, 12 May 2022 16:45:24 +0000
From:   Song Liu <songliubraving@...com>
To:     Wan Jiabing <wanjiabing@...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 Lau <kafai@...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>,
        Linux Kernel Mailing List <linux-kernel@...r.kernel.org>
Subject: Re: [PATCH 3/3] bpf: use vmemdup_user instead of kvmalloc and
 copy_from_user



> On May 12, 2022, at 7:17 AM, Wan Jiabing <wanjiabing@...o.com> wrote:
> 
> Fix following coccicheck warning:
> ./kernel/trace/bpf_trace.c:2488:12-20: WARNING opportunity for vmemdup_user
> 
> Use vmemdup_user instead of kvmalloc and copy_from_user.
> 
> Signed-off-by: Wan Jiabing <wanjiabing@...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 1b0db8f78dc8..48fc97a6db50 100644
> --- a/kernel/trace/bpf_trace.c
> +++ b/kernel/trace/bpf_trace.c
> @@ -2483,15 +2483,11 @@ 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;
> +		cookies = vmemdup_user(ucookies, size);

vmemdup_user() uses GFP_USER, so this is a behavior change. 

Song

> +		if (IS_ERR(cookies)) {
> +			err = PTR_ERR(cookies);
> 			goto error_addrs;
> 		}
> -		if (copy_from_user(cookies, ucookies, size)) {
> -			err = -EFAULT;
> -			goto error_cookies;
> -		}
> 	}
> 
> 	link = kzalloc(sizeof(*link), GFP_KERNEL);
> -- 
> 2.35.1
> 

Powered by blists - more mailing lists