mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Helge Deller <deller@gmx.de>
To: Nick Desaulniers <ndesaulniers@google.com>
Cc: linux-fbdev@vger.kernel.org,
	dri-devel <dri-devel@lists.freedesktop.org>,
	clang-built-linux <llvm@lists.linux.dev>,
	LKML <linux-kernel@vger.kernel.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Nathan Chancellor <nathan@kernel.org>
Subject: Re: truncation in drivers/video/fbdev/neofb.c
Date: Tue, 29 Aug 2023 19:11:25 +0200	[thread overview]
Message-ID: <9d2bb495-0c1d-0d1b-96ea-4b1110d45b79@gmx.de> (raw)
In-Reply-To: <CAKwvOdn0xoVWjQ6ufM_rojtKb0f1i1hW-J_xYGfKDNFdHwaeHQ@mail.gmail.com>

On 8/29/23 18:45, Nick Desaulniers wrote:
> Helge,
> A recent change in clang made it better about spotting snprintf that
> will result in truncation.  Nathan reported the following instances:
>
> drivers/video/fbdev/neofb.c:1959:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 17 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1963:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 18 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1967:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 17 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1971:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 17 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1978:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 18 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1985:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 17 [-Wfortify-source]
> drivers/video/fbdev/neofb.c:1992:3: warning: 'snprintf' will always be
> truncated; specified size is 16, but format string expands to at least
> 18 [-Wfortify-source]
>
> https://github.com/ClangBuiltLinux/linux/issues/1923
>
> Clang is right here.  `info->fix.id` is declared as `char id[16];` so
> indeed string literals like "MagicGraph 256AV+" indeed lead to
> truncation. But this is declared in include/uapi/linux/fb.h; I assume
> those headers cant be changed? Can the strings be shortened then? Is
> it perhaps time to delete this driver?
>
> I see AKPM mentioned alluded to this in
> commit 0e90454 ("neofb: avoid overwriting fb_info fields")
>
> (Also, snprintf probably isn't necessary for string literals that
> don't contain format strings)

It's just an ID field, so I don't think we need the full name of the card.
So using strscpy() and shorten the name, e.g. "MagicGr. 256XL+"
instead of "MagicGraph 256XL+" is probably the most simple solution?

Anyone want to send a patch?

Helge

  reply	other threads:[~2023-08-29 17:12 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-29 16:45 Nick Desaulniers
2023-08-29 17:11 ` Helge Deller [this message]
2023-08-31 21:23   ` Helge Deller
2023-08-31 21:41     ` Nick Desaulniers
2023-08-31 22:15       ` Helge Deller
2023-08-31 22:26         ` Nick Desaulniers

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=9d2bb495-0c1d-0d1b-96ea-4b1110d45b79@gmx.de \
    --to=deller@gmx.de \
    --cc=akpm@linux-foundation.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=linux-fbdev@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=llvm@lists.linux.dev \
    --cc=nathan@kernel.org \
    --cc=ndesaulniers@google.com \
    /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

all inboxes | Powered by JetHome®