From: Simon Horman <horms@kernel•org>
To: Justin Stitt <justinstitt@google•com>
Cc: Pablo Neira Ayuso <pablo@netfilter•org>,
Jozsef Kadlecsik <kadlec@netfilter•org>,
Roopa Prabhu <roopa@nvidia•com>,
Nikolay Aleksandrov <razor@blackwall•org>,
"David S. Miller" <davem@davemloft•net>,
Eric Dumazet <edumazet@google•com>,
Jakub Kicinski <kuba@kernel•org>, Paolo Abeni <pabeni@redhat•com>,
netfilter-devel@vger•kernel.org, coreteam@netfilter•org,
bridge@lists•linux.dev, netdev@vger•kernel.org,
linux-kernel@vger•kernel.org, linux-hardening@vger•kernel.org,
Kees Cook <kees@kernel•org>
Subject: Re: [PATCH] netfilter: nf_tables: replace deprecated strncpy with strscpy_pad
Date: Fri, 13 Sep 2024 12:17:32 +0100 [thread overview]
Message-ID: <20240913111732.GV572255@kernel.org> (raw)
In-Reply-To: <20240909-strncpy-net-bridge-netfilter-nft_meta_bridge-c-v1-1-946180aa7909@google.com>
On Mon, Sep 09, 2024 at 03:48:39PM -0700, 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.
>
> In this particular instance, the usage of strncpy() is fine and works as
> expected. However, towards the goal of [2], we should consider replacing
> it with an alternative as many instances of strncpy() are bug-prone. Its
> removal from the kernel promotes better long term health for the
> codebase.
>
> The current usage of strncpy() likely just wants the NUL-padding
> behavior offered by strncpy() and doesn't care about the
> NUL-termination. Since the compiler doesn't know the size of @dest, we
> can't use strtomem_pad(). Instead, use strscpy_pad() which behaves
> functionally the same as strncpy() in this context -- as we expect
> br_dev->name to be NUL-terminated itself.
>
> Link: https://www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings [1]
> Link: https://github.com/KSPP/linux/issues/90 [2]
> Link: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html
> Cc: Kees Cook <keescook@chromium•org>
> Cc: linux-hardening@vger•kernel.org
> Signed-off-by: Justin Stitt <justinstitt@google•com>
> ---
> Note: build-tested only.
Reviewed-by: Simon Horman <horms@kernel•org>
next prev parent reply other threads:[~2024-09-13 11:17 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-09-09 22:48 [PATCH] netfilter: nf_tables: replace deprecated strncpy with strscpy_pad Justin Stitt
2024-09-13 11:17 ` Simon Horman [this message]
2024-10-04 11:14 ` Pablo Neira Ayuso
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=20240913111732.GV572255@kernel.org \
--to=horms@kernel$(echo .)org \
--cc=bridge@lists$(echo .)linux.dev \
--cc=coreteam@netfilter$(echo .)org \
--cc=davem@davemloft$(echo .)net \
--cc=edumazet@google$(echo .)com \
--cc=justinstitt@google$(echo .)com \
--cc=kadlec@netfilter$(echo .)org \
--cc=kees@kernel$(echo .)org \
--cc=kuba@kernel$(echo .)org \
--cc=linux-hardening@vger$(echo .)kernel.org \
--cc=linux-kernel@vger$(echo .)kernel.org \
--cc=netdev@vger$(echo .)kernel.org \
--cc=netfilter-devel@vger$(echo .)kernel.org \
--cc=pabeni@redhat$(echo .)com \
--cc=pablo@netfilter$(echo .)org \
--cc=razor@blackwall$(echo .)org \
--cc=roopa@nvidia$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
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