linux/drivers/net
Justin Stitt a02527363a qed: replace uses of strncpy
strncpy() is deprecated for use on NUL-terminated destination strings
[1] and as such we should prefer more robust and less ambiguous string
interfaces.

This patch eliminates three uses of strncpy():

Firstly, `dest` is expected to be NUL-terminated which is evident by the
manual setting of a NUL-byte at size - 1. For this use specifically,
strscpy() is a viable replacement due to the fact that it guarantees
NUL-termination on the destination buffer.

The next two cases should simply be memcpy() as the size of the src
string is always 3 and the destination string just wants the first 3
bytes changed.

To be clear, there are no buffer overread bugs in the current code as
the sizes and offsets are carefully managed such that buffers are
NUL-terminated. However, with these changes, the code is now more robust
and less ambiguous (and hopefully easier to read).

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 [2]
Link: https://github.com/KSPP/linux/issues/90
Signed-off-by: Justin Stitt <justinstitt@google.com>
Reviewed-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231012-strncpy-drivers-net-ethernet-qlogic-qed-qed_debug-c-v2-1-16d2c0162b80@google.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-10-13 17:40:21 -07:00
..
arcnet net: arcnet: Do not call kfree_skb() under local_irq_disable() 2023-08-25 10:10:52 +01:00
bonding Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-08-24 10:51:39 -07:00
caif
can Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-10-12 17:07:34 -07:00
dsa net: dsa: vsc73xx: replace deprecated strncpy with ethtool_sprintf 2023-10-13 16:28:35 -07:00
ethernet qed: replace uses of strncpy 2023-10-13 17:40:21 -07:00
fddi
fjes netdev: replace napi_reschedule with napi_schedule 2023-10-11 17:28:06 -07:00
hamradio hamradio: baycom: remove useless link in Kconfig 2023-09-22 08:17:05 +01:00
hippi
hyperv hv_netvsc: fix netvsc_send_completion to avoid multiple message length checks 2023-10-11 09:19:01 +01:00
ieee802154 ieee802154: ca8210: Fix a potential UAF in ca8210_probe 2023-10-07 20:37:38 +02:00
ipa net: ipa: Annotate struct ipa_power with __counted_by 2023-10-02 11:24:54 -07:00
ipvlan
mctp
mdio net: mdio: xgene: Use device_get_match_data() 2023-10-13 10:15:05 +01:00
netdevsim
pcs net: pcs: xpcs: adapt Wangxun NICs for SGMII mode 2023-08-25 07:42:59 +01:00
phy net: phy: tja11xx: replace deprecated strncpy with ethtool_sprintf 2023-10-13 17:23:58 -07:00
plip
ppp net: implement lockless SO_PRIORITY 2023-10-01 19:09:54 +01:00
pse-pd
slip
team team: fix null-ptr-deref when team device type is changed 2023-09-19 16:28:37 +02:00
thunderbolt net: thunderbolt: Fix TCPv6 GSO checksum calculation 2023-09-15 13:45:05 +01:00
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-10-12 17:07:34 -07:00
vmxnet3
vxlan vxlan: vxlan_core: Support FDB flushing by destination IP 2023-10-13 10:00:32 +01:00
wan netdev: replace napi_reschedule with napi_schedule 2023-10-11 17:28:06 -07:00
wireguard
wireless netdev: use napi_schedule bool instead of napi_schedule_prep/__napi_schedule 2023-10-11 17:28:06 -07:00
wwan net: wwan: t7xx: Add __counted_by for struct t7xx_fsm_event and use struct_size() 2023-10-13 10:11:48 +01:00
xen-netback xen-netback: add software timestamp capabilities 2023-10-13 10:19:50 +01:00
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c udp: annotate data-races around udp->encap_type 2023-09-14 16:16:36 +02:00
ifb.c
Kconfig
LICENSE.SRC
loopback.c
macsec.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-10-12 17:07:34 -07:00
macvlan.c
macvtap.c
Makefile appletalk: remove ipddp driver 2023-10-10 17:49:00 -07:00
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c netconsole: Attach cmdline target to dynamic target 2023-10-13 17:26:38 -07:00
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
Space.c net: appletalk: remove cops support 2023-10-04 11:49:20 -07:00
sungem_phy.c
tap.c
tun.c
veth.c veth: Update XDP feature set when bringing up device 2023-09-12 16:32:56 +02:00
virtio_net.c virtio-net: a tiny comment update 2023-10-11 07:13:50 +01:00
vrf.c sysctl-6.6-rc1 2023-08-29 17:39:15 -07:00
vsockmon.c
xen-netfront.c