* [PATCH] dmaengine: avoid non-constant format string
@ 2024-07-19 10:23 Arnd Bergmann
2024-07-19 15:49 ` Dave Jiang
2024-08-29 17:30 ` Vinod Koul
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2024-07-19 10:23 UTC (permalink / raw)
To: Vinod Koul, Amelie Delaunay
Cc: Arnd Bergmann, Dave Jiang, Yajun Deng, dmaengine, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
Using an arbitrary string as a printf-style format can be a security
problem if that string contains % characters, as the optionalal
-Wformat-security flag points out:
drivers/dma/dmaengine.c: In function '__dma_async_device_channel_register':
drivers/dma/dmaengine.c:1073:17: error: format not a string literal and no format arguments [-Werror=format-security]
1073 | dev_set_name(&chan->dev->device, name);
| ^~~~~~~~~~~~
Change this newly added instance to use "%s" as the format instead to
pass the actual name.
Fixes: 10b8e0fd3f72 ("dmaengine: add channel device name to channel registration")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/dma/dmaengine.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index c380a4dda77a..c1357d7f3dc6 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1070,7 +1070,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
if (!name)
dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
else
- dev_set_name(&chan->dev->device, name);
+ dev_set_name(&chan->dev->device, "%s", name);
rc = device_register(&chan->dev->device);
if (rc)
goto err_out_ida;
--
2.39.2
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: avoid non-constant format string
2024-07-19 10:23 [PATCH] dmaengine: avoid non-constant format string Arnd Bergmann
@ 2024-07-19 15:49 ` Dave Jiang
2024-08-29 17:30 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Dave Jiang @ 2024-07-19 15:49 UTC (permalink / raw)
To: Arnd Bergmann, Vinod Koul, Amelie Delaunay
Cc: Arnd Bergmann, Yajun Deng, dmaengine, linux-kernel
On 7/19/24 3:23 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> Using an arbitrary string as a printf-style format can be a security
> problem if that string contains % characters, as the optionalal
> -Wformat-security flag points out:
>
> drivers/dma/dmaengine.c: In function '__dma_async_device_channel_register':
> drivers/dma/dmaengine.c:1073:17: error: format not a string literal and no format arguments [-Werror=format-security]
> 1073 | dev_set_name(&chan->dev->device, name);
> | ^~~~~~~~~~~~
>
> Change this newly added instance to use "%s" as the format instead to
> pass the actual name.
>
> Fixes: 10b8e0fd3f72 ("dmaengine: add channel device name to channel registration")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> ---
> drivers/dma/dmaengine.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
> index c380a4dda77a..c1357d7f3dc6 100644
> --- a/drivers/dma/dmaengine.c
> +++ b/drivers/dma/dmaengine.c
> @@ -1070,7 +1070,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
> if (!name)
> dev_set_name(&chan->dev->device, "dma%dchan%d", device->dev_id, chan->chan_id);
> else
> - dev_set_name(&chan->dev->device, name);
> + dev_set_name(&chan->dev->device, "%s", name);
> rc = device_register(&chan->dev->device);
> if (rc)
> goto err_out_ida;
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] dmaengine: avoid non-constant format string
2024-07-19 10:23 [PATCH] dmaengine: avoid non-constant format string Arnd Bergmann
2024-07-19 15:49 ` Dave Jiang
@ 2024-08-29 17:30 ` Vinod Koul
1 sibling, 0 replies; 3+ messages in thread
From: Vinod Koul @ 2024-08-29 17:30 UTC (permalink / raw)
To: Amelie Delaunay, Arnd Bergmann
Cc: Arnd Bergmann, Dave Jiang, Yajun Deng, dmaengine, linux-kernel
On Fri, 19 Jul 2024 12:23:12 +0200, Arnd Bergmann wrote:
> Using an arbitrary string as a printf-style format can be a security
> problem if that string contains % characters, as the optionalal
> -Wformat-security flag points out:
>
> drivers/dma/dmaengine.c: In function '__dma_async_device_channel_register':
> drivers/dma/dmaengine.c:1073:17: error: format not a string literal and no format arguments [-Werror=format-security]
> 1073 | dev_set_name(&chan->dev->device, name);
> | ^~~~~~~~~~~~
>
> [...]
Applied, thanks!
[1/1] dmaengine: avoid non-constant format string
commit: ae04342b5264fcf90a288a984a69ffb9e93904a7
Best regards,
--
~Vinod
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-08-29 17:30 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-07-19 10:23 [PATCH] dmaengine: avoid non-constant format string Arnd Bergmann
2024-07-19 15:49 ` Dave Jiang
2024-08-29 17:30 ` Vinod Koul
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox