* [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf()
@ 2021-04-23 9:45 Rasmus Villemoes
2021-04-23 10:01 ` Sakari Ailus
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: Rasmus Villemoes @ 2021-04-23 9:45 UTC (permalink / raw)
To: Andrew Morton, Petr Mladek, Steven Rostedt, Sergey Senozhatsky,
Andy Shevchenko, Rasmus Villemoes, Rafael J. Wysocki,
Sakari Ailus
Cc: stable, linux-kernel
Commit 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in
favour of %pS and %ps") removed support for %pF and %pf, and correctly
removed the handling of those cases in vbin_printf(). However, the
corresponding cases in bstr_printf() were left behind.
In the same series, %pf was re-purposed for dealing with
fwnodes (3bd32d6a2ee6, "lib/vsprintf: Add %pfw conversion specifier
for printing fwnode names").
So should anyone use %pf with the binary printf routines,
vbin_printf() would (correctly, as it involves dereferencing the
pointer) do the string formatting to the u32 array, but bstr_printf()
would not copy the string from the u32 array, but instead interpret
the first sizeof(void*) bytes of the formatted string as a pointer -
which generally won't end well (also, all subsequent get_args would be
out of sync).
Fixes: 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")
Cc: stable@vger.kernel.org
Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
---
lib/vsprintf.c | 2 --
1 file changed, 2 deletions(-)
diff --git a/lib/vsprintf.c b/lib/vsprintf.c
index 41ddc353ebb8..39ef2e314da5 100644
--- a/lib/vsprintf.c
+++ b/lib/vsprintf.c
@@ -3135,8 +3135,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
switch (*fmt) {
case 'S':
case 's':
- case 'F':
- case 'f':
case 'x':
case 'K':
case 'e':
--
2.29.2
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf()
2021-04-23 9:45 [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf() Rasmus Villemoes
@ 2021-04-23 10:01 ` Sakari Ailus
2021-04-23 15:10 ` Petr Mladek
2021-04-26 13:07 ` Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: Sakari Ailus @ 2021-04-23 10:01 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Andrew Morton, Petr Mladek, Steven Rostedt, Sergey Senozhatsky,
Andy Shevchenko, Rafael J. Wysocki, stable, linux-kernel
Hi Rasmus,
On Fri, Apr 23, 2021 at 11:45:29AM +0200, Rasmus Villemoes wrote:
> Commit 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in
> favour of %pS and %ps") removed support for %pF and %pf, and correctly
> removed the handling of those cases in vbin_printf(). However, the
> corresponding cases in bstr_printf() were left behind.
>
> In the same series, %pf was re-purposed for dealing with
> fwnodes (3bd32d6a2ee6, "lib/vsprintf: Add %pfw conversion specifier
> for printing fwnode names").
>
> So should anyone use %pf with the binary printf routines,
> vbin_printf() would (correctly, as it involves dereferencing the
> pointer) do the string formatting to the u32 array, but bstr_printf()
> would not copy the string from the u32 array, but instead interpret
> the first sizeof(void*) bytes of the formatted string as a pointer -
> which generally won't end well (also, all subsequent get_args would be
> out of sync).
>
> Fixes: 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")
> Cc: stable@vger.kernel.org
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Thanks!
Reviewed-by: Sakari Ailus <sakari.ailus@linux.intel.com>
> ---
> lib/vsprintf.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 41ddc353ebb8..39ef2e314da5 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -3135,8 +3135,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
> switch (*fmt) {
> case 'S':
> case 's':
> - case 'F':
> - case 'f':
> case 'x':
> case 'K':
> case 'e':
> --
> 2.29.2
>
--
Sakari Ailus
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf()
2021-04-23 9:45 [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf() Rasmus Villemoes
2021-04-23 10:01 ` Sakari Ailus
@ 2021-04-23 15:10 ` Petr Mladek
2021-04-26 13:07 ` Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: Petr Mladek @ 2021-04-23 15:10 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Andrew Morton, Steven Rostedt, Sergey Senozhatsky,
Andy Shevchenko, Rafael J. Wysocki, Sakari Ailus, stable,
linux-kernel
On Fri 2021-04-23 11:45:29, Rasmus Villemoes wrote:
> Commit 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in
> favour of %pS and %ps") removed support for %pF and %pf, and correctly
> removed the handling of those cases in vbin_printf(). However, the
> corresponding cases in bstr_printf() were left behind.
>
> In the same series, %pf was re-purposed for dealing with
> fwnodes (3bd32d6a2ee6, "lib/vsprintf: Add %pfw conversion specifier
> for printing fwnode names").
>
> So should anyone use %pf with the binary printf routines,
> vbin_printf() would (correctly, as it involves dereferencing the
> pointer) do the string formatting to the u32 array, but bstr_printf()
> would not copy the string from the u32 array, but instead interpret
> the first sizeof(void*) bytes of the formatted string as a pointer -
> which generally won't end well (also, all subsequent get_args would be
> out of sync).
>
> Fixes: 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")
> Cc: stable@vger.kernel.org
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Great catch!
The patch is pushed in printk/linux.git, branch for-5.13 now.
I did it quickly because the merge window will likely be opened
next week and this should get in.
Best Regards,
Petr
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf()
2021-04-23 9:45 [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf() Rasmus Villemoes
2021-04-23 10:01 ` Sakari Ailus
2021-04-23 15:10 ` Petr Mladek
@ 2021-04-26 13:07 ` Steven Rostedt
2 siblings, 0 replies; 4+ messages in thread
From: Steven Rostedt @ 2021-04-26 13:07 UTC (permalink / raw)
To: Rasmus Villemoes
Cc: Andrew Morton, Petr Mladek, Sergey Senozhatsky, Andy Shevchenko,
Rafael J. Wysocki, Sakari Ailus, stable, linux-kernel
On Fri, 23 Apr 2021 11:45:29 +0200
Rasmus Villemoes <linux@rasmusvillemoes.dk> wrote:
> Commit 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in
> favour of %pS and %ps") removed support for %pF and %pf, and correctly
> removed the handling of those cases in vbin_printf(). However, the
> corresponding cases in bstr_printf() were left behind.
>
> In the same series, %pf was re-purposed for dealing with
> fwnodes (3bd32d6a2ee6, "lib/vsprintf: Add %pfw conversion specifier
> for printing fwnode names").
>
> So should anyone use %pf with the binary printf routines,
> vbin_printf() would (correctly, as it involves dereferencing the
> pointer) do the string formatting to the u32 array, but bstr_printf()
> would not copy the string from the u32 array, but instead interpret
> the first sizeof(void*) bytes of the formatted string as a pointer -
> which generally won't end well (also, all subsequent get_args would be
> out of sync).
>
> Fixes: 9af7706492f9 ("lib/vsprintf: Remove support for %pF and %pf in favour of %pS and %ps")
> Cc: stable@vger.kernel.org
> Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
> ---
Reviewed-by: Steven Rostedt (VMware) <rostedt@goodmis.org>
Thanks!
-- Steve
> lib/vsprintf.c | 2 --
> 1 file changed, 2 deletions(-)
>
> diff --git a/lib/vsprintf.c b/lib/vsprintf.c
> index 41ddc353ebb8..39ef2e314da5 100644
> --- a/lib/vsprintf.c
> +++ b/lib/vsprintf.c
> @@ -3135,8 +3135,6 @@ int bstr_printf(char *buf, size_t size, const char *fmt, const u32 *bin_buf)
> switch (*fmt) {
> case 'S':
> case 's':
> - case 'F':
> - case 'f':
> case 'x':
> case 'K':
> case 'e':
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2021-04-26 13:07 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-23 9:45 [PATCH] lib/vsprintf.c: remove leftover 'f' and 'F' cases from bstr_printf() Rasmus Villemoes
2021-04-23 10:01 ` Sakari Ailus
2021-04-23 15:10 ` Petr Mladek
2021-04-26 13:07 ` Steven Rostedt
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).