From: Helge Deller <deller@gmx.de>
To: Ajith P V <ajithpv.linux@gmail.com>, FlorianSchandinat@gmx.de
Cc: linux-fbdev@vger.kernel.org, dri-devel@lists.freedesktop.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH v3] video: fbdev: via: refactor strcpy and viafb_name
Date: Tue, 18 Aug 2026 10:53:36 +0200 [thread overview]
Message-ID: <40410af6-5fbc-4b7e-826a-24d93e8e65c5@gmx.de> (raw)
In-Reply-To: <20260814074435.277441-1-ajithpv.linux@gmail.com>
On 8/14/26 09:44, Ajith P V wrote:
> Replace the deprecated and unbounded strcpy() function with the safer
> strscpy() alternative when setting up the framebuffer fixed screen
> information [1][2].
>
> It aligns this driver with the ongoing kernel-wide security initiative
> to eliminate unbounded string copies, hardening the code against future
> modifications.
>
> Additionally, convert the file-scope `viafb_name` pointer into a
> `static const char[]` array while preserving its original value "Via".
> This allows the compiler to execute compile-time bounds checking and
> optimize the string copy operation without breaking userspace ABI
> backward compatibility.
>
> This is a proactive API cleanup and there is no functional
> performance or truncation risk.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strcpy [1]
> Link: https://github.com/KSPP/linux/issues/88 [2]
>
> Signed-off-by: Ajith P V <ajithpv.linux@gmail.com>
> ---
> v3:
> - Restore the original "Via" string value to prevent userspace ABI
> regressions, while keeping the 'static const char[]' optimization as
> suggested by Sashiko AI.
> v2:
> - Keep variable static but change it to a const array
> 'static const char viafb_name[] = "viafb"' as suggested by Helge Deller
> to let the compiler leverage compile-time checks.
>
> drivers/video/fbdev/via/viafbdev.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c
> index 80f95dac32c8..f6823beb4d7e 100644
> --- a/drivers/video/fbdev/via/viafbdev.c
> +++ b/drivers/video/fbdev/via/viafbdev.c
> @@ -16,7 +16,7 @@
> #define _MASTER_FILE
> #include "global.h"
>
> -static char *viafb_name = "Via";
> +static const char viafb_name[] = "Via";
> static u32 pseudo_pal[17];
>
> /* video mode */
> @@ -144,7 +144,7 @@ static void viafb_setup_fixinfo(struct fb_fix_screeninfo *fix,
> struct viafb_par *viaparinfo)
> {
> memset(fix, 0, sizeof(struct fb_fix_screeninfo));
> - strcpy(fix->id, viafb_name);
> + strscpy(fix->id, viafb_name, sizeof(fix->id));
Please make it simple:
strcpy(fix->id, "Via");
Helge
prev parent reply other threads:[~2026-08-18 8:53 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-14 7:44 [PATCH v3] video: fbdev: via: refactor strcpy and viafb_name Ajith P V
2026-08-18 8:53 ` Helge Deller [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=40410af6-5fbc-4b7e-826a-24d93e8e65c5@gmx.de \
--to=deller@gmx.de \
--cc=FlorianSchandinat@gmx.de \
--cc=ajithpv.linux@gmail.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=linux-fbdev@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
/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