[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20220512141710.116135-4-wanjiabing@vivo.com>
Date: Thu, 12 May 2022 22:17:10 +0800
From: Wan Jiabing <wanjiabing@...o.com>
To: 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>, netdev@...r.kernel.org,
bpf@...r.kernel.org, linux-kernel@...r.kernel.org
Cc: Wan Jiabing <wanjiabing@...o.com>
Subject: [PATCH 3/3] bpf: use vmemdup_user instead of kvmalloc and copy_from_user
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);
+ 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