From: "Thomas Hellström" <thomas.hellstrom@linux.intel.com>
To: Arnd Bergmann <arnd@kernel.org>,
Lucas De Marchi <lucas.demarchi@intel.com>,
Oded Gabbay <ogabbay@kernel.org>
Cc: "Arnd Bergmann" <arnd@arndb.de>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Daniel Vetter" <daniel@ffwll.ch>,
"Rodrigo Vivi" <rodrigo.vivi@intel.com>,
"José Roberto de Souza" <jose.souza@intel.com>,
"Matthew Brost" <matthew.brost@intel.com>,
"Francois Dugast" <francois.dugast@intel.com>,
"Himal Prasad Ghimiray" <himal.prasad.ghimiray@intel.com>,
intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drm/xe: replace format-less snprintf() with strscpy()
Date: Tue, 28 May 2024 16:46:02 +0200 [thread overview]
Message-ID: <706e63abf12b9cf76d43cf67999cbb7baa06ebb0.camel@linux.intel.com> (raw)
In-Reply-To: <20240528133251.2310868-1-arnd@kernel.org>
On Tue, 2024-05-28 at 15:32 +0200, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> 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 <arnd@arndb.de>
Reviewed-by: Thomas Hellström <thomas.hellstrom@linux.intel.com>
Thanks,
Will pick up and apply as soon as our CI is fit for fight.
/Thomas
> ---
> drivers/gpu/drm/xe/xe_devcoredump.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_devcoredump.c
> b/drivers/gpu/drm/xe/xe_devcoredump.c
> index 1643d44f8bc4..1973bfaece40 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);
>
prev parent reply other threads:[~2024-05-28 14:46 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-28 13:32 [PATCH] drm/xe: replace format-less snprintf() with strscpy() Arnd Bergmann
2024-05-28 14:46 ` Thomas Hellström [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=706e63abf12b9cf76d43cf67999cbb7baa06ebb0.camel@linux.intel.com \
--to=thomas.hellstrom@linux.intel.com \
--cc=airlied@gmail.com \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=francois.dugast@intel.com \
--cc=himal.prasad.ghimiray@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=jose.souza@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=matthew.brost@intel.com \
--cc=mripard@kernel.org \
--cc=ogabbay@kernel.org \
--cc=rodrigo.vivi@intel.com \
--cc=tzimmermann@suse.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox