[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <202309142129.46C1EAE2E2@keescook>
Date: Thu, 14 Sep 2023 21:30:43 -0700
From: Kees Cook <keescook@...omium.org>
To: Justin Stitt <justinstitt@...gle.com>
Cc: Maarten Lankhorst <maarten.lankhorst@...ux.intel.com>,
Maxime Ripard <mripard@...nel.org>,
Thomas Zimmermann <tzimmermann@...e.de>,
David Airlie <airlied@...il.com>,
Daniel Vetter <daniel@...ll.ch>,
dri-devel@...ts.freedesktop.org, linux-kernel@...r.kernel.org,
linux-hardening@...r.kernel.org, Xu Panda <xu.panda@....com.cn>
Subject: Re: [PATCH] drm/modes: refactor deprecated strncpy
On Thu, Sep 14, 2023 at 06:08:44PM +0000, Justin Stitt wrote:
> `strncpy` is deprecated for use on NUL-terminated destination strings [1].
>
> We should prefer more robust and less ambiguous string interfaces.
>
> A suitable replacement is `strscpy` [2] due to the fact that it guarantees
> NUL-termination on the destination buffer and doesn't incur the
> performance loss of unnecessarily NUL-padding.
How did you decide it didn't need %NUL padding?
I suspect it should have it, as I see what looks like full struct copies
happening in places:
struct drm_mode_modeinfo umode;
...
struct drm_property_blob *blob;
drm_mode_convert_to_umode(&umode, mode);
blob = drm_property_create_blob(crtc->dev,
sizeof(umode), &umode);
Can you send a v2 using strscpy_pad() instead?
Thanks!
-Kees
--
Kees Cook
Powered by blists - more mailing lists