From: Arnd Bergmann Date: Tue, 28 May 2024 13:32:36 +0000 (+0200) Subject: drm/xe: replace format-less snprintf() with strscpy() X-Git-Tag: v6.11-rc1~141^2~26^2~26 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=9bbfab1c7cf7801e50b131ccf04af8d32b01dcec;p=thirdparty%2Flinux.git drm/xe: replace format-less snprintf() with strscpy() 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: b10d0c5e9df7 ("drm/xe: Add process name to devcoredump") Signed-off-by: Arnd Bergmann Reviewed-by: Thomas Hellström Signed-off-by: Thomas Hellström Link: https://patchwork.freedesktop.org/patch/msgid/20240528133251.2310868-1-arnd@kernel.org --- diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c b/drivers/gpu/drm/xe/xe_devcoredump.c index 1643d44f8bc42..1973bfaece40d 100644 --- a/drivers/gpu/drm/xe/xe_devcoredump.c +++ b/drivers/gpu/drm/xe/xe_devcoredump.c @@ -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);