mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Steven Rostedt <rostedt@goodmis.org>
To: Jiri Olsa <jolsa@redhat.com>
Cc: linux-kernel@vger.kernel.org,
	Andrew Morton <akpm@linux-foundation.org>,
	Rasmus Villemoes <linux@rasmusvillemoes.dk>,
	Frederic Weisbecker <fweisbec@gmail.com>,
	Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	Jiri Olsa <jolsa@kernel.org>
Subject: Re: [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to vbin_printf()
Date: Thu, 30 Jun 2016 11:48:30 -0400	[thread overview]
Message-ID: <20160630114830.49b18e55@gandalf.local.home> (raw)
In-Reply-To: <20160630145634.GA2992@krava>

On Thu, 30 Jun 2016 16:56:34 +0200
Jiri Olsa <jolsa@redhat.com> wrote:

> On Wed, Jun 29, 2016 at 04:05:25PM -0400, Steven Rostedt wrote:
> 
> SNIP
> 
> >  			}
> > @@ -2552,11 +2561,18 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
> >  		}
> >  
> >  		case FORMAT_TYPE_PTR: {
> > +			unsigned long *tmp_ptr;
> > +			unsigned long *ptr;
> >  			const char *_fmt = fmt;
> >  			char tmp_fmt[2];
> >  
> >  			if (supported_bin_ptr(fmt)) {
> >  				switch (fmt[0]) {
> > +				case 'b': {
> > +					tmp_ptr = get_arg(void *);
> > +					ptr = (void *)&tmp_ptr;  
> 
> this seems wrong.. &tmp_ptr is address from the stack
> not from args which is what we want in here IIUC

Ah, your right. This only worked because the test I did was on a mask
of less than 64 cpus, where the above moved the bitmask into tmp_ptr.

I do want the address of the actual args array.

> 
> should we do something like in attached patch? untested..

I'll test it out.

Thanks,

-- Steve

> 
> thanks,
> jirka
> 
> 
> ---
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 474d9ddaca6f..9aeb277ae533 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -2561,7 +2561,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
>  		}
>  
>  		case FORMAT_TYPE_PTR: {
> -			unsigned long *tmp_ptr;
>  			unsigned long *ptr;
>  			const char *_fmt = fmt;
>  			char tmp_fmt[2];
> @@ -2569,8 +2568,8 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
>  			if (supported_bin_ptr(fmt)) {
>  				switch (fmt[0]) {
>  				case 'b': {
> -					tmp_ptr = get_arg(void *);
> -					ptr = (void *)&tmp_ptr;
> +					ptr = (unsigned long *) PTR_ALIGN(args, sizeof(u32));
> +					args += BITS_TO_LONGS(spec.field_width);
>  					break;
>  				}
>  				case 'F':

      reply	other threads:[~2016-06-30 15:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-06-29 20:05 [RFC][PATCH 0/3] vsprintf: Do not dereference pointers in bstr_printf() Steven Rostedt
2016-06-29 20:05 ` [RFC][PATCH 1/3] vsprintf: Prevent vbin_printf() from using dereferenced pointers Steven Rostedt
2016-06-29 20:05 ` [RFC][PATCH 2/3] vsprintf: Add support for %pf and %pF to vbin_printf() Steven Rostedt
2016-06-29 20:05 ` [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends " Steven Rostedt
2016-06-30 14:56   ` Jiri Olsa
2016-06-30 15:48     ` Steven Rostedt [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=20160630114830.49b18e55@gandalf.local.home \
    --to=rostedt@goodmis.org \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=fweisbec@gmail.com \
    --cc=jolsa@kernel.org \
    --cc=jolsa@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@rasmusvillemoes.dk \
    /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®