mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* kernel/trace/trace_events_user.c:747:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
@ 2022-03-28  7:39 kernel test robot
  2022-03-28 15:15 ` Steven Rostedt
  0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2022-03-28  7:39 UTC (permalink / raw)
  To: Beau Belgrave; +Cc: kbuild-all, linux-kernel, Steven Rostedt (Google)

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git master
head:   ae085d7f9365de7da27ab5c0d16b12d51ea7fca9
commit: 7f5a08c79df35e68f1a43033450c5050f12bc155 user_events: Add minimal support for trace_event into ftrace
date:   6 weeks ago
config: i386-randconfig-s001-20220328 (https://download.01.org/0day-ci/archive/20220328/202203281558.fjXyftuw-lkp@intel.com/config)
compiler: gcc-9 (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.4-dirty
        # https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=7f5a08c79df35e68f1a43033450c5050f12bc155
        git remote add linus https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
        git fetch --no-tags linus master
        git checkout 7f5a08c79df35e68f1a43033450c5050f12bc155
        # save the config file to linux build tree
        mkdir build_dir
        make W=1 C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=i386 SHELL=/bin/bash drivers/acpi/apei/ drivers/gpu/drm/ kernel/trace/

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)
>> kernel/trace/trace_events_user.c:747:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
>> kernel/trace/trace_events_user.c:747:16: sparse:    void [noderef] __rcu *
>> kernel/trace/trace_events_user.c:747:16: sparse:    void *
>> kernel/trace/trace_events_user.c:811:13: sparse: sparse: cast removes address space '__user' of expression
>> kernel/trace/trace_events_user.c:811:13: sparse: sparse: incorrect type in argument 2 (different address spaces) @@     expected void [noderef] __user *buf @@     got char * @@
   kernel/trace/trace_events_user.c:811:13: sparse:     expected void [noderef] __user *buf
   kernel/trace/trace_events_user.c:811:13: sparse:     got char *
   kernel/trace/trace_events_user.c:827:16: sparse: sparse: incompatible types in comparison expression (different address spaces):
   kernel/trace/trace_events_user.c:827:16: sparse:    void [noderef] __rcu *
   kernel/trace/trace_events_user.c:827:16: sparse:    void *
   kernel/trace/trace_events_user.c:854:9: sparse: sparse: incompatible types in comparison expression (different address spaces):
   kernel/trace/trace_events_user.c:854:9: sparse:    void [noderef] __rcu *
   kernel/trace/trace_events_user.c:854:9: sparse:    void *

vim +747 kernel/trace/trace_events_user.c

   730	
   731	/*
   732	 * Validates the user payload and writes via iterator.
   733	 */
   734	static ssize_t user_events_write_core(struct file *file, struct iov_iter *i)
   735	{
   736		struct user_event_refs *refs;
   737		struct user_event *user = NULL;
   738		struct tracepoint *tp;
   739		ssize_t ret = i->count;
   740		int idx;
   741	
   742		if (unlikely(copy_from_iter(&idx, sizeof(idx), i) != sizeof(idx)))
   743			return -EFAULT;
   744	
   745		rcu_read_lock_sched();
   746	
 > 747		refs = rcu_dereference_sched(file->private_data);
   748	
   749		/*
   750		 * The refs->events array is protected by RCU, and new items may be
   751		 * added. But the user retrieved from indexing into the events array
   752		 * shall be immutable while the file is opened.
   753		 */
   754		if (likely(refs && idx < refs->count))
   755			user = refs->events[idx];
   756	
   757		rcu_read_unlock_sched();
   758	
   759		if (unlikely(user == NULL))
   760			return -ENOENT;
   761	
   762		tp = &user->tracepoint;
   763	
   764		/*
   765		 * It's possible key.enabled disables after this check, however
   766		 * we don't mind if a few events are included in this condition.
   767		 */
   768		if (likely(atomic_read(&tp->key.enabled) > 0)) {
   769			struct tracepoint_func *probe_func_ptr;
   770			user_event_func_t probe_func;
   771			void *tpdata;
   772			void *kdata;
   773			u32 datalen;
   774	
   775			kdata = kmalloc(i->count, GFP_KERNEL);
   776	
   777			if (unlikely(!kdata))
   778				return -ENOMEM;
   779	
   780			datalen = copy_from_iter(kdata, i->count, i);
   781	
   782			rcu_read_lock_sched();
   783	
   784			probe_func_ptr = rcu_dereference_sched(tp->funcs);
   785	
   786			if (probe_func_ptr) {
   787				do {
   788					probe_func = probe_func_ptr->func;
   789					tpdata = probe_func_ptr->data;
   790					probe_func(user, kdata, datalen, tpdata);
   791				} while ((++probe_func_ptr)->func);
   792			}
   793	
   794			rcu_read_unlock_sched();
   795	
   796			kfree(kdata);
   797		}
   798	
   799		return ret;
   800	}
   801	
   802	static ssize_t user_events_write(struct file *file, const char __user *ubuf,
   803					 size_t count, loff_t *ppos)
   804	{
   805		struct iovec iov;
   806		struct iov_iter i;
   807	
   808		if (unlikely(*ppos != 0))
   809			return -EFAULT;
   810	
 > 811		if (unlikely(import_single_range(READ, (char *)ubuf, count, &iov, &i)))
   812			return -EFAULT;
   813	
   814		return user_events_write_core(file, &i);
   815	}
   816	

-- 
0-DAY CI Kernel Test Service
https://01.org/lkp

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-03-28 15:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-03-28  7:39 kernel/trace/trace_events_user.c:747:16: sparse: sparse: incompatible types in comparison expression (different address spaces): kernel test robot
2022-03-28 15:15 ` Steven Rostedt

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®