From: Jiri Olsa <jolsa@redhat.com>
To: Steven Rostedt <rostedt@goodmis.org>
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 16:56:34 +0200 [thread overview]
Message-ID: <20160630145634.GA2992@krava> (raw)
In-Reply-To: <20160629201224.718341351@goodmis.org>
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
should we do something like in attached patch? untested..
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':
next prev parent reply other threads:[~2016-06-30 14:56 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 [this message]
2016-06-30 15:48 ` Steven Rostedt
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=20160630145634.GA2992@krava \
--to=jolsa@redhat.com \
--cc=akpm@linux-foundation.org \
--cc=andriy.shevchenko@linux.intel.com \
--cc=fweisbec@gmail.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux@rasmusvillemoes.dk \
--cc=rostedt@goodmis.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.