linux-stable/drivers/net/ethernet/i825xx
Kees Cook 4bea747f3f net/sun3_82586: Avoid reading past buffer in debug output
Since NUM_XMIT_BUFFS is always 1, building m68k with sun3_defconfig and
-Warraybounds, this build warning is visible[1]:

drivers/net/ethernet/i825xx/sun3_82586.c: In function 'sun3_82586_timeout':
drivers/net/ethernet/i825xx/sun3_82586.c:990:122: warning: array subscript 1 is above array bounds of 'volatile struct transmit_cmd_struct *[1]' [-Warray-bounds=]
  990 |                 printk("%s: command-stats: %04x %04x\n",dev->name,swab16(p->xmit_cmds[0]->cmd_status),swab16(p->xmit_cmds[1]->cmd_status));
      |                                                                                                               ~~~~~~~~~~~~^~~
...
drivers/net/ethernet/i825xx/sun3_82586.c:156:46: note: while referencing 'xmit_cmds'
  156 |         volatile struct transmit_cmd_struct *xmit_cmds[NUM_XMIT_BUFFS];

Avoid accessing index 1 since it doesn't exist.

Link: https://github.com/KSPP/linux/issues/325 [1]
Cc: Sam Creasey <sammy@sammy.net>
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Simon Horman <horms@kernel.org>
Tested-by: Simon Horman <horms@kernel.org> # build-tested
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20240206161651.work.876-kees@kernel.org
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
2024-02-08 18:41:10 -08:00
..
82596.c net: ethernet: i825xx: Replace unversioned GPL (GPL 1.0) notice with SPDX identifier 2023-05-16 15:38:07 +02:00
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile
ether1.c ethernet: i825xx: don't write directly to netdev->dev_addr 2022-01-26 15:40:01 +00:00
ether1.h
lasi_82596.c net: ethernet: i825xx: Replace unversioned GPL (GPL 1.0) notice with SPDX identifier 2023-05-16 15:38:07 +02:00
lib82596.c net: ethernet: i825xx: Replace unversioned GPL (GPL 1.0) notice with SPDX identifier 2023-05-16 15:38:07 +02:00
sni_82596.c net: ethernet: i825xx: Convert to platform remove callback returning void 2023-09-20 09:06:38 +01:00
sun3_82586.c net/sun3_82586: Avoid reading past buffer in debug output 2024-02-08 18:41:10 -08:00
sun3_82586.h net: ethernet: i825xx: sun3_8256: Add SPDX license identifier 2023-05-16 15:38:07 +02:00