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>] [day] [month] [year] [list]
Message-ID: <202507151301.xP2HYvaW-lkp@intel.com>
Date: Tue, 15 Jul 2025 13:11:29 +0800
From: kernel test robot <lkp@...el.com>
To: Tomas Glozar <tglozar@...hat.com>
Cc: oe-kbuild-all@...ts.linux.dev, linux-kernel@...r.kernel.org,
	"Steven Rostedt (Google)" <rostedt@...dmis.org>
Subject: kernel/trace/trace_osnoise.c:2325:7-14: WARNING opportunity for
 memdup_user

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   347e9f5043c89695b01e66b3ed111755afcf1911
commit: 17f89102fe23d7389085a8820550df688f79888a tracing/osnoise: Allow arbitrarily long CPU string
date:   10 weeks ago
config: arm-randconfig-r064-20250714 (https://download.01.org/0day-ci/archive/20250715/202507151301.xP2HYvaW-lkp@intel.com/config)
compiler: clang version 21.0.0git (https://github.com/llvm/llvm-project 01c97b4953e87ae455bd4c41e3de3f0f0f29c61c)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@...el.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507151301.xP2HYvaW-lkp@intel.com/

cocci warnings: (new ones prefixed by >>)
>> kernel/trace/trace_osnoise.c:2325:7-14: WARNING opportunity for memdup_user

vim +2325 kernel/trace/trace_osnoise.c

  2300	
  2301	/*
  2302	 * osnoise_cpus_write - Write function for "cpus" entry
  2303	 * @filp: The active open file structure
  2304	 * @ubuf: The user buffer that contains the value to write
  2305	 * @count: The maximum number of bytes to write to "file"
  2306	 * @ppos: The current position in @file
  2307	 *
  2308	 * This function provides a write implementation for the "cpus"
  2309	 * interface to the osnoise trace. By default, it lists all  CPUs,
  2310	 * in this way, allowing osnoise threads to run on any online CPU
  2311	 * of the system. It serves to restrict the execution of osnoise to the
  2312	 * set of CPUs writing via this interface. Why not use "tracing_cpumask"?
  2313	 * Because the user might be interested in tracing what is running on
  2314	 * other CPUs. For instance, one might run osnoise in one HT CPU
  2315	 * while observing what is running on the sibling HT CPU.
  2316	 */
  2317	static ssize_t
  2318	osnoise_cpus_write(struct file *filp, const char __user *ubuf, size_t count,
  2319			   loff_t *ppos)
  2320	{
  2321		cpumask_var_t osnoise_cpumask_new;
  2322		int running, err;
  2323		char *buf __free(kfree) = NULL;
  2324	
> 2325		buf = kmalloc(count, GFP_KERNEL);
  2326		if (!buf)
  2327			return -ENOMEM;
  2328	
  2329		if (copy_from_user(buf, ubuf, count))
  2330			return -EFAULT;
  2331	
  2332		if (!zalloc_cpumask_var(&osnoise_cpumask_new, GFP_KERNEL))
  2333			return -ENOMEM;
  2334	
  2335		err = cpulist_parse(buf, osnoise_cpumask_new);
  2336		if (err)
  2337			goto err_free;
  2338	
  2339		/*
  2340		 * trace_types_lock is taken to avoid concurrency on start/stop.
  2341		 */
  2342		mutex_lock(&trace_types_lock);
  2343		running = osnoise_has_registered_instances();
  2344		if (running)
  2345			stop_per_cpu_kthreads();
  2346	
  2347		mutex_lock(&interface_lock);
  2348		/*
  2349		 * osnoise_cpumask is read by CPU hotplug operations.
  2350		 */
  2351		cpus_read_lock();
  2352	
  2353		cpumask_copy(&osnoise_cpumask, osnoise_cpumask_new);
  2354	
  2355		cpus_read_unlock();
  2356		mutex_unlock(&interface_lock);
  2357	
  2358		if (running)
  2359			start_per_cpu_kthreads();
  2360		mutex_unlock(&trace_types_lock);
  2361	
  2362		free_cpumask_var(osnoise_cpumask_new);
  2363		return count;
  2364	
  2365	err_free:
  2366		free_cpumask_var(osnoise_cpumask_new);
  2367	
  2368		return err;
  2369	}
  2370	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ