* [PATCH] kdb: address -Wformat-security warnings
@ 2024-05-28 12:11 Arnd Bergmann
2024-05-28 13:41 ` Doug Anderson
2024-06-21 15:47 ` Daniel Thompson
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2024-05-28 12:11 UTC (permalink / raw)
To: Jason Wessel, Daniel Thompson
Cc: Arnd Bergmann, Douglas Anderson, Petr Mladek, Sergey Senozhatsky,
Justin Stitt, John Ogness, kgdb-bugreport, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
When -Wformat-security is not disabled, using a string pointer
as a format causes a warning:
kernel/debug/kdb/kdb_io.c: In function 'kdb_read':
kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security]
365 | kdb_printf(kdb_prompt_str);
| ^~~~~~~~~~~~~~
kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr':
kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security]
456 | kdb_printf(kdb_prompt_str);
| ^~~~~~~~~~~~~~
Use an explcit "%s" format instead.
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
kernel/debug/kdb/kdb_io.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/kernel/debug/kdb/kdb_io.c b/kernel/debug/kdb/kdb_io.c
index 3131334d7a81..7da3fa7beffd 100644
--- a/kernel/debug/kdb/kdb_io.c
+++ b/kernel/debug/kdb/kdb_io.c
@@ -362,7 +362,7 @@ static char *kdb_read(char *buffer, size_t bufsize)
if (i >= dtab_count)
kdb_printf("...");
kdb_printf("\n");
- kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", kdb_prompt_str);
kdb_printf("%s", buffer);
if (cp != lastchar)
kdb_position_cursor(kdb_prompt_str, buffer, cp);
@@ -453,7 +453,7 @@ char *kdb_getstr(char *buffer, size_t bufsize, const char *prompt)
{
if (prompt && kdb_prompt_str != prompt)
strscpy(kdb_prompt_str, prompt, CMD_BUFLEN);
- kdb_printf(kdb_prompt_str);
+ kdb_printf("%s", kdb_prompt_str);
kdb_nextline = 1; /* Prompt and input resets line number */
return kdb_read(buffer, bufsize);
}
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] kdb: address -Wformat-security warnings
2024-05-28 12:11 [PATCH] kdb: address -Wformat-security warnings Arnd Bergmann
@ 2024-05-28 13:41 ` Doug Anderson
2024-06-21 15:47 ` Daniel Thompson
1 sibling, 0 replies; 3+ messages in thread
From: Doug Anderson @ 2024-05-28 13:41 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Jason Wessel, Daniel Thompson, Arnd Bergmann, Petr Mladek,
Sergey Senozhatsky, Justin Stitt, John Ogness, kgdb-bugreport,
linux-kernel
Hi,
On Tue, May 28, 2024 at 5:12 AM Arnd Bergmann <arnd@kernel.org> wrote:
>
> From: Arnd Bergmann <arnd@arndb.de>
>
> When -Wformat-security is not disabled, using a string pointer
> as a format causes a warning:
>
> kernel/debug/kdb/kdb_io.c: In function 'kdb_read':
> kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security]
> 365 | kdb_printf(kdb_prompt_str);
> | ^~~~~~~~~~~~~~
> kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr':
> kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security]
> 456 | kdb_printf(kdb_prompt_str);
> | ^~~~~~~~~~~~~~
>
> Use an explcit "%s" format instead.
>
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
> kernel/debug/kdb/kdb_io.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
Fixes: 5d5314d6795f ("kdb: core for kgdb back end (1 of 2)")
Reviewed-by: Douglas Anderson <dianders@chromium.org>
...probably also justifies a:
Cc: stable@vger.kernel.org
-Doug
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] kdb: address -Wformat-security warnings
2024-05-28 12:11 [PATCH] kdb: address -Wformat-security warnings Arnd Bergmann
2024-05-28 13:41 ` Doug Anderson
@ 2024-06-21 15:47 ` Daniel Thompson
1 sibling, 0 replies; 3+ messages in thread
From: Daniel Thompson @ 2024-06-21 15:47 UTC (permalink / raw)
To: Jason Wessel, Arnd Bergmann
Cc: Daniel Thompson, Arnd Bergmann, Douglas Anderson, Petr Mladek,
Sergey Senozhatsky, Justin Stitt, John Ogness, kgdb-bugreport,
linux-kernel
On Tue, 28 May 2024 14:11:48 +0200, Arnd Bergmann wrote:
> When -Wformat-security is not disabled, using a string pointer
> as a format causes a warning:
>
> kernel/debug/kdb/kdb_io.c: In function 'kdb_read':
> kernel/debug/kdb/kdb_io.c:365:36: error: format not a string literal and no format arguments [-Werror=format-security]
> 365 | kdb_printf(kdb_prompt_str);
> | ^~~~~~~~~~~~~~
> kernel/debug/kdb/kdb_io.c: In function 'kdb_getstr':
> kernel/debug/kdb/kdb_io.c:456:20: error: format not a string literal and no format arguments [-Werror=format-security]
> 456 | kdb_printf(kdb_prompt_str);
> | ^~~~~~~~~~~~~~
>
> [...]
Applied, thanks!
[1/1] kdb: address -Wformat-security warnings
commit: 70867efacf4370b6c7cdfc7a5b11300e9ef7de64
Best regards,
--
Daniel Thompson <daniel.thompson@linaro.org>
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-06-21 15:48 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-28 12:11 [PATCH] kdb: address -Wformat-security warnings Arnd Bergmann
2024-05-28 13:41 ` Doug Anderson
2024-06-21 15:47 ` Daniel Thompson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox