linux/drivers/net/ethernet
Kees Cook 1c7ab9cd98 net: chelsio: cxgb4: Avoid potential negative array offset
Using min_t(int, ...) as a potential array index implies to the compiler
that negative offsets should be allowed. This is not the case, though.
Replace "int" with "unsigned int". Fixes the following warning exposed
under future CONFIG_FORTIFY_SOURCE improvements:

In file included from include/linux/string.h:253,
                 from include/linux/bitmap.h:11,
                 from include/linux/cpumask.h:12,
                 from include/linux/smp.h:13,
                 from include/linux/lockdep.h:14,
                 from include/linux/rcupdate.h:29,
                 from include/linux/rculist.h:11,
                 from include/linux/pid.h:5,
                 from include/linux/sched.h:14,
                 from include/linux/delay.h:23,
                 from drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:35:
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c: In function 't4_get_raw_vpd_params':
include/linux/fortify-string.h:46:33: warning: '__builtin_memcpy' pointer overflow between offset 29 and size [2147483648, 4294967295] [-Warray-bounds]
   46 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
include/linux/fortify-string.h:388:9: note: in expansion of macro '__underlying_memcpy'
  388 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
include/linux/fortify-string.h:433:26: note: in expansion of macro '__fortify_memcpy_chk'
  433 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:2796:9: note: in expansion of macro 'memcpy'
 2796 |         memcpy(p->id, vpd + id, min_t(int, id_len, ID_LEN));
      |         ^~~~~~
include/linux/fortify-string.h:46:33: warning: '__builtin_memcpy' pointer overflow between offset 0 and size [2147483648, 4294967295] [-Warray-bounds]
   46 | #define __underlying_memcpy     __builtin_memcpy
      |                                 ^
include/linux/fortify-string.h:388:9: note: in expansion of macro '__underlying_memcpy'
  388 |         __underlying_##op(p, q, __fortify_size);                        \
      |         ^~~~~~~~~~~~~
include/linux/fortify-string.h:433:26: note: in expansion of macro '__fortify_memcpy_chk'
  433 | #define memcpy(p, q, s)  __fortify_memcpy_chk(p, q, s,                  \
      |                          ^~~~~~~~~~~~~~~~~~~~
drivers/net/ethernet/chelsio/cxgb4/t4_hw.c:2798:9: note: in expansion of macro 'memcpy'
 2798 |         memcpy(p->sn, vpd + sn, min_t(int, sn_len, SERNUM_LEN));
      |         ^~~~~~

Additionally remove needless cast from u8[] to char * in last strim()
call.

Reported-by: kernel test robot <lkp@intel.com>
Link: https://lore.kernel.org/lkml/202205031926.FVP7epJM-lkp@intel.com
Fixes: fc9279298e ("cxgb4: Search VPD with pci_vpd_find_ro_info_keyword()")
Fixes: 24c521f81c ("cxgb4: Use pci_vpd_find_id_string() to find VPD ID string")
Cc: Raju Rangoju <rajur@chelsio.com>
Cc: Eric Dumazet <edumazet@google.com>
Cc: Paolo Abeni <pabeni@redhat.com>
Signed-off-by: Kees Cook <keescook@chromium.org>
Link: https://lore.kernel.org/r/20220505233101.1224230-1-keescook@chromium.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2022-05-06 15:41:27 -07:00
..
3com
8390
actions
adaptec
aeroflex
agere
alacritech
allwinner
alteon
altera
amazon
amd
apm drivers: net: xgene: Fix regression in CRC stripping 2022-03-23 10:30:05 -07:00
apple
aquantia net: atlantic: invert deep par in pm functions, preventing null derefs 2022-04-18 13:34:36 +01:00
arc
asix
atheros atl1c: remove redundant assignment to variable size 2022-03-18 14:16:47 -07:00
broadcom bnxt_en: Fix unnecessary dropping of RX packets 2022-05-03 17:41:32 -07:00
brocade
cadence net: macb: Restart tx only if queue pointer is lagging 2022-04-11 18:18:07 -07:00
calxeda
cavium pci_irq_vector() can't be used in atomic context any longer. This conflicts 2022-05-01 17:02:23 +01:00
chelsio net: chelsio: cxgb4: Avoid potential negative array offset 2022-05-06 15:41:27 -07:00
cirrus
cisco
cortina
davicom
dec
dlink
emulex
engleder
ezchip
faraday net: ftgmac100: access hardware register after clock ready 2022-04-13 12:43:55 +01:00
freescale net: enetc: allow tc-etf offload even with NETIF_F_CSUM_MASK 2022-04-28 09:45:48 -07:00
fujitsu
fungible net/fungible: Fix reference to __udivdi3 on 32b builds 2022-04-01 21:32:30 -07:00
google gve: Fix spelling mistake "droping" -> "dropping" 2022-03-16 19:29:00 -07:00
hisilicon net: hns: Add missing fwnode_handle_put in hns_mac_init 2022-04-25 11:06:53 +01:00
huawei hinic: fix bug of wq out of bound access 2022-04-29 18:37:45 -07:00
i825xx Networking changes for 5.18. 2022-03-24 13:13:26 -07:00
ibm Revert "ibmvnic: Add ethtool private flag for driver-defined queue limits" 2022-04-28 09:46:18 -07:00
intel ixgbe: ensure IPsec VF<->PF compatibility 2022-04-28 09:40:02 -07:00
litex
marvell net: ethernet: mv643xx: Fix over zealous checking of_get_mac_address() 2022-04-05 18:12:55 -07:00
mediatek net: ethernet: mediatek: add missing of_node_put() in mtk_sgmii_init() 2022-04-29 17:57:12 -07:00
mellanox net/mlx5: Fix matching on inner TTC 2022-05-04 00:00:07 -07:00
micrel net: micrel: Fix KS8851 Kconfig 2022-04-05 17:32:05 -07:00
microchip net: lan966x: fix a couple off by one bugs 2022-04-25 11:25:37 +01:00
microsoft
moxa
mscc net: mscc: ocelot: avoid corrupting hardware counters when moving VCAP filters 2022-05-05 19:15:17 -07:00
myricom myri10ge: fix an incorrect free for skb in myri10ge_sw_tso 2022-04-06 15:29:18 +01:00
natsemi
neterion
netronome devlink: hold the instance lock during eswitch_mode callbacks 2022-03-21 14:11:38 +00:00
ni
nvidia
nxp
oki-semi
packetengines
pasemi
pensando
qlogic qede: confirm skb is allocated before using 2022-04-06 15:16:23 +01:00
qualcomm
rdc
realtek r8169: improve driver unload and system shutdown behavior on DASH-enabled systems 2022-03-17 16:47:32 -07:00
renesas
rocker
samsung
seeq
sfc net: sfc: fix using uninitialized xdp tx_queue 2022-04-06 13:50:17 +01:00
sgi
silan
sis
smsc smsc911x: allow using IRQ0 2022-05-03 16:57:33 -07:00
socionext
stmicro net: stmmac: disable Split Header (SPH) for Intel platforms 2022-05-01 13:20:03 +01:00
sun ethernet: sun: Fix spelling mistake "mis-matched" -> "mismatched" 2022-03-17 16:36:05 -07:00
synopsys
tehuti
ti net: cpsw: add missing of_node_put() in cpsw_probe_dt() 2022-04-30 13:37:20 +01:00
toshiba
tundra
vertexcom
via
wiznet
xilinx net: emaclite: Add error handling for of_address_to_resource() 2022-05-03 11:07:32 +02:00
xircom
xscale
dnet.c
dnet.h
ec_bhf.c
ethoc.c
fealnx.c
jme.c
jme.h
Kconfig net: restore alpha order to Ethernet devices in config 2022-04-15 11:56:16 +01:00
korina.c
lantiq_etop.c
lantiq_xrx200.c
Makefile