* [PATCH] mm/damon/sysfs-schemes: avoid Wformat-security warning
@ 2025-03-10 13:51 Arnd Bergmann
2025-03-10 16:17 ` SeongJae Park
0 siblings, 1 reply; 3+ messages in thread
From: Arnd Bergmann @ 2025-03-10 13:51 UTC (permalink / raw)
To: SeongJae Park, Andrew Morton
Cc: Arnd Bergmann, Hyeongtak Ji, Honggyu Kim, Usama Arif, damon,
linux-mm, linux-kernel
From: Arnd Bergmann <arnd@arndb.de>
This warning is for potentially user-defined format strings:
mm/damon/sysfs-schemes.c:1664:4: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
1664 | name);
Change this to use "%s" as the format and the name as the argument.
Fixes: 92bc039dd72e ("mm/damon/sysfs-schemes: let damon_sysfs_scheme_set_filters() be used for different named directories")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
mm/damon/sysfs-schemes.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
index 50e6907515e6..23ac98dd6451 100644
--- a/mm/damon/sysfs-schemes.c
+++ b/mm/damon/sysfs-schemes.c
@@ -1661,7 +1661,7 @@ static int damon_sysfs_scheme_set_filters(struct damon_sysfs_scheme *scheme,
return -ENOMEM;
err = kobject_init_and_add(&filters->kobj,
&damon_sysfs_scheme_filters_ktype, &scheme->kobj,
- name);
+ "%s", name);
if (err)
kobject_put(&filters->kobj);
else
--
2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon/sysfs-schemes: avoid Wformat-security warning
2025-03-10 13:51 [PATCH] mm/damon/sysfs-schemes: avoid Wformat-security warning Arnd Bergmann
@ 2025-03-10 16:17 ` SeongJae Park
2025-03-10 16:53 ` SeongJae Park
0 siblings, 1 reply; 3+ messages in thread
From: SeongJae Park @ 2025-03-10 16:17 UTC (permalink / raw)
To: Arnd Bergmann
Cc: SeongJae Park, Andrew Morton, Arnd Bergmann, Hyeongtak Ji,
Honggyu Kim, Usama Arif, damon, linux-mm, linux-kernel
On Mon, 10 Mar 2025 14:51:37 +0100 Arnd Bergmann <arnd@kernel.org> wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> This warning is for potentially user-defined format strings:
>
> mm/damon/sysfs-schemes.c:1664:4: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
> 1664 | name);
>
> Change this to use "%s" as the format and the name as the argument.
Thank you for this patch!
>
> Fixes: 92bc039dd72e ("mm/damon/sysfs-schemes: let damon_sysfs_scheme_set_filters() be used for different named directories")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: SeongJae Park <sj@kernel.org>
Thanks,
SJ
> ---
> mm/damon/sysfs-schemes.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/mm/damon/sysfs-schemes.c b/mm/damon/sysfs-schemes.c
> index 50e6907515e6..23ac98dd6451 100644
> --- a/mm/damon/sysfs-schemes.c
> +++ b/mm/damon/sysfs-schemes.c
> @@ -1661,7 +1661,7 @@ static int damon_sysfs_scheme_set_filters(struct damon_sysfs_scheme *scheme,
> return -ENOMEM;
> err = kobject_init_and_add(&filters->kobj,
> &damon_sysfs_scheme_filters_ktype, &scheme->kobj,
> - name);
> + "%s", name);
> if (err)
> kobject_put(&filters->kobj);
> else
> --
> 2.39.5
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] mm/damon/sysfs-schemes: avoid Wformat-security warning
2025-03-10 16:17 ` SeongJae Park
@ 2025-03-10 16:53 ` SeongJae Park
0 siblings, 0 replies; 3+ messages in thread
From: SeongJae Park @ 2025-03-10 16:53 UTC (permalink / raw)
To: SeongJae Park
Cc: Arnd Bergmann, Andrew Morton, Arnd Bergmann, Hyeongtak Ji,
Honggyu Kim, Usama Arif, damon, linux-mm, linux-kernel
On Mon, 10 Mar 2025 09:17:58 -0700 SeongJae Park <sj@kernel.org> wrote:
> On Mon, 10 Mar 2025 14:51:37 +0100 Arnd Bergmann <arnd@kernel.org> wrote:
>
> > From: Arnd Bergmann <arnd@arndb.de>
> >
> > This warning is for potentially user-defined format strings:
> >
> > mm/damon/sysfs-schemes.c:1664:4: error: format string is not a string literal (potentially insecure) [-Werror,-Wformat-security]
> > 1664 | name);
> >
> > Change this to use "%s" as the format and the name as the argument.
>
> Thank you for this patch!
I also found there is another similar issue and sent another patch[1] for that.
Thank you again for sharing the issue.
[1] https://lore.kernel.org/20250310165009.652491-1-sj@kernel.org
Thanks,
SJ
[...]
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-03-10 16:53 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 13:51 [PATCH] mm/damon/sysfs-schemes: avoid Wformat-security warning Arnd Bergmann
2025-03-10 16:17 ` SeongJae Park
2025-03-10 16:53 ` SeongJae Park
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox