From: Luis Chamberlain <mcgrof@kernel.org>
To: Justin Stitt <justinstitt@google.com>
Cc: Nathan Chancellor <nathan@kernel.org>,
Nick Desaulniers <ndesaulniers@google.com>,
Bill Wendling <morbo@google.com>,
linux-modules@vger.kernel.org, linux-kernel@vger.kernel.org,
llvm@lists.linux.dev, linux-hardening@vger.kernel.org
Subject: Re: [PATCH] kallsyms: replace deprecated strncpy with strscpy
Date: Fri, 12 Apr 2024 13:20:43 -0700 [thread overview]
Message-ID: <ZhmXm4xVMY5QPEGn@bombadil.infradead.org> (raw)
In-Reply-To: <20240412-strncpy-kernel-module-kallsyms-c-v1-1-ba3f0fc16163@google.com>
On Fri, Apr 12, 2024 at 06:53:47PM +0000, Justin Stitt wrote:
> strncpy() is deprecated for use on NUL-terminated destination strings
> [1] and as such we should prefer more robust and less ambiguous string
> interfaces. The goal is to remove its use completely [2].
>
> namebuf is eventually cleaned of any trailing llvm suffixes using
> strstr(). This hints that namebuf should be NUL-terminated.
>
> static void cleanup_symbol_name(char *s)
> {
> char *res;
> ...
> res = strstr(s, ".llvm.");
> ...
> }
>
> Due to this, use strscpy() over strncpy() as it guarantees
> NUL-termination on the destination buffer. Drop the -1 from the length
> calculation as it is no longer needed to ensure NUL-termination.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
> Link: https://github.com/KSPP/linux/issues/90 [2]
> Cc: linux-hardening@vger.kernel.org
> Signed-off-by: Justin Stitt <justinstitt@google.com>
Thanks! Queued up on modules-next.
Luis
prev parent reply other threads:[~2024-04-12 20:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-12 18:53 [PATCH] kallsyms: replace deprecated strncpy with strscpy Justin Stitt
2024-04-12 20:20 ` Luis Chamberlain [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=ZhmXm4xVMY5QPEGn@bombadil.infradead.org \
--to=mcgrof@kernel.org \
--cc=justinstitt@google.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-modules@vger.kernel.org \
--cc=llvm@lists.linux.dev \
--cc=morbo@google.com \
--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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).