mm/damon/sysfs-schemes: avoid Wformat-security warning
Subsystems (2)
PATCH 1/1 mm/damon/sysfs-schemes: avoid Wformat-security warning
From: Arnd Bergmann <[email protected]>
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.
--- mm/damon/sysfs-schemes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
mm/damon/sysfs-schemes.c +1 -1
@@ -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
Signature · 1 line
2.39.5
Quoted 8 lines · On Mon, 10 Mar 2025 14:51:37 +0100 Arnd Bergmann <[email protected]> wrote:
From: Arnd Bergmann <[email protected]>
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!
Quoted 3 lines
Fixes 92bc039dd72e ("mm/damon/sysfs-schemes: let damon_sysfs_scheme_set_filters() be used for different named directories")Signed-off-by Arnd Bergmann <[email protected]>
Thanks,
SJ
Quoted 19 lines
--- mm/damon/sysfs-schemes.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)mm/damon/sysfs-schemes.c +1
-1@@ -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 Signature · 1 line
2.39.5
SeongJae Park
maintainerQuoted 4 lines · On Mon, 10 Mar 2025 09:17:58 -0700 SeongJae Park <[email protected]> wrote:
Quoted 2 lines · On Mon, 10 Mar 2025 14:51:37 +0100 Arnd Bergmann <[email protected]> wrote:
From: Arnd Bergmann <[email protected]>
Quoted 8 lines
Quoted 6 lines
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/[email protected]
Thanks,
SJ
[...]