public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string
@ 2025-06-10  9:34 Arnd Bergmann
  2025-06-10 17:20 ` srinivas pandruvada
  2025-06-13  8:48 ` Ilpo Järvinen
  0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2025-06-10  9:34 UTC (permalink / raw)
  To: Srinivas Pandruvada, Hans de Goede, Ilpo Järvinen
  Cc: Arnd Bergmann, Tero Kristo, Peter Zijlstra, platform-driver-x86,
	linux-kernel

From: Arnd Bergmann <arnd@arndb.de>

Using a string variable in place of a format string causes a W=1 build warning:

drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
   61 |                 length += sysfs_emit_at(buf, length, agent_name[agent]);
      |                                                      ^~~~~~~~~~~~~~~~~

Use the safer "%s" format string to print it instead.

Fixes: b98fa870fce2 ("platform/x86/intel-uncore-freq: Add attributes to show agent types")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
 .../x86/intel/uncore-frequency/uncore-frequency-common.c        | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
index 0f8aea18275b..65897fae17df 100644
--- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
+++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c
@@ -58,7 +58,7 @@ static ssize_t show_agent_types(struct kobject *kobj, struct kobj_attribute *att
 		if (length)
 			length += sysfs_emit_at(buf, length, " ");
 
-		length += sysfs_emit_at(buf, length, agent_name[agent]);
+		length += sysfs_emit_at(buf, length, "%s", agent_name[agent]);
 	}
 
 	length += sysfs_emit_at(buf, length, "\n");
-- 
2.39.5


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

* Re: [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string
  2025-06-10  9:34 [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string Arnd Bergmann
@ 2025-06-10 17:20 ` srinivas pandruvada
  2025-06-13  8:48 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: srinivas pandruvada @ 2025-06-10 17:20 UTC (permalink / raw)
  To: Arnd Bergmann, Hans de Goede, Ilpo Järvinen
  Cc: Arnd Bergmann, Tero Kristo, Peter Zijlstra, platform-driver-x86,
	linux-kernel

On Tue, 2025-06-10 at 11:34 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
> 
> Using a string variable in place of a format string causes a W=1
> build warning:
> 
I am not able to reproduce with W=1 with gcc 15.1.1 20250521 (Red Hat
15.1.1-2).

$touch drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
common.c
$ make -j128 W=1
  DESCEND objtool
  CALL    scripts/checksyscalls.sh
  INSTALL libsubcmd_headers
.pylintrc: warning: ignored by one of the .gitignore files
  CC [M]  drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
common.o
  LD [M]  drivers/platform/x86/intel/uncore-frequency/intel-uncore-
frequency-common.o


But verified the change:

Tested-by: Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>

Thanks,
Srinivas

> drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c:61:40: error: format string is not a string literal
> (potentially insecure) [-Werror,-Wformat-security]
>    61 |                 length += sysfs_emit_at(buf, length,
> agent_name[agent]);
>       |                                                     
> ^~~~~~~~~~~~~~~~~
> 
> Use the safer "%s" format string to print it instead.
> 
> Fixes: b98fa870fce2 ("platform/x86/intel-uncore-freq: Add attributes
> to show agent types")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
> ---
>  .../x86/intel/uncore-frequency/uncore-frequency-common.c        | 2
> +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/x86/intel/uncore-frequency/uncore-
> frequency-common.c b/drivers/platform/x86/intel/uncore-
> frequency/uncore-frequency-common.c
> index 0f8aea18275b..65897fae17df 100644
> --- a/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> +++ b/drivers/platform/x86/intel/uncore-frequency/uncore-frequency-
> common.c
> @@ -58,7 +58,7 @@ static ssize_t show_agent_types(struct kobject
> *kobj, struct kobj_attribute *att
>  		if (length)
>  			length += sysfs_emit_at(buf, length, " ");
>  
> -		length += sysfs_emit_at(buf, length,
> agent_name[agent]);
> +		length += sysfs_emit_at(buf, length, "%s",
> agent_name[agent]);
>  	}
>  
>  	length += sysfs_emit_at(buf, length, "\n");

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

* Re: [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string
  2025-06-10  9:34 [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string Arnd Bergmann
  2025-06-10 17:20 ` srinivas pandruvada
@ 2025-06-13  8:48 ` Ilpo Järvinen
  1 sibling, 0 replies; 3+ messages in thread
From: Ilpo Järvinen @ 2025-06-13  8:48 UTC (permalink / raw)
  To: Srinivas Pandruvada, Hans de Goede, Arnd Bergmann
  Cc: Arnd Bergmann, Tero Kristo, Peter Zijlstra, platform-driver-x86,
	linux-kernel

On Tue, 10 Jun 2025 11:34:55 +0200, Arnd Bergmann wrote:

> Using a string variable in place of a format string causes a W=1 build warning:
> 
> drivers/platform/x86/intel/uncore-frequency/uncore-frequency-common.c:61:40: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
>    61 |                 length += sysfs_emit_at(buf, length, agent_name[agent]);
>       |                                                      ^~~~~~~~~~~~~~~~~
> 
> Use the safer "%s" format string to print it instead.
> 
> [...]


Thank you for your contribution, it has been applied to my local
review-ilpo-fixes branch. Note it will show up in the public
platform-drivers-x86/review-ilpo-fixes branch only once I've pushed my
local branch there, which might take a while.

The list of commits applied:
[1/1] platform/x86/intel-uncore-freq: avoid non-literal format string
      commit: 0c44b46f51a17baa7ab67de1464427116e9c4eaa

--
 i.


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

end of thread, other threads:[~2025-06-13  8:48 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-10  9:34 [PATCH] platform/x86/intel-uncore-freq: avoid non-literal format string Arnd Bergmann
2025-06-10 17:20 ` srinivas pandruvada
2025-06-13  8:48 ` Ilpo Järvinen

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