public inbox for linux-pm@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] power: reset: reboot-mode: fix -Wformat-security warning
@ 2026-03-06 15:07 Arnd Bergmann
  2026-03-11  7:10 ` Sebastian Reichel
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2026-03-06 15:07 UTC (permalink / raw)
  To: Sebastian Reichel, Bartosz Golaszewski, Shivendra Pratap
  Cc: Arnd Bergmann, André Draszik, linux-pm, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

The device_create() function expects a format string to construct a device
name, so passing a variable here introduces a possible vulnerability in
case the string can contain '%' characters:

drivers/power/reset/reboot-mode.c:148:22: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
drivers/power/reset/reboot-mode.c:148:22: note: treat the string as an argument to avoid this
  148 |                                                  (void *)priv, reboot->dev->driver->name);

Use an trivial "%s" format instead and pass the name as the string to be
included here.

Fixes: cfaf0a90789a ("power: reset: reboot-mode: Expose sysfs for registered reboot_modes")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/power/reset/reboot-mode.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/power/reset/reboot-mode.c b/drivers/power/reset/reboot-mode.c
index ad239e96774b..d20e44db0532 100644
--- a/drivers/power/reset/reboot-mode.c
+++ b/drivers/power/reset/reboot-mode.c
@@ -145,7 +145,8 @@ static int reboot_mode_create_device(struct reboot_mode_driver *reboot)
 	}
 
 	priv->reboot_mode_device = device_create(&reboot_mode_class, NULL, 0,
-						 (void *)priv, reboot->dev->driver->name);
+						 (void *)priv, "%s",
+						 reboot->dev->driver->name);
 	if (IS_ERR(priv->reboot_mode_device)) {
 		ret = PTR_ERR(priv->reboot_mode_device);
 		goto error;
-- 
2.39.5


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] power: reset: reboot-mode: fix -Wformat-security warning
  2026-03-06 15:07 [PATCH] power: reset: reboot-mode: fix -Wformat-security warning Arnd Bergmann
@ 2026-03-11  7:10 ` Sebastian Reichel
  0 siblings, 0 replies; 2+ messages in thread
From: Sebastian Reichel @ 2026-03-11  7:10 UTC (permalink / raw)
  To: Sebastian Reichel, Bartosz Golaszewski, Shivendra Pratap,
	Arnd Bergmann
  Cc: Arnd Bergmann, André Draszik, linux-pm, linux-kernel


On Fri, 06 Mar 2026 16:07:34 +0100, Arnd Bergmann wrote:
> The device_create() function expects a format string to construct a device
> name, so passing a variable here introduces a possible vulnerability in
> case the string can contain '%' characters:
> 
> drivers/power/reset/reboot-mode.c:148:22: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
> drivers/power/reset/reboot-mode.c:148:22: note: treat the string as an argument to avoid this
>   148 |                                                  (void *)priv, reboot->dev->driver->name);
> 
> [...]

Applied, thanks!

[1/1] power: reset: reboot-mode: fix -Wformat-security warning
      commit: c7e05ab38adc44d0cae4888016829359dcbba7b2

Best regards,
-- 
Sebastian Reichel <sebastian.reichel@collabora.com>


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-03-11  7:10 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-06 15:07 [PATCH] power: reset: reboot-mode: fix -Wformat-security warning Arnd Bergmann
2026-03-11  7:10 ` Sebastian Reichel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox