1
0
Fork 0
mirror of synced 2025-03-06 20:59:54 +01:00
linux/drivers/net/wireless/rsi
Zekun Shen f1cb3476e4 rsi: Fix out-of-bounds read in rsi_read_pkt()
rsi_get_* functions rely on an offset variable from usb
input. The size of usb input is RSI_MAX_RX_USB_PKT_SIZE(3000),
while 2-byte offset can be up to 0xFFFF. Thus a large offset
can cause out-of-bounds read.

The patch adds a bound checking condition when rcv_pkt_len is 0,
indicating it's USB. It's unclear whether this is triggerable
from other type of bus. The following check might help in that case.
offset > rcv_pkt_len - FRAME_DESC_SZ

The bug is trigerrable with conpromised/malfunctioning USB devices.
I tested the patch with the crashing input and got no more bug report.

Attached is the KASAN report from fuzzing.

BUG: KASAN: slab-out-of-bounds in rsi_read_pkt+0x42e/0x500 [rsi_91x]
Read of size 2 at addr ffff888019439fdb by task RX-Thread/227

CPU: 0 PID: 227 Comm: RX-Thread Not tainted 5.6.0 #66
Call Trace:
 dump_stack+0x76/0xa0
 print_address_description.constprop.0+0x16/0x200
 ? rsi_read_pkt+0x42e/0x500 [rsi_91x]
 ? rsi_read_pkt+0x42e/0x500 [rsi_91x]
 __kasan_report.cold+0x37/0x7c
 ? rsi_read_pkt+0x42e/0x500 [rsi_91x]
 kasan_report+0xe/0x20
 rsi_read_pkt+0x42e/0x500 [rsi_91x]
 rsi_usb_rx_thread+0x1b1/0x2fc [rsi_usb]
 ? rsi_probe+0x16a0/0x16a0 [rsi_usb]
 ? _raw_spin_lock_irqsave+0x7b/0xd0
 ? _raw_spin_trylock_bh+0x120/0x120
 ? __wake_up_common+0x10b/0x520
 ? rsi_probe+0x16a0/0x16a0 [rsi_usb]
 kthread+0x2b5/0x3b0
 ? kthread_create_on_node+0xd0/0xd0
 ret_from_fork+0x22/0x40

Reported-by: Brendan Dolan-Gavitt <brendandg@nyu.edu>
Signed-off-by: Zekun Shen <bruceshenzk@gmail.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/YXxXS4wgu2OsmlVv@10-18-43-117.dynapool.wireless.nyu.edu
2021-11-29 12:43:54 +02:00
..
Kconfig treewide: replace '---help---' in Kconfig files with 'help' 2020-06-14 01:57:21 +09:00
Makefile rsi: add coex support 2018-03-13 18:36:57 +02:00
rsi_91x_coex.c rsi: File headers are not suitable for kernel-doc 2020-09-01 12:20:17 +03:00
rsi_91x_core.c rsi: fix key enabled check causing unwanted encryption for vap_id > 0 2021-09-21 08:42:37 +03:00
rsi_91x_debugfs.c rsi: make array fsm_state static const, makes object smaller 2021-08-29 11:32:01 +03:00
rsi_91x_hal.c rsi: fix rate mask set leading to P2P failure 2021-09-21 08:42:37 +03:00
rsi_91x_mac80211.c rsi: fix rate mask set leading to P2P failure 2021-09-21 08:42:37 +03:00
rsi_91x_main.c rsi: Fix out-of-bounds read in rsi_read_pkt() 2021-11-29 12:43:54 +02:00
rsi_91x_mgmt.c rsi: fix rate mask set leading to P2P failure 2021-09-21 08:42:37 +03:00
rsi_91x_ps.c rsi: remove unused including <linux/version.h> 2021-04-13 14:51:41 -07:00
rsi_91x_sdio.c rsi: Fix module dev_oper_mode parameter description 2021-09-21 18:03:48 +03:00
rsi_91x_sdio_ops.c rsi: Clean up loop in the interrupt handler 2020-11-10 20:55:06 +02:00
rsi_91x_usb.c rsi: Fix out-of-bounds read in rsi_read_pkt() 2021-11-29 12:43:54 +02:00
rsi_91x_usb_ops.c rsi: rsi_91x_usb_ops: Source file headers are not good candidates for kernel-doc 2020-11-07 18:02:49 +02:00
rsi_boot_params.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_coex.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_common.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_debugfs.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_hal.h rsi: Fix module dev_oper_mode parameter description 2021-09-21 18:03:48 +03:00
rsi_main.h rsi: fix rate mask set leading to P2P failure 2021-09-21 08:42:37 +03:00
rsi_mgmt.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_ps.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_sdio.h rsi: fix comment syntax in file headers 2021-04-18 09:27:35 +03:00
rsi_usb.h rsi: Fix out-of-bounds read in rsi_read_pkt() 2021-11-29 12:43:54 +02:00