From: Kees Cook <kees@kernel.org>
To: Mariia Nikitash <nikitash.mariiaw@gmail.com>
Cc: nicolas.dufresne@collabora.com, benjamin.gaignard@collabora.com,
p.zabel@pengutronix.de, mchehab@kernel.org,
hverkuil+cisco@kernel.org, linux-media@vger.kernel.org,
linux-rockchip@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org, justinstitt@google.com,
morbo@google.com, david.laight.linux@gmail.com
Subject: Re: [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf()
Date: Thu, 12 Nov 2026 09:42:03 -0800 [thread overview]
Message-ID: <202611120937.C289DA9C4D@keescook> (raw)
In-Reply-To: <20261111032446.29803-1-nikitash.mariiaw@gmail.com>
On Tue, Nov 10, 2026 at 07:24:46PM -0800, Mariia Nikitash wrote:
> In preparation for removing the deprecated strlcat() API [1], replace the
> strscpy() and strlcat() calls in hantro_add_func() with a single
> scnprintf() call.
>
> This preserves the resulting string, including NUL termination
> and truncation behavior.
>
> Link: https://github.com/KSPP/linux/issues/370 [1]
> Signed-off-by: Mariia Nikitash <nikitash.mariiaw@gmail.com>
> ---
> Changes in v2:
> - Replace seq_buf with a single scnprintf() call, as suggested
> by Hans Verkuil.
Reviewed-by: Kees Cook <kees@kernel.org>
I think the Subject prefix is fine, it matches the prior poking of this
area:
b66215e7b780 ("media: verisilicon: replace snprintf with strscpy+strlcat")
For vfd->name,
struct video_device {
...
char name[64];
Does this need to be raised?
Because match->compatible is quite large:
struct of_device_id {
...
char compatible[128];
The real question remains: how should truncation of vfd->name (by
anything that constructs it) be handled?
-Kees
>
> drivers/media/platform/verisilicon/hantro_drv.c | 5 ++---
> 1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/media/platform/verisilicon/hantro_drv.c b/drivers/media/platform/verisilicon/hantro_drv.c
> index 26e5d5547466..d8854ceb4fed 100644
> --- a/drivers/media/platform/verisilicon/hantro_drv.c
> +++ b/drivers/media/platform/verisilicon/hantro_drv.c
> @@ -902,9 +902,8 @@ static int hantro_add_func(struct hantro_dev *vpu, unsigned int funcid)
> vfd->vfl_dir = VFL_DIR_M2M;
> vfd->device_caps = V4L2_CAP_STREAMING | V4L2_CAP_VIDEO_M2M_MPLANE;
> vfd->ioctl_ops = &hantro_ioctl_ops;
> - strscpy(vfd->name, match->compatible, sizeof(vfd->name));
> - strlcat(vfd->name, funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ?
> - "-enc" : "-dec", sizeof(vfd->name));
> + scnprintf(vfd->name, sizeof(vfd->name), "%s%s", match->compatible,
> + funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER ? "-enc" : "-dec");
>
> if (funcid == MEDIA_ENT_F_PROC_VIDEO_ENCODER) {
> vpu->encoder = func;
> --
> 2.43.0
>
--
Kees Cook
next prev parent reply other threads:[~2026-11-12 17:42 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-05 8:45 [PATCH] media: verisilicon: Replace strlcat() with seq_buf Mariia Nikitash
2026-11-08 20:08 ` David Laight
2026-11-10 10:13 ` Hans Verkuil
2026-11-10 18:27 ` Mariia Nikitash
2026-11-12 17:45 ` Kees Cook
2026-11-11 3:24 ` [PATCH v2] media: verisilicon: Replace strlcat() with scnprintf() Mariia Nikitash
2026-11-11 10:35 ` Alejandro Colomar
2026-11-11 22:04 ` Thorsten Blum
2026-11-12 17:42 ` Kees Cook [this message]
2026-11-11 23:27 ` [PATCH] media: verisilicon: Replace strlcat() with seq_buf Justin Stitt
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=202611120937.C289DA9C4D@keescook \
--to=kees@kernel.org \
--cc=benjamin.gaignard@collabora.com \
--cc=david.laight.linux@gmail.com \
--cc=hverkuil+cisco@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=linux-rockchip@lists.infradead.org \
--cc=mchehab@kernel.org \
--cc=morbo@google.com \
--cc=nicolas.dufresne@collabora.com \
--cc=nikitash.mariiaw@gmail.com \
--cc=p.zabel@pengutronix.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