Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1434644

Re: [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to vbin_printf()

From Jiri Olsa <jolsa@redhat.com>
Newsgroups linux.kernel
Subject Re: [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to vbin_printf()
Date 2016-06-30 17:00 +0200
Message-ID <rPLBE-2p3-19@gated-at.bofh.it> (permalink)
References <rPu7L-go-3@gated-at.bofh.it> <rPu7M-go-19@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


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':

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC][PATCH 0/3] vsprintf: Do not dereference pointers in bstr_printf() Steven Rostedt <rostedt@goodmis.org> - 2016-06-29 22:20 +0200
  [RFC][PATCH 1/3] vsprintf: Prevent vbin_printf() from using dereferenced pointers Steven Rostedt <rostedt@goodmis.org> - 2016-06-29 22:20 +0200
  [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to vbin_printf() Steven Rostedt <rostedt@goodmis.org> - 2016-06-29 22:20 +0200
    Re: [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to  vbin_printf() Jiri Olsa <jolsa@redhat.com> - 2016-06-30 17:00 +0200
      Re: [RFC][PATCH 3/3] vsprintf: Add support for %pb and friends to  vbin_printf() Steven Rostedt <rostedt@goodmis.org> - 2016-06-30 17:50 +0200
  [RFC][PATCH 2/3] vsprintf: Add support for %pf and %pF to vbin_printf() Steven Rostedt <rostedt@goodmis.org> - 2016-06-29 22:20 +0200

csiph-web