mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Pingfan Liu <kernelfans@gmail.com>
Cc: linux-kernel@vger.kernel.org, Ingo Molnar <mingo@redhat.com>
Subject: Re: [PATCH 1/3] tracing/filter: degrade addr in filter_pred_string() from double pointer to pointer
Date: Fri, 7 Jan 2022 12:18:42 -0500	[thread overview]
Message-ID: <20220107121842.70c7651b@gandalf.local.home> (raw)
In-Reply-To: <20220107044951.22080-2-kernelfans@gmail.com>

On Fri,  7 Jan 2022 12:49:49 +0800
Pingfan Liu <kernelfans@gmail.com> wrote:

> Since FILTER_PTR_STRING has the type of "char *", it is meaningless to
> convert it to "char **". Hence degrading addr from double pointer to
> single.
> 
> Signed-off-by: Pingfan Liu <kernelfans@gmail.com>
> Cc: Steven Rostedt <rostedt@goodmis.org>
> Cc: Ingo Molnar <mingo@redhat.com>
> To: linux-kernel@vger.kernel.org
> ---
>  kernel/trace/trace_events_filter.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c
> index c9124038b140..264456e1698f 100644
> --- a/kernel/trace/trace_events_filter.c
> +++ b/kernel/trace/trace_events_filter.c
> @@ -670,11 +670,11 @@ static int filter_pred_string(struct filter_pred *pred, void *event)
>  /* Filter predicate for char * pointers */
>  static int filter_pred_pchar(struct filter_pred *pred, void *event)
>  {
> -	char **addr = (char **)(event + pred->offset);
> +	char *addr = (char *)(event + pred->offset);

This doesn't look right. The address of the pointer should be in the event.
"event" is an address to the content of the event in the kernel ring buffer.

	event + pred->offset

Is then the address of position of the event.

Let's say we have an event record at 0xffff8000, and the pred->offset is at
0x10. And the pointer to the string (in user space) is at 0x70008000.

0xffff8000:  <heade>
0xffff8010: 0x70008000

0x70008000: "user space sting"

event + pred->offset gives us 0xffff8010

If we now have that as char *addr, then addr is 0xffff8010


>  	int cmp, match;
> -	int len = strlen(*addr) + 1;	/* including tailing '\0' */
> +	int len = strlen(addr) + 1;	/* including tailing '\0' */

This would give us the addr = 0xffff8010, which is not where the string
exists.

How would this work?

-- Steve


>  
> -	cmp = pred->regex.match(*addr, &pred->regex, len);
> +	cmp = pred->regex.match(addr, &pred->regex, len);
>  
>  	match = cmp ^ pred->not;
>  


  reply	other threads:[~2022-01-07 17:18 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-07  4:49 [PATCH 0/3] tracing/filter: make filter_pred_pchar() survive the access to user space Pingfan Liu
2022-01-07  4:49 ` [PATCH 1/3] tracing/filter: degrade addr in filter_pred_string() from double pointer to pointer Pingfan Liu
2022-01-07 17:18   ` Steven Rostedt [this message]
2022-01-10  2:58     ` Pingfan Liu
2022-01-07  4:49 ` [PATCH 2/3] tracing/filter: harden the prototype of predicate_parse() Pingfan Liu
2022-01-07  4:49 ` [PATCH 3/3] tracing/filter: make filter_pred_pchar() survive the access to user space Pingfan Liu
2022-01-07 22:25   ` Steven Rostedt
2022-01-08  6:49   ` kernel test robot
2022-01-08  8:20   ` kernel test robot

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=20220107121842.70c7651b@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=kernelfans@gmail.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    /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®