1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/ethernet/chelsio/cxgb4
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
..
clip_tbl.c cxgb4: clip_tbl: use list_del_init instead of list_del/INIT_LIST_HEAD 2021-05-18 13:43:37 -07:00
clip_tbl.h chelsio: Replace zero-length array with flexible-array member 2020-02-24 15:26:17 -08:00
cudbg_common.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 2019-06-05 17:36:38 +02:00
cudbg_entity.h cxgb4: collect serial config version from register 2021-02-10 15:05:40 -08:00
cudbg_if.h cxgb4: add support to read serial flash 2020-06-18 20:49:55 -07:00
cudbg_lib.c Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-04-09 20:48:35 -07:00
cudbg_lib.h cxgb4: move device dump arrays in header to C file 2020-06-23 20:55:44 -07:00
cudbg_lib_common.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 2019-06-05 17:36:38 +02:00
cudbg_zlib.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 2019-06-05 17:36:38 +02:00
cudbg_zlib.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 2019-06-05 17:36:38 +02:00
cxgb4.h ethernet: chelsio: use eth_hw_addr_set() 2021-10-02 14:18:25 +01:00
cxgb4_cudbg.c cxgb4: remove unneeded if-null-free check 2021-04-09 16:47:41 -07:00
cxgb4_cudbg.h cxgb4: add support to read serial flash 2020-06-18 20:49:55 -07:00
cxgb4_dcb.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 291 2019-06-05 17:36:38 +02:00
cxgb4_dcb.h cxgb4: move DCB version extern to header file 2020-06-23 15:18:48 -07:00
cxgb4_debugfs.c Merge https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2020-11-12 16:54:48 -08:00
cxgb4_debugfs.h chelsio: Replace zero-length array with flexible-array member 2020-02-24 15:26:17 -08:00
cxgb4_ethtool.c cxgb4: allow reading unrecognized port module eeprom 2021-11-24 17:27:07 -08:00
cxgb4_fcoe.c cxgb4/chtls: Prefix adapter flags with CXGB4 2019-03-04 10:21:32 -08:00
cxgb4_fcoe.h
cxgb4_filter.c cxgb4: make the array match_all_mac static, makes object smaller 2021-08-02 15:01:26 -07:00
cxgb4_filter.h cxgb4: add skeleton for ethtool n-tuple filters 2020-06-19 13:17:31 -07:00
cxgb4_main.c cxgb4: Remove useless DMA-32 fallback configuration 2022-01-09 16:52:20 -08:00
cxgb4_mps.c cxgb4: fix memory leak during module unload 2020-09-17 16:29:20 -07:00
cxgb4_ptp.c net: chelsio: cxgb4: Fix wrong function name in comments 2021-05-17 14:12:38 -07:00
cxgb4_ptp.h
cxgb4_tc_flower.c cxgb4: fix regression with HASH tc prio value update 2021-06-03 15:12:42 -07:00
cxgb4_tc_flower.h cxgb4: handle 4-tuple PEDIT to NAT mode translation 2020-10-14 18:20:37 -07:00
cxgb4_tc_matchall.c flow_offload: reject offload for all drivers with invalid police parameters 2022-02-28 11:12:20 +00:00
cxgb4_tc_matchall.h cxgb4: add TC-MATCHALL IPv6 support 2020-08-03 18:17:08 -07:00
cxgb4_tc_mqprio.c cxgb4: avoid link re-train during TC-MQPRIO configuration 2021-06-04 14:45:13 -07:00
cxgb4_tc_mqprio.h cxgb4: add EOTID tracking and software context dump 2020-05-15 10:54:07 -07:00
cxgb4_tc_u32.c cxgb4: remove unneeded if-null-free check 2021-04-09 16:47:41 -07:00
cxgb4_tc_u32.h
cxgb4_tc_u32_parse.h cxgb4: parse TC-U32 key values and masks natively 2020-06-23 15:18:47 -07:00
cxgb4_thermal.c cxgb4: fix thermal zone device registration 2020-08-31 12:27:23 -07:00
cxgb4_uld.c cxgb4: fix IRQ free race during driver unload 2021-07-08 13:34:13 -07:00
cxgb4_uld.h cxgb4/chtls/cxgbit: Keeping the max ofld immediate data size same in cxgb4 and ulds 2021-02-15 12:39:33 -08:00
l2t.c treewide: Use fallthrough pseudo-keyword 2020-08-23 17:36:59 -05:00
l2t.h cxgb4/chcr: Save tx keys and handle HW response 2020-03-08 21:16:23 -07:00
Makefile cxgb4: add TC-MATCHALL classifier egress offload 2019-11-20 12:05:23 -08:00
sched.c cxgb4: update kernel-doc line comments 2020-06-23 15:18:48 -07:00
sched.h chelsio: Replace zero-length array with flexible-array member 2020-02-24 15:26:17 -08:00
sge.c cxgb4: Use struct_group() for memcpy() region 2021-11-19 11:17:09 +00:00
smt.c cxgb4: use eth_zero_addr() to clear mac address 2020-07-23 11:49:12 -07:00
smt.h chelsio: Replace zero-length array with flexible-array member 2020-02-24 15:26:17 -08:00
srq.c cxgb4/chtls: Prefix adapter flags with CXGB4 2019-03-04 10:21:32 -08:00
srq.h cxgb4: Add support to initialise/read SRQ entries 2018-03-22 11:59:11 -04:00
t4_chip_type.h cxgb4: clean up init_one 2018-05-25 14:59:38 -04:00
t4_hw.c net: chelsio: cxgb4: Avoid potential negative array offset 2022-05-06 15:41:27 -07:00
t4_hw.h cxgb4: fix eeprom len when diagnostics not implemented 2021-11-11 11:42:13 +00:00
t4_msg.h iw_cxgb4: Use memset_startat() for cpl_t5_pass_accept_rpl 2021-12-14 20:21:22 -04:00
t4_pci_id_tbl.h cxgb4: Add new T6 PCI device id 0x6092 2021-02-04 18:09:23 -08:00
t4_regs.h cxgb4: collect serial config version from register 2021-02-10 15:05:40 -08:00
t4_tcb.h cxgb4/chtls: Fix tid stuck due to wrong update of qid 2021-01-13 19:40:05 -08:00
t4_values.h cxgb4/cxgb4vf: Add support for SGE doorbell queue timer 2019-02-14 12:39:35 -05:00
t4fw_api.h cxgb4: Use struct_group() for memcpy() region 2021-11-19 11:17:09 +00:00
t4fw_version.h cxgb4: Update 1.23.3.0 as the latest firmware supported. 2019-03-29 13:47:31 -07:00