netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Justin Stitt <justinstitt@google.com>
To: Pablo Neira Ayuso <pablo@netfilter.org>,
	Jozsef Kadlecsik <kadlec@netfilter.org>,
	 Florian Westphal <fw@strlen.de>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	 Jakub Kicinski <kuba@kernel.org>,
	Paolo Abeni <pabeni@redhat.com>
Cc: linux-hardening@vger.kernel.org,
	Kees Cook <keescook@chromium.org>,
	 netfilter-devel@vger.kernel.org, coreteam@netfilter.org,
	 netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Justin Stitt <justinstitt@google.com>
Subject: [PATCH v2 0/7] netfilter: refactor deprecated strncpy
Date: Wed, 09 Aug 2023 01:06:03 +0000	[thread overview]
Message-ID: <20230809-net-netfilter-v2-0-5847d707ec0a@google.com> (raw)

`strncpy` is deprecated for use on NUL-terminated destination strings [1].

A suitable replacement is `strscpy` or `strscpy_pad` [2] due to the fact
that they guarantee NUL-termination on their destination buffer argument
which is _not_ the case for `strncpy`!

This series of patches aims to swap out `strncpy` for more a robust and
less ambiguous interface `strscpy_pad` . This patch series, if applied
in its entirety, removes most if not all instances of `strncpy` in the
`net/netfilter` directory.

[1]: www.kernel.org/doc/html/latest/process/deprecated.html#strncpy-on-nul-terminated-strings
[2]: https://manpages.debian.org/testing/linux-manual-4.8/strscpy.9.en.html

Link: https://github.com/KSPP/linux/issues/90
Related: commit 8556bceb9c40 ("netfilter: move from strlcpy with unused retval to strscpy")
---
Changes in v2:
- use `strscpy_pad` instead of `strscpy` since zero-padding is needed
  (thanks Florian and Kees)
- Link to v1: https://lore.kernel.org/r/20230808-net-netfilter-v1-0-efbbe4ec60af@google.com

---
Justin Stitt (7):
      netfilter: ipset: refactor deprecated strncpy
      netfilter: nf_tables: refactor deprecated strncpy
      netfilter: nf_tables: refactor deprecated strncpy
      netfilter: nft_meta: refactor deprecated strncpy
      netfilter: nft_osf: refactor deprecated strncpy
      netfilter: x_tables: refactor deprecated strncpy
      netfilter: xtables: refactor deprecated strncpy

 net/netfilter/ipset/ip_set_core.c | 10 +++++-----
 net/netfilter/nft_ct.c            |  2 +-
 net/netfilter/nft_fib.c           |  2 +-
 net/netfilter/nft_meta.c          |  6 +++---
 net/netfilter/nft_osf.c           |  6 +++---
 net/netfilter/x_tables.c          |  5 ++---
 net/netfilter/xt_repldata.h       |  2 +-
 7 files changed, 16 insertions(+), 17 deletions(-)
---
base-commit: 14f9643dc90adea074a0ffb7a17d337eafc6a5cc
change-id: 20230807-net-netfilter-4027219bb6e7

Best regards,
--
Justin Stitt <justinstitt@google.com>


             reply	other threads:[~2023-08-09  1:07 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-09  1:06 Justin Stitt [this message]
2023-08-09  1:06 ` [PATCH v2 1/7] netfilter: ipset: refactor deprecated strncpy Justin Stitt
2023-08-09 20:19   ` Florian Westphal
2023-08-09 21:40     ` Justin Stitt
2023-08-09 21:54       ` Jan Engelhardt
2023-08-10 19:07         ` Kees Cook
2023-08-09 21:58       ` Florian Westphal
2023-08-09 22:47         ` Justin Stitt
2023-08-09  1:06 ` [PATCH v2 2/7] netfilter: nf_tables: " Justin Stitt
2023-08-09  1:06 ` [PATCH v2 3/7] " Justin Stitt
2023-08-09  1:06 ` [PATCH v2 4/7] netfilter: nft_meta: " Justin Stitt
2023-08-09  1:06 ` [PATCH v2 5/7] netfilter: nft_osf: " Justin Stitt
2023-08-09 20:21   ` Florian Westphal
2023-08-09  1:06 ` [PATCH v2 6/7] netfilter: x_tables: " Justin Stitt
2023-08-09 20:20   ` Florian Westphal
2023-08-09  1:06 ` [PATCH v2 7/7] netfilter: xtables: " Justin Stitt
2023-08-09 20:20   ` Florian Westphal

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=20230809-net-netfilter-v2-0-5847d707ec0a@google.com \
    --to=justinstitt@google.com \
    --cc=coreteam@netfilter.org \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=fw@strlen.de \
    --cc=kadlec@netfilter.org \
    --cc=keescook@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-hardening@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=netfilter-devel@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=pablo@netfilter.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;
as well as URLs for NNTP newsgroup(s).