public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpiolib: avoid format string weakness in workqueue interface
@ 2024-10-28 14:21 Arnd Bergmann
  2024-10-31 12:43 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Arnd Bergmann @ 2024-10-28 14:21 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Nathan Chancellor,
	Kent Gibson
  Cc: Arnd Bergmann, Nick Desaulniers, Bill Wendling, Justin Stitt,
	Andy Shevchenko, linux-gpio, linux-kernel, llvm

From: Arnd Bergmann <arnd@arndb.de>

Using a string literal as a format string is a possible bug when the
string contains '%' characters:

drivers/gpio/gpiolib-cdev.c:2813:48: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
 2813 |         gdev->line_state_wq = alloc_ordered_workqueue(dev_name(&gdev->dev),
      |                                                       ^~~~~~~~~~~~~~~~~~~~
drivers/gpio/gpiolib-cdev.c:2813:48: note: treat the string as an argument to avoid this
 2813 |         gdev->line_state_wq = alloc_ordered_workqueue(dev_name(&gdev->dev),
      |                                                       ^
      |                                                       "%s",

Do as clang suggests and use a trivial "%s" format string.

Fixes: 7b9b77a8bba9 ("gpiolib: add a per-gpio_device line state notification workqueue")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/gpio/gpiolib-cdev.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-cdev.c b/drivers/gpio/gpiolib-cdev.c
index 0ec162b0ea04..088201de9627 100644
--- a/drivers/gpio/gpiolib-cdev.c
+++ b/drivers/gpio/gpiolib-cdev.c
@@ -2810,8 +2810,8 @@ int gpiolib_cdev_register(struct gpio_device *gdev, dev_t devt)
 	gdev->chrdev.owner = THIS_MODULE;
 	gdev->dev.devt = MKDEV(MAJOR(devt), gdev->id);
 
-	gdev->line_state_wq = alloc_ordered_workqueue(dev_name(&gdev->dev),
-						      WQ_HIGHPRI);
+	gdev->line_state_wq = alloc_ordered_workqueue("%s", WQ_HIGHPRI,
+						      dev_name(&gdev->dev));
 	if (!gdev->line_state_wq)
 		return -ENOMEM;
 
-- 
2.39.5


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

* Re: [PATCH] gpiolib: avoid format string weakness in workqueue interface
  2024-10-28 14:21 [PATCH] gpiolib: avoid format string weakness in workqueue interface Arnd Bergmann
@ 2024-10-31 12:43 ` Bartosz Golaszewski
  0 siblings, 0 replies; 2+ messages in thread
From: Bartosz Golaszewski @ 2024-10-31 12:43 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij, Nathan Chancellor,
	Kent Gibson, Arnd Bergmann
  Cc: Bartosz Golaszewski, Arnd Bergmann, Nick Desaulniers,
	Bill Wendling, Justin Stitt, Andy Shevchenko, linux-gpio,
	linux-kernel, llvm

From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>


On Mon, 28 Oct 2024 14:21:46 +0000, Arnd Bergmann wrote:
> Using a string literal as a format string is a possible bug when the
> string contains '%' characters:
> 
> drivers/gpio/gpiolib-cdev.c:2813:48: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
>  2813 |         gdev->line_state_wq = alloc_ordered_workqueue(dev_name(&gdev->dev),
>       |                                                       ^~~~~~~~~~~~~~~~~~~~
> drivers/gpio/gpiolib-cdev.c:2813:48: note: treat the string as an argument to avoid this
>  2813 |         gdev->line_state_wq = alloc_ordered_workqueue(dev_name(&gdev->dev),
>       |                                                       ^
>       |                                                       "%s",
> 
> [...]

Applied, thanks!

[1/1] gpiolib: avoid format string weakness in workqueue interface
      commit: a22c9dc26d6fc522357b73858b13e29c58f49d64

Best regards,
-- 
Bartosz Golaszewski <bartosz.golaszewski@linaro.org>

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

end of thread, other threads:[~2024-10-31 12:43 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-28 14:21 [PATCH] gpiolib: avoid format string weakness in workqueue interface Arnd Bergmann
2024-10-31 12:43 ` Bartosz Golaszewski

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