Skip to content

Commit

Permalink
drm/xe: replace format-less snprintf() with strscpy()
Browse files Browse the repository at this point in the history
Using snprintf() with a format string from task->comm is a bit
dangerous since the string may be controlled by unprivileged
userspace:

drivers/gpu/drm/xe/xe_devcoredump.c: In function 'devcoredump_snapshot':
drivers/gpu/drm/xe/xe_devcoredump.c:184:9: error: format not a string literal and no format arguments [-Werror=format-security]
  184 |         snprintf(ss->process_name, sizeof(ss->process_name), process_name);
      |         ^~~~~~~~

In this case there is no reason for an snprintf(), so use a simpler
string copy.

Fixes: b10d0c5 ("drm/xe: Add process name to devcoredump")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Signed-off-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Link: https://patchwork.freedesktop.org/patch/msgid/20240528133251.2310868-1-arnd@kernel.org
  • Loading branch information
Arnd Bergmann authored and Thomas Hellström committed May 30, 2024
1 parent 264eecd commit 9bbfab1
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/gpu/drm/xe/xe_devcoredump.c
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ static void devcoredump_snapshot(struct xe_devcoredump *coredump,
if (task)
process_name = task->comm;
}
snprintf(ss->process_name, sizeof(ss->process_name), process_name);
strscpy(ss->process_name, process_name);
if (task)
put_task_struct(task);

Expand Down

0 comments on commit 9bbfab1

Please sign in to comment.