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]
Date:   Wed, 14 Apr 2021 13:15:33 +0800
From:   kernel test robot <lkp@...el.com>
To:     Namhyung Kim <namhyung@...nel.org>,
        Peter Zijlstra <peterz@...radead.org>
Cc:     kbuild-all@...ts.01.org, Ingo Molnar <mingo@...nel.org>,
        Arnaldo Carvalho de Melo <acme@...nel.org>,
        Jiri Olsa <jolsa@...hat.com>,
        Mark Rutland <mark.rutland@....com>,
        Alexander Shishkin <alexander.shishkin@...ux.intel.com>,
        LKML <linux-kernel@...r.kernel.org>,
        Stephane Eranian <eranian@...gle.com>,
        Andi Kleen <ak@...ux.intel.com>,
        Ian Rogers <irogers@...gle.com>
Subject: [PATCH] perf/core: fix memdup_user.cocci warnings

From: kernel test robot <lkp@...el.com>

kernel/events/core.c:5925:13-20: WARNING opportunity for memdup_user

 Use memdup_user rather than duplicating its implementation
 This is a little bit restricted to reduce false positives

Generated by: scripts/coccinelle/api/memdup_user.cocci

CC: Namhyung Kim <namhyung@...nel.org>
Reported-by: kernel test robot <lkp@...el.com>
Signed-off-by: kernel test robot <lkp@...el.com>
---

url:    https://github.com/0day-ci/linux/commits/Namhyung-Kim/perf-core-Sharing-events-with-multiple-cgroups/20210413-124251
base:   https://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git cface0326a6c2ae5c8f47bd466f07624b3e348a7

 core.c |   12 +++---------
 1 file changed, 3 insertions(+), 9 deletions(-)

--- a/kernel/events/core.c
+++ b/kernel/events/core.c
@@ -5922,15 +5922,9 @@ static long _perf_ioctl(struct perf_even
 
 		cgrp_bufsz = nr_cgrps * sizeof(*cgrp_buf);
 
-		cgrp_buf = kmalloc(cgrp_bufsz, GFP_KERNEL);
-		if (cgrp_buf == NULL)
-			return -ENOMEM;
-
-		if (copy_from_user(cgrp_buf, (u64 __user *)(arg + 8),
-				   cgrp_bufsz)) {
-			kfree(cgrp_buf);
-			return -EFAULT;
-		}
+		cgrp_buf = memdup_user((u64 __user *)(arg + 8), cgrp_bufsz);
+		if (IS_ERR(cgrp_buf))
+			return PTR_ERR(cgrp_buf);
 
 		ret = perf_event_attach_cgroup_node(event, nr_cgrps, cgrp_buf);
 

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ