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: <202210121133.9ON00f3H-lkp@intel.com>
Date:   Wed, 12 Oct 2022 11:31:16 +0800
From:   kernel test robot <lkp@...el.com>
To:     "Steven Rostedt (Google)" <rostedt@...dmis.org>
Cc:     kbuild-all@...ts.01.org, Ammar Faizi <ammarfaizi2@...weeb.org>,
        GNU/Weeb Mailing List <gwml@...r.gnuweeb.org>,
        linux-kernel@...r.kernel.org
Subject: [ammarfaizi2-block:rostedt/linux-trace/ftrace/core 46/46]
 kernel/trace/trace_events_synth.c:423:47: sparse: sparse: incorrect type in
 argument 1 (different base types)

tree:   https://github.com/ammarfaizi2/linux-block rostedt/linux-trace/ftrace/core
head:   36ac19d408fed20243e0901b038ade4bd6f5c8ad
commit: 36ac19d408fed20243e0901b038ade4bd6f5c8ad [46/46] tracing: Fix reading strings from synthetic events
config: arc-randconfig-s032-20221012
compiler: arceb-elf-gcc (GCC) 12.1.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # apt-get install sparse
        # sparse version: v0.6.4-39-gce1a6720-dirty
        # https://github.com/ammarfaizi2/linux-block/commit/36ac19d408fed20243e0901b038ade4bd6f5c8ad
        git remote add ammarfaizi2-block https://github.com/ammarfaizi2/linux-block
        git fetch --no-tags ammarfaizi2-block rostedt/linux-trace/ftrace/core
        git checkout 36ac19d408fed20243e0901b038ade4bd6f5c8ad
        # save the config file
        mkdir build_dir && cp config build_dir/.config
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-12.1.0 make.cross C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__' O=build_dir ARCH=arc SHELL=/bin/bash kernel/trace/

If you fix the issue, kindly add following tag where applicable
| Reported-by: kernel test robot <lkp@...el.com>

sparse warnings: (new ones prefixed by >>)
>> kernel/trace/trace_events_synth.c:423:47: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned long addr @@     got char *str_val @@
   kernel/trace/trace_events_synth.c:423:47: sparse:     expected unsigned long addr
   kernel/trace/trace_events_synth.c:423:47: sparse:     got char *str_val
>> kernel/trace/trace_events_synth.c:477:47: sparse: sparse: incorrect type in argument 1 (different base types) @@     expected unsigned long addr @@     got char *[assigned] str_val @@
   kernel/trace/trace_events_synth.c:477:47: sparse:     expected unsigned long addr
   kernel/trace/trace_events_synth.c:477:47: sparse:     got char *[assigned] str_val

vim +423 kernel/trace/trace_events_synth.c

   404	
   405	static unsigned int trace_string(struct synth_trace_event *entry,
   406					 struct synth_event *event,
   407					 char *str_val,
   408					 bool is_dynamic,
   409					 unsigned int data_size,
   410					 unsigned int *n_u64)
   411	{
   412		unsigned int len = 0;
   413		char *str_field;
   414		int ret;
   415	
   416		if (is_dynamic) {
   417			u32 data_offset;
   418	
   419			data_offset = offsetof(typeof(*entry), fields);
   420			data_offset += event->n_u64 * sizeof(u64);
   421			data_offset += data_size;
   422	
 > 423			len = kern_fetch_store_strlen(str_val) + 1;
   424			if (len == 1)
   425				len = strlen("fault") + 1;
   426			data_offset |= len << 16;
   427			*(u32 *)&entry->fields[*n_u64] = data_offset;
   428	
   429			kern_fetch_store_string((unsigned long)str_val, &entry->fields[*n_u64], entry);
   430	
   431			(*n_u64)++;
   432		} else {
   433			str_field = (char *)&entry->fields[*n_u64];
   434	
   435	#ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
   436			if ((unsigned long)str_val < TASK_SIZE)
   437				ret = strncpy_from_user_nofault(str_field, str_val, STR_VAR_LEN_MAX);
   438			else
   439	#endif
   440				ret = strncpy_from_kernel_nofault(str_field, str_val, STR_VAR_LEN_MAX);
   441	
   442			if (ret < 0)
   443				strcpy(str_field, "(fault)");
   444	
   445			(*n_u64) += STR_VAR_LEN_MAX / sizeof(u64);
   446		}
   447	
   448		return len;
   449	}
   450	
   451	static notrace void trace_event_raw_event_synth(void *__data,
   452							u64 *var_ref_vals,
   453							unsigned int *var_ref_idx)
   454	{
   455		unsigned int i, n_u64, val_idx, len, data_size = 0;
   456		struct trace_event_file *trace_file = __data;
   457		struct synth_trace_event *entry;
   458		struct trace_event_buffer fbuffer;
   459		struct trace_buffer *buffer;
   460		struct synth_event *event;
   461		int fields_size = 0;
   462	
   463		event = trace_file->event_call->data;
   464	
   465		if (trace_trigger_soft_disabled(trace_file))
   466			return;
   467	
   468		fields_size = event->n_u64 * sizeof(u64);
   469	
   470		for (i = 0; i < event->n_dynamic_fields; i++) {
   471			unsigned int field_pos = event->dynamic_fields[i]->field_pos;
   472			char *str_val;
   473	
   474			val_idx = var_ref_idx[field_pos];
   475			str_val = (char *)(long)var_ref_vals[val_idx];
   476	
 > 477			len = kern_fetch_store_strlen(str_val) + 1;
   478			if (len == 1)
   479				len = strlen("(fault)") + 1;
   480	
   481			fields_size += len;
   482		}
   483	
   484		/*
   485		 * Avoid ring buffer recursion detection, as this event
   486		 * is being performed within another event.
   487		 */
   488		buffer = trace_file->tr->array_buffer.buffer;
   489		ring_buffer_nest_start(buffer);
   490	
   491		entry = trace_event_buffer_reserve(&fbuffer, trace_file,
   492						   sizeof(*entry) + fields_size);
   493		if (!entry)
   494			goto out;
   495	
   496		for (i = 0, n_u64 = 0; i < event->n_fields; i++) {
   497			val_idx = var_ref_idx[i];
   498			if (event->fields[i]->is_string) {
   499				char *str_val = (char *)(long)var_ref_vals[val_idx];
   500	
   501				len = trace_string(entry, event, str_val,
   502						   event->fields[i]->is_dynamic,
   503						   data_size, &n_u64);
   504				data_size += len; /* only dynamic string increments */
   505			} else {
   506				struct synth_field *field = event->fields[i];
   507				u64 val = var_ref_vals[val_idx];
   508	
   509				switch (field->size) {
   510				case 1:
   511					*(u8 *)&entry->fields[n_u64] = (u8)val;
   512					break;
   513	
   514				case 2:
   515					*(u16 *)&entry->fields[n_u64] = (u16)val;
   516					break;
   517	
   518				case 4:
   519					*(u32 *)&entry->fields[n_u64] = (u32)val;
   520					break;
   521	
   522				default:
   523					entry->fields[n_u64] = val;
   524					break;
   525				}
   526				n_u64++;
   527			}
   528		}
   529	
   530		trace_event_buffer_commit(&fbuffer);
   531	out:
   532		ring_buffer_nest_end(buffer);
   533	}
   534	

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

View attachment "config" of type "text/plain" (138331 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ