public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning
@ 2025-04-23 16:40 Arnd Bergmann
  2025-04-23 16:47 ` Jason Gunthorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Arnd Bergmann @ 2025-04-23 16:40 UTC (permalink / raw)
  To: Joerg Roedel, Will Deacon, Magnus Damm
  Cc: Arnd Bergmann, Robin Murphy, Jason Gunthorpe, Geert Uytterhoeven,
	Lu Baolu, Vasant Hegde, iommu, linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

iommu_device_sysfs_add() requires a constant format string, otherwise
a W=1 build produces a warning:

drivers/iommu/ipmmu-vmsa.c:1093:62: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
 1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
      |                                                                     ^~~~~~~~~~~~~~~~~~~~
drivers/iommu/ipmmu-vmsa.c:1093:62: note: treat the string as an argument to avoid this
 1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
      |                                                                     ^
      |                                                                     "%s",

This was an old bug but I saw it now because the code was changed as part
of commit d9d3cede4167 ("iommu/ipmmu-vmsa: Register in a sensible order").

Fixes: 7af9a5fdb9e0 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 drivers/iommu/ipmmu-vmsa.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/ipmmu-vmsa.c b/drivers/iommu/ipmmu-vmsa.c
index e424b279a8cd..90341b24a811 100644
--- a/drivers/iommu/ipmmu-vmsa.c
+++ b/drivers/iommu/ipmmu-vmsa.c
@@ -1090,7 +1090,8 @@ static int ipmmu_probe(struct platform_device *pdev)
 	if (mmu->features->has_cache_leaf_nodes && ipmmu_is_root(mmu))
 		return 0;
 
-	ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
+	ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, "%s",
+				     dev_name(&pdev->dev));
 	if (ret)
 		return ret;
 
-- 
2.39.5


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

* Re: [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning
  2025-04-23 16:40 [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning Arnd Bergmann
@ 2025-04-23 16:47 ` Jason Gunthorpe
  2025-04-24  7:34 ` Geert Uytterhoeven
  2025-04-28 11:20 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Jason Gunthorpe @ 2025-04-23 16:47 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Joerg Roedel, Will Deacon, Magnus Damm, Arnd Bergmann,
	Robin Murphy, Geert Uytterhoeven, Lu Baolu, Vasant Hegde, iommu,
	linux-kernel

On Wed, Apr 23, 2025 at 06:40:02PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> iommu_device_sysfs_add() requires a constant format string, otherwise
> a W=1 build produces a warning:
> 
> drivers/iommu/ipmmu-vmsa.c:1093:62: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^~~~~~~~~~~~~~~~~~~~
> drivers/iommu/ipmmu-vmsa.c:1093:62: note: treat the string as an argument to avoid this
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^
>       |                                                                     "%s",
> 
> This was an old bug but I saw it now because the code was changed as part
> of commit d9d3cede4167 ("iommu/ipmmu-vmsa: Register in a sensible order").
> 
> Fixes: 7af9a5fdb9e0 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason

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

* Re: [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning
  2025-04-23 16:40 [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning Arnd Bergmann
  2025-04-23 16:47 ` Jason Gunthorpe
@ 2025-04-24  7:34 ` Geert Uytterhoeven
  2025-04-28 11:20 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Geert Uytterhoeven @ 2025-04-24  7:34 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Joerg Roedel, Will Deacon, Magnus Damm, Arnd Bergmann,
	Robin Murphy, Jason Gunthorpe, Lu Baolu, Vasant Hegde, iommu,
	linux-kernel

On Wed, 23 Apr 2025 at 18:43, Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> iommu_device_sysfs_add() requires a constant format string, otherwise
> a W=1 build produces a warning:
>
> drivers/iommu/ipmmu-vmsa.c:1093:62: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^~~~~~~~~~~~~~~~~~~~
> drivers/iommu/ipmmu-vmsa.c:1093:62: note: treat the string as an argument to avoid this
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^
>       |                                                                     "%s",
>
> This was an old bug but I saw it now because the code was changed as part
> of commit d9d3cede4167 ("iommu/ipmmu-vmsa: Register in a sensible order").
>
> Fixes: 7af9a5fdb9e0 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>

Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

Gr{oetje,eeting}s,

                        Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning
  2025-04-23 16:40 [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning Arnd Bergmann
  2025-04-23 16:47 ` Jason Gunthorpe
  2025-04-24  7:34 ` Geert Uytterhoeven
@ 2025-04-28 11:20 ` Joerg Roedel
  2 siblings, 0 replies; 4+ messages in thread
From: Joerg Roedel @ 2025-04-28 11:20 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Will Deacon, Magnus Damm, Arnd Bergmann, Robin Murphy,
	Jason Gunthorpe, Geert Uytterhoeven, Lu Baolu, Vasant Hegde,
	iommu, linux-kernel

On Wed, Apr 23, 2025 at 06:40:02PM +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> iommu_device_sysfs_add() requires a constant format string, otherwise
> a W=1 build produces a warning:
> 
> drivers/iommu/ipmmu-vmsa.c:1093:62: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^~~~~~~~~~~~~~~~~~~~
> drivers/iommu/ipmmu-vmsa.c:1093:62: note: treat the string as an argument to avoid this
>  1093 |         ret = iommu_device_sysfs_add(&mmu->iommu, &pdev->dev, NULL, dev_name(&pdev->dev));
>       |                                                                     ^
>       |                                                                     "%s",
> 
> This was an old bug but I saw it now because the code was changed as part
> of commit d9d3cede4167 ("iommu/ipmmu-vmsa: Register in a sensible order").
> 
> Fixes: 7af9a5fdb9e0 ("iommu/ipmmu-vmsa: Use iommu_device_sysfs_add()/remove()")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  drivers/iommu/ipmmu-vmsa.c | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)

Applied, thanks.

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

end of thread, other threads:[~2025-04-28 11:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-04-23 16:40 [PATCH] iommu: ipmmu-vmsa: avoid Wformat-security warning Arnd Bergmann
2025-04-23 16:47 ` Jason Gunthorpe
2025-04-24  7:34 ` Geert Uytterhoeven
2025-04-28 11:20 ` Joerg Roedel

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