drm/amdkd: fix the warning for potential insecure string
Subsystems (3)
PATCH 1/2 drm/amdkd: fix the warning for potential insecure string
Below is the warning thrown by the clang compiler:linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:588:9: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
stats_dir_filename);
^~~~~~~~~~~~~~~~~~
linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:588:9: note: treat the string as an argument to avoid this
stats_dir_filename);
^
"%s",
linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:635:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
p->kobj, counters_dir_filename);
^~~~~~~~~~~~~~~~~~~~~
linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:635:18: note: treat the string as an argument to avoid this
p->kobj, counters_dir_filename);
^
"%s",--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_process.c +2 -2
@@ -585,7 +585,7 @@ static void kfd_procfs_add_sysfs_stats(struct kfd_process *p) ret =kobject_init_and_add (pdd->kobj_stats, &procfs_stats_type, p->kobj, - stats_dir_filename); +"%s" , stats_dir_filename);if (ret) { pr_warn("Creating KFD proc/stats_%s folder failed",
@@ -632,7 +632,7 @@ static void kfd_procfs_add_sysfs_counters(struct kfd_process *p)return ; ret =kobject_init_and_add (kobj_counters, &sysfs_counters_type, - p->kobj, counters_dir_filename); + p->kobj,"%s" , counters_dir_filename);if (ret) {pr_warn ("Creating KFD proc/%s folder failed" , counters_dir_filename);
Signature · 1 line
2.34.1
PATCH 2/2 drm/amdgpu: fix warning for potentially insecure string
linux/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2358:24: warning: format string is not a string literal (potentially insecure) [-Wformat-security]
sprintf(ring->name, amdgpu_sw_ring_name(i));
^~~~~~~~~~~~~~~~~~~~~~
linux/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2358:24: note: treat the string as an argument to avoid this
sprintf(ring->name, amdgpu_sw_ring_name(i));--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1 -1
@@ -2355,7 +2355,7 @@ static int gfx_v9_0_sw_init(struct amdgpu_ip_block *ip_block)for (i =0 ; i <GFX9_NUM_SW_GFX_RINGS ; i++) { ring = &adev->gfx.sw_gfx_ring[i]; ring->ring_obj =NULL ; -sprintf (ring->name,amdgpu_sw_ring_name (i)); +sprintf (ring->name,"%s" ,amdgpu_sw_ring_name (i)); ring->use_doorbell = true; ring->doorbell_index = adev->doorbell_index.gfx_ring0 <<1 ; ring->is_sw_ring = true;
Signature · 1 line
2.34.1
Christian König
maintainerRe: [PATCH v1 2/2] drm/amdgpu: fix warning for potentially insecure string
Quoted 16 lines · Sunil Khatri
linux/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2358:24: warning: format string is not a string literal (potentially insecure) [-Wformat-security]sprintf(ring->name, amdgpu_sw_ring_name(i)); ^~~~~~~~~~~~~~~~~~~~~~ linux/drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c:2358:24: note: treat the string as an argument to avoid this sprintf(ring->name, amdgpu_sw_ring_name(i));Signed-off-by Sunil Khatri <[email protected]>--- drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c static int gfx_v9_0_sw_init(struct amdgpu_ip_block *ip_block) · line 2358
Quoted 5 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +1
-1@@ -2355,7 +2355,7 @@ static int gfx_v9_0_sw_init(struct amdgpu_ip_block *ip_block)for (i =0 ; i <GFX9_NUM_SW_GFX_RINGS ; i++) { ring = &adev->gfx.sw_gfx_ring[i]; ring->ring_obj =NULL ; -sprintf (ring->name,amdgpu_sw_ring_name (i)); +sprintf (ring->name,"%s" ,amdgpu_sw_ring_name (i));
You could use strcpy here instead of sprintf.
Christian.
Quoted 3 lines
drivers/gpu/drm/amd/amdgpu/gfx_v9_0.c +0
-0ring->use_doorbell = true; ring->doorbell_index = adev->doorbell_index.gfx_ring0 <<1 ; ring->is_sw_ring = true;
Quoted 16 lines · Sunil Khatri
Below is the warning thrown by the clang compiler:
linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:588:9: warning: format string is not a string literal (potentially insecure) [-Wformat-security]stats_dir_filename); ^~~~~~~~~~~~~~~~~~ linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:588:9: note: treat the string as an argument to avoid this stats_dir_filename); ^ "%s", linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:635:18: warning: format string is not a string literal (potentially insecure) [-Wformat-security] p->kobj, counters_dir_filename); ^~~~~~~~~~~~~~~~~~~~~ linux/drivers/gpu/drm/amd/amdgpu/../amdkfd/kfd_process.c:635:18: note: treat the string as an argument to avoid this p->kobj, counters_dir_filename); ^ "%s",
Quoted 3 lines
Signed-off-by Sunil Khatri <[email protected]>CC Philip Yang <[email protected]>CC Felix Kuehling <[email protected]>
There is a typo in the subject (amdkd instead of amdkfd), but apart from that:
Quoted 26 lines
--- drivers/gpu/drm/amd/amdkfd/kfd_process.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/gpu/drm/amd/amdkfd/kfd_process.c +2
-2@@ -585,7 +585,7 @@ static void kfd_procfs_add_sysfs_stats(struct kfd_process *p) ret =kobject_init_and_add (pdd->kobj_stats, &procfs_stats_type, p->kobj, - stats_dir_filename); +"%s" , stats_dir_filename);if (ret) { pr_warn("Creating KFD proc/stats_%s folder failed",@@ -632,7 +632,7 @@ static void kfd_procfs_add_sysfs_counters(struct kfd_process *p)return ; ret =kobject_init_and_add (kobj_counters, &sysfs_counters_type, - p->kobj, counters_dir_filename); + p->kobj,"%s" , counters_dir_filename);if (ret) {pr_warn ("Creating KFD proc/%s folder failed" , counters_dir_filename);