OrangePi_CM5/drivers/net/wireless/rsi
Zekun Shen ab523ea096 rsi: Fix out-of-bounds read in rsi_read_pkt()
[ Upstream commit f1cb3476e48b60c450ec3a1d7da0805bffc6e43a ]

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
Signed-off-by: Sasha Levin <sashal@kernel.org>
2022-01-27 10:54:13 +01:00
..
Kconfig
…
Makefile
…
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-11-18 14:03:47 +01:00
rsi_91x_debugfs.c rsi: Source file headers are not suitable for kernel-doc 2020-09-01 12:22:40 +03:00
rsi_91x_hal.c rsi: fix rate mask set leading to P2P failure 2021-11-18 14:03:47 +01:00
rsi_91x_mac80211.c rsi: fix rate mask set leading to P2P failure 2021-11-18 14:03:47 +01:00
rsi_91x_main.c rsi: Fix out-of-bounds read in rsi_read_pkt() 2022-01-27 10:54:13 +01:00
rsi_91x_mgmt.c rsi: fix rate mask set leading to P2P failure 2021-11-18 14:03:47 +01:00
rsi_91x_ps.c rsi: Source file headers do not make good kernel-doc candidates 2020-09-01 12:20:14 +03:00
rsi_91x_sdio.c rsi: Fix module dev_oper_mode parameter description 2021-11-18 14:03:47 +01:00
rsi_91x_sdio_ops.c rsi: Move card interrupt handling to RX thread 2021-03-07 12:34:08 +01:00
rsi_91x_usb.c rsi: Fix out-of-bounds read in rsi_read_pkt() 2022-01-27 10:54:13 +01:00
rsi_91x_usb_ops.c
…
rsi_boot_params.h
…
rsi_coex.h
…
rsi_common.h
…
rsi_debugfs.h
…
rsi_hal.h rsi: Fix module dev_oper_mode parameter description 2021-11-18 14:03:47 +01:00
rsi_main.h rsi: fix rate mask set leading to P2P failure 2021-11-18 14:03:47 +01:00
rsi_mgmt.h
…
rsi_ps.h
…
rsi_sdio.h rsi: Move card interrupt handling to RX thread 2021-03-07 12:34:08 +01:00
rsi_usb.h rsi: Fix out-of-bounds read in rsi_read_pkt() 2022-01-27 10:54:13 +01:00