linux/drivers/net/ethernet
Guangshuo Li 278b7cfe0d e1000: fix OOB in e1000_tbi_should_accept()
commit 9c72a5182e upstream.

In e1000_tbi_should_accept() we read the last byte of the frame via
'data[length - 1]' to evaluate the TBI workaround. If the descriptor-
reported length is zero or larger than the actual RX buffer size, this
read goes out of bounds and can hit unrelated slab objects. The issue
is observed from the NAPI receive path (e1000_clean_rx_irq):

==================================================================
BUG: KASAN: slab-out-of-bounds in e1000_tbi_should_accept+0x610/0x790
Read of size 1 at addr ffff888014114e54 by task sshd/363

CPU: 0 PID: 363 Comm: sshd Not tainted 5.18.0-rc1 #1
Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS rel-1.12.0-59-gc9ba5276e321-prebuilt.qemu.org 04/01/2014
Call Trace:
 <IRQ>
 dump_stack_lvl+0x5a/0x74
 print_address_description+0x7b/0x440
 print_report+0x101/0x200
 kasan_report+0xc1/0xf0
 e1000_tbi_should_accept+0x610/0x790
 e1000_clean_rx_irq+0xa8c/0x1110
 e1000_clean+0xde2/0x3c10
 __napi_poll+0x98/0x380
 net_rx_action+0x491/0xa20
 __do_softirq+0x2c9/0x61d
 do_softirq+0xd1/0x120
 </IRQ>
 <TASK>
 __local_bh_enable_ip+0xfe/0x130
 ip_finish_output2+0x7d5/0xb00
 __ip_queue_xmit+0xe24/0x1ab0
 __tcp_transmit_skb+0x1bcb/0x3340
 tcp_write_xmit+0x175d/0x6bd0
 __tcp_push_pending_frames+0x7b/0x280
 tcp_sendmsg_locked+0x2e4f/0x32d0
 tcp_sendmsg+0x24/0x40
 sock_write_iter+0x322/0x430
 vfs_write+0x56c/0xa60
 ksys_write+0xd1/0x190
 do_syscall_64+0x43/0x90
 entry_SYSCALL_64_after_hwframe+0x44/0xae
RIP: 0033:0x7f511b476b10
Code: 73 01 c3 48 8b 0d 88 d3 2b 00 f7 d8 64 89 01 48 83 c8 ff c3 66 0f 1f 44 00 00 83 3d f9 2b 2c 00 00 75 10 b8 01 00 00 00 0f 05 <48> 3d 01 f0 ff ff 73 31 c3 48 83 ec 08 e8 8e 9b 01 00 48 89 04 24
RSP: 002b:00007ffc9211d4e8 EFLAGS: 00000246 ORIG_RAX: 0000000000000001
RAX: ffffffffffffffda RBX: 0000000000004024 RCX: 00007f511b476b10
RDX: 0000000000004024 RSI: 0000559a9385962c RDI: 0000000000000003
RBP: 0000559a9383a400 R08: fffffffffffffff0 R09: 0000000000004f00
R10: 0000000000000070 R11: 0000000000000246 R12: 0000000000000000
R13: 00007ffc9211d57f R14: 0000559a9347bde7 R15: 0000000000000003
 </TASK>
Allocated by task 1:
 __kasan_krealloc+0x131/0x1c0
 krealloc+0x90/0xc0
 add_sysfs_param+0xcb/0x8a0
 kernel_add_sysfs_param+0x81/0xd4
 param_sysfs_builtin+0x138/0x1a6
 param_sysfs_init+0x57/0x5b
 do_one_initcall+0x104/0x250
 do_initcall_level+0x102/0x132
 do_initcalls+0x46/0x74
 kernel_init_freeable+0x28f/0x393
 kernel_init+0x14/0x1a0
 ret_from_fork+0x22/0x30
The buggy address belongs to the object at ffff888014114000
 which belongs to the cache kmalloc-2k of size 2048
The buggy address is located 1620 bytes to the right of
 2048-byte region [ffff888014114000, ffff888014114800]
The buggy address belongs to the physical page:
page:ffffea0000504400 refcount:1 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x14110
head:ffffea0000504400 order:3 compound_mapcount:0 compound_pincount:0
flags: 0x100000000010200(slab|head|node=0|zone=1)
raw: 0100000000010200 0000000000000000 dead000000000001 ffff888013442000
raw: 0000000000000000 0000000000080008 00000001ffffffff 0000000000000000
page dumped because: kasan: bad access detected
==================================================================

This happens because the TBI check unconditionally dereferences the last
byte without validating the reported length first:

	u8 last_byte = *(data + length - 1);

Fix by rejecting the frame early if the length is zero, or if it exceeds
adapter->rx_buffer_len. This preserves the TBI workaround semantics for
valid frames and prevents touching memory beyond the RX buffer.

Fixes: 2037110c96 ("e1000: move tbi workaround code into helper function")
Cc: stable@vger.kernel.org
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
Reviewed-by: Simon Horman <horms@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
History 2026-01-19 13:10:03 +01:00
..
3com 3c589_cs: Fix an error handling path in tc589_probe() 2023-05-30 13:55:33 +01:00
8390 net:mcf8390: Use platform_get_irq() to get the interrupt 2022-04-08 14:22:47 +02:00
actions ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
adaptec ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
aeroflex net: ethernet: aeroflex: fix potential memory leak in greth_start_xmit_gbit() 2024-11-01 01:52:33 +01:00
agere et131x: Add missing check after DMA map 2025-08-28 16:24:20 +02:00
alacritech ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
allwinner ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
alteon ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
altera ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
amazon net: ena: return 0 in ena_get_rxfh_key_size() when RSS hash key is not configurable 2025-10-19 16:21:37 +02:00
amd amd-xgbe: Avoid spurious link down messages during interface toggle 2025-10-29 14:03:08 +01:00
apm net: xgene-v2: remove incorrect ACPI_PTR annotation 2025-06-04 14:38:00 +02:00
apple ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
aquantia net: atlantic: fix fragment overflow handling in RX path 2025-12-07 06:09:34 +09:00
arc net: arc: fix the device for dma_map_single/dma_unmap_single 2024-11-14 13:13:37 +01:00
atheros net: ag71xx: Add missing check after DMA map 2025-08-28 16:24:20 +02:00
broadcom broadcom: b44: prevent uninitialized value usage 2026-01-19 13:09:43 +01:00
brocade bna: adjust 'name' buf size of bna_tcb and bna_ccb structures 2024-08-19 05:44:59 +02:00
cadence net: macb: avoid dealing with endianness in macb_set_hwaddr() 2025-12-07 06:09:23 +09:00
calxeda ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
cavium net: liquidio: fix overflow in octeon_init_instr_queue() 2025-10-02 13:39:06 +02:00
chelsio minmax: add in_range() macro 2025-10-19 16:21:28 +02:00
cirrus net: cs89x0: disable compile testing on powerpc 2021-09-03 13:42:27 +01:00
cisco enic: fix incorrect MTU comparison in enic_change_mtu() 2025-07-10 15:57:46 +02:00
cortina net: ethernet: cortina: Drop TSO support 2024-10-17 15:11:48 +02:00
davicom net: davicom: fix UAF in dm9000_drv_remove 2025-03-13 12:50:12 +01:00
dec ethernet: tulip: fix missing pci_disable_device() on error in tulip_init_one() 2022-05-25 09:57:35 +02:00
dlink net: dlink: handle dma_map_single() failure properly 2025-10-29 14:03:07 +01:00
emulex be2net: pass wrb_params in case of OS2BMC 2025-12-07 06:09:30 +09:00
ezchip ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
faraday net: ftgmac100: Ensure tx descriptor updates are visible 2024-10-17 15:10:38 +02:00
freescale dpaa2-mac: bail if the dpmacs fwnode is not found 2026-01-19 13:09:19 +01:00
fujitsu Merge git://git.kernel.org/pub/scm/linux/kernel/git/netdev/net 2021-05-27 09:55:10 -07:00
google gve: Return error for unknown admin queue command 2025-08-28 16:24:22 +02:00
hisilicon net: hns3: add VLAN id validation before using 2026-01-19 13:09:45 +01:00
huawei net: hinic: Fix cleanup in create_rxqs/txqs() 2025-01-09 13:28:31 +01:00
i825xx net/sun3_82586: fix potential memory leak in sun3_82586_send_packet() 2024-11-01 01:52:36 +01:00
ibm net: ibm: emac: mal: fix wrong goto 2024-10-17 15:11:56 +02:00
intel e1000: fix OOB in e1000_tbi_should_accept() 2026-01-19 13:10:03 +01:00
litex ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
marvell octeontx2-pf: fix "UBSAN: shift-out-of-bounds error" 2026-01-19 13:09:57 +01:00
mediatek net: ethernet: mtk_eth_soc: fix tx vlan tag for llc packets 2025-09-09 18:50:19 +02:00
mellanox net/mlx5: fw_tracer, Handle escaped percent properly 2026-01-19 13:09:45 +01:00
micrel net: ks8851: Fix potential TX stall after interface reopen 2024-07-18 13:07:40 +02:00
microchip net: ethernet: microchip: sparx5: make it selectable for ARCH_LAN969X 2025-12-07 06:09:23 +09:00
microsoft net/mana: fix warning in the writer of client oob 2025-06-04 14:38:03 +02:00
moxa net: moxa: get rid of asymmetry in DMA mapping/unmapping 2022-08-31 17:16:39 +02:00
mscc ethernet: use eth_hw_addr_set() instead of ether_addr_copy() 2023-07-27 08:46:59 +02:00
myricom ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
natsemi net: natsemi: fix rx_dropped double accounting on netif_rx() failure 2025-10-02 13:39:06 +02:00
neterion ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
netronome nfp: fix RSS hash key size when RSS is not supported 2025-10-19 16:21:37 +02:00
ni nixge: fix mac address error handling again 2023-07-27 08:47:05 +02:00
nvidia eth: remove remaining copies of the NAPI_POLL_WEIGHT define 2023-10-19 23:05:39 +02:00
nxp ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
oki-semi net: pch_gbe: fix pci device refcount leak while module exiting 2022-12-02 17:41:05 +01:00
packetengines dev_ioctl: split out ndo_eth_ioctl 2021-07-27 20:11:45 +01:00
pasemi net: pasemi: Fix return type of pasemi_mac_start_tx() 2023-05-24 17:36:45 +01:00
pensando ionic: use ee->offset when returning sprom data 2025-01-09 13:28:31 +01:00
qlogic net: qede: Initialize qede_ll_ops with designated initializer 2025-12-07 06:09:32 +09:00
qualcomm qca_spi: Make driver probing reliable 2024-12-19 18:07:21 +01:00
rdc ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
realtek r8169: set EEE speed down ratio to 1 2025-12-07 06:09:23 +09:00
renesas net: sh_eth: Disable WoL if system can not suspend 2025-12-07 06:09:21 +09:00
rocker rocker: fix link status detection in rocker_carrier_init() 2024-12-14 19:51:40 +01:00
samsung net: sxgbe: fix potential NULL dereference in sxgbe_rx() 2025-12-07 06:09:34 +09:00
seeq net: seeq: Fix use after free vulnerability in ether3 Driver Due to Race Condition 2024-10-17 15:11:08 +02:00
sfc sfc: fix a double-free bug in efx_probe_filters 2024-01-15 18:51:15 +01:00
sgi dev_ioctl: split out ndo_eth_ioctl 2021-07-27 20:11:45 +01:00
silan net: silan: convert tasklets to use new tasklet_setup() API 2020-09-14 13:02:38 -07:00
sis ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
smsc smc91x: fix broken irq-context in PREEMPT_RT 2026-01-19 13:09:57 +01:00
socionext net: netsec: Ignore 'phy-mode' on SynQuacer in DT mode 2023-08-11 15:13:53 +02:00
stmicro net: stmmac: fix rx limit check in stmmac_rx_zc() 2026-01-19 13:09:36 +01:00
sun nui: Fix dma_mapping_error() check 2025-07-10 15:57:46 +02:00
synopsys ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
tehuti ethtool: extend coalesce setting uAPI with CQE mode 2021-08-24 07:38:29 -07:00
ti net: ethernet: ti: netcp: Standardize knav_dma_open_channel to return NULL on error 2025-12-07 06:09:32 +09:00
toshiba ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
tundra ethernet: tundra: free irq when alloc ring failed in tsi108_open() 2022-11-16 09:58:23 +01:00
via ethtool: extend coalesce setting uAPI with CQE mode 2021-08-24 07:38:29 -07:00
wiznet net: w5100: check return value after calling platform_get_resource() 2021-08-31 12:08:42 +01:00
xilinx net: emaclite: Fix missing pointer increment in aligned_read() 2025-08-28 16:24:01 +02:00
xircom xirc2ps_cs: fix register access when enabling FullDuplex 2025-09-09 18:50:18 +02:00
xscale ixp4xx_eth: fix error check return value of platform_get_irq() 2022-06-09 10:22:46 +02:00
dnet.c ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
dnet.h net/dnet: Delete static version from the driver 2020-03-03 17:54:55 -08:00
ec_bhf.c net: ec_bhf: switch from 'pci_' to 'dma_' API 2021-08-23 11:56:57 +01:00
ethoc.c ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
fealnx.c ethernet: constify references to netdev->dev_addr in drivers 2024-01-05 15:13:37 +01:00
jme.c net: ethernet: use ip_hdrlen() instead of bit shift 2024-10-17 15:10:32 +02:00
jme.h net: jme: Replace link-change tasklet with work 2021-03-17 16:33:58 +01:00
Kconfig net: restore alpha order to Ethernet devices in config 2022-04-27 14:38:53 +02:00
korina.c net: korina: handle clk prepare error in korina_probe() 2023-08-11 15:13:53 +02:00
lantiq_etop.c net: ethernet: lantiq_etop: fix memory disclosure 2024-10-17 15:11:20 +02:00
lantiq_xrx200.c ethernet: use of_get_ethdev_address() 2023-07-27 08:47:00 +02:00
Makefile net: Add driver for LiteX's LiteETH network interface 2021-08-26 12:13:52 +01:00