3
0
Fork 0
forked from mirrors/linux
kernel/net/bridge/netfilter
Justin Stitt 544dded8cb netfilter: nf_tables: replace deprecated strncpy with strscpy_pad
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>
Reviewed-by: Simon Horman <horms@kernel.org>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
2024-10-15 17:29:51 +02:00
..
ebt_802_3.c
ebt_among.c
ebt_arp.c
ebt_arpreply.c
ebt_dnat.c
ebt_ip.c
ebt_ip6.c
ebt_limit.c netfilter: allow to turn off xtables compat layer 2021-04-26 18:16:56 +02:00
ebt_log.c
ebt_mark.c netfilter: allow to turn off xtables compat layer 2021-04-26 18:16:56 +02:00
ebt_mark_m.c netfilter: allow to turn off xtables compat layer 2021-04-26 18:16:56 +02:00
ebt_nflog.c
ebt_pkttype.c
ebt_redirect.c
ebt_snat.c
ebt_stp.c
ebt_vlan.c
ebtable_broute.c netfilter: add missing module descriptions 2023-11-08 13:52:32 +01:00
ebtable_filter.c netfilter: add missing module descriptions 2023-11-08 13:52:32 +01:00
ebtable_nat.c netfilter: add missing module descriptions 2023-11-08 13:52:32 +01:00
ebtables.c netfilter: Use kmemdup_array instead of kmemdup for multiple allocation 2024-09-03 10:47:16 +02:00
Kconfig netfilter: Make legacy configs user selectable 2024-10-15 10:00:24 +02:00
Makefile netfilter: ebtables: allow xtables-nft only builds 2024-01-29 15:43:21 +01:00
nf_conntrack_bridge.c net: Rename mono_delivery_time to tstamp_type for scalabilty 2024-05-23 14:14:23 -07:00
nft_meta_bridge.c netfilter: nf_tables: replace deprecated strncpy with strscpy_pad 2024-10-15 17:29:51 +02:00
nft_reject_bridge.c netfilter: nf_tables: drop unused 3rd argument from validate callback ops 2024-09-03 10:47:17 +02:00