mirror-linux/drivers/net
Kees Cook bc044ae9d6 cxgb3: Avoid potential string truncation in desc
Builds with W=1 were warning about potential string truncations:

drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c: In function 'cxgb_up':
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:394:38: warning: '%d' directive output may be truncated writing between 1 and 11 bytes into a region of size between 5 and 20 [-Wformat-truncation=]
  394 |                                  "%s-%d", d->name, pi->first_qset + i);
      |                                      ^~
In function 'name_msix_vecs',
    inlined from 'cxgb_up' at drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:1264:3: drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:394:34: note: directive argument in the range [-2147483641, 509]
  394 |                                  "%s-%d", d->name, pi->first_qset + i);
      |                                  ^~~~~~~
drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c:393:25: note: 'snprintf' output between 3 and 28 bytes into a destination of size 21
  393 |                         snprintf(adap->msix_info[msi_idx].desc, n,
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  394 |                                  "%s-%d", d->name, pi->first_qset + i);
      |                                  ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Avoid open-coded %NUL-termination (this code was assuming snprintf
wasn't %NUL terminating when it does -- likely thinking of strncpy),
and grow the size of the string to handle a maximal value.

Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/oe-kbuild-all/202312100937.ZPZCARhB-lkp@intel.com/
Cc: Raju Rangoju <rajur@chelsio.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20231212220954.work.219-kees@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2023-12-13 18:32:01 -08:00
..
arcnet arcnet: restoring support for multiple Sohard Arcnet cards 2023-12-04 18:01:20 -08:00
bonding
caif
can
dsa net: dsa: realtek: Rewrite RTL8366RB MTU handling 2023-12-12 14:17:06 +01:00
ethernet cxgb3: Avoid potential string truncation in desc 2023-12-13 18:32:01 -08:00
fddi
fjes net: fjes: Convert to platform remove callback returning void 2023-12-05 19:51:09 -08:00
hamradio
hippi
hyperv net: Convert some ethtool_sprintf() to ethtool_puts() 2023-12-08 10:56:25 +00:00
ieee802154
ipa net: ipa: Convert to platform remove callback returning void 2023-12-05 19:51:09 -08:00
ipvlan ipvlan: implement .parse_protocol hook function in ipvlan_header_ops 2023-12-05 13:42:08 +01:00
mctp
mdio net: mdio-gpio: replace deprecated strncpy with strscpy 2023-12-12 16:00:02 -08:00
netdevsim
pcs net: pcs: rzn1-miic: Convert to platform remove callback returning void 2023-12-05 19:51:09 -08:00
phy net: phy: Add support for the DP83TG720S Ethernet PHY 2023-12-13 18:01:08 -08:00
plip
ppp
pse-pd
slip
team
thunderbolt
usb Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-12-07 17:53:17 -08:00
vmxnet3 net: Convert some ethtool_sprintf() to ethtool_puts() 2023-12-08 10:56:25 +00:00
vxlan
wan Immutable tag for the PEF2256 framer 2023-12-12 15:14:38 -08:00
wireguard
wireless Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2023-11-30 16:11:19 -08:00
wwan net: wwan: qcom_bam_dmux: Convert to platform remove callback returning void 2023-12-05 19:54:44 -08:00
xen-netback
Kconfig virtio-net: support rx netdim 2023-12-13 12:49:05 +00:00
LICENSE.SRC
Makefile
Space.c
amt.c
bareudp.c
dummy.c
eql.c
geneve.c
gtp.c
ifb.c
loopback.c
macsec.c
macvlan.c macvlan: implement .parse_protocol hook function in macvlan_hard_header_ops 2023-12-05 13:41:48 +01:00
macvtap.c
mdio.c
mhi_net.c
mii.c
net_failover.c
netconsole.c
netkit.c
nlmon.c
ntb_netdev.c
rionet.c
sb1000.c
sungem_phy.c
tap.c
tun.c
veth.c net: veth: fix packet segmentation in veth_convert_skb_to_xdp_buff 2023-12-05 19:24:26 -08:00
virtio_net.c virtio-net: support rx netdim 2023-12-13 12:49:05 +00:00
vrf.c
vsockmon.c
xen-netfront.c