From: "Chen, Rong A" <rong.a.chen@intel.com>
To: Steven Rostedt <rostedt@goodmis.org>, kernel test robot <lkp@intel.com>
Cc: kbuild-all@lists.01.org, linux-kernel@vger.kernel.org,
Tom Zanussi <zanussi@kernel.org>
Subject: Re: [kbuild-all] Re: kernel/trace/trace_events_synth.c:436:68: sparse: sparse: incorrect type in argument 2 (different address spaces)
Date: Mon, 24 Oct 2022 15:14:00 +0800 [thread overview]
Message-ID: <97e79e49-0635-68d8-1ee0-1ba9030c45f1@intel.com> (raw)
In-Reply-To: <20221019093416.1155d790@gandalf.local.home>
On 10/19/2022 9:34 PM, Steven Rostedt wrote:
> On Wed, 19 Oct 2022 11:43:54 +0800
> kernel test robot <lkp@intel.com> wrote:
>
>> sparse warnings: (new ones prefixed by >>)
>>>> kernel/trace/trace_events_synth.c:436:68: sparse: sparse: incorrect type in argument 2 (different address spaces) @@ expected void const [noderef] __user *unsafe_addr @@ got char *str_val @@
>> kernel/trace/trace_events_synth.c:436:68: sparse: expected void const [noderef] __user *unsafe_addr
>> kernel/trace/trace_events_synth.c:436:68: sparse: got char *str_val
>>
>> vim +436 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((unsigned long)str_val);
>> 424
>> 425 data_offset |= len << 16;
>> 426 *(u32 *)&entry->fields[*n_u64] = data_offset;
>> 427
>> 428 ret = kern_fetch_store_string((unsigned long)str_val, &entry->fields[*n_u64], entry);
>> 429
>> 430 (*n_u64)++;
>> 431 } else {
>> 432 str_field = (char *)&entry->fields[*n_u64];
>> 433
>> 434 #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
>> 435 if ((unsigned long)str_val < TASK_SIZE)
>> > 436 ret = strncpy_from_user_nofault(str_field, str_val, STR_VAR_LEN_MAX);
>> 437 else
>> 438 #endif
>> 439 ret = strncpy_from_kernel_nofault(str_field, str_val, STR_VAR_LEN_MAX);
>> 440
>
>
> Does this fix it?
Hi Steve,
I tried the below patch, it can fix the issue.
Best Regards,
Rong Chen
>
> -- Steve
>
> diff --git a/kernel/trace/trace_events_synth.c b/kernel/trace/trace_events_synth.c
> index e310052dc83c..2562d7522999 100644
> --- a/kernel/trace/trace_events_synth.c
> +++ b/kernel/trace/trace_events_synth.c
> @@ -433,7 +433,8 @@ static unsigned int trace_string(struct synth_trace_event *entry,
>
> #ifdef CONFIG_ARCH_HAS_NON_OVERLAPPING_ADDRESS_SPACE
> if ((unsigned long)str_val < TASK_SIZE)
> - ret = strncpy_from_user_nofault(str_field, str_val, STR_VAR_LEN_MAX);
> + ret = strncpy_from_user_nofault(str_field,
> + (__force const void __user *)str_val, STR_VAR_LEN_MAX);
> else
> #endif
> ret = strncpy_from_kernel_nofault(str_field, str_val, STR_VAR_LEN_MAX);
> _______________________________________________
> kbuild-all mailing list -- kbuild-all@lists.01.org
> To unsubscribe send an email to kbuild-all-leave@lists.01.org
>
prev parent reply other threads:[~2022-10-24 7:14 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-19 3:43 kernel test robot
2022-10-19 13:34 ` Steven Rostedt
2022-10-24 7:14 ` Chen, Rong A [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=97e79e49-0635-68d8-1ee0-1ba9030c45f1@intel.com \
--to=rong.a.chen@intel.com \
--cc=kbuild-all@lists.01.org \
--cc=linux-kernel@vger.kernel.org \
--cc=lkp@intel.com \
--cc=rostedt@goodmis.org \
--cc=zanussi@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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®