<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel.git/drivers/net/wireless/rsi, branch linux-5.16.y</title>
<subtitle>Hosts the 0x221E linux distro kernel.
</subtitle>
<id>https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y</id>
<link rel='self' href='https://git.0xinfinity.dev/distro/kernel.git/atom?h=linux-5.16.y'/>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/'/>
<updated>2022-01-27T11:02:18Z</updated>
<entry>
<title>rsi: Fix out-of-bounds read in rsi_read_pkt()</title>
<updated>2022-01-27T11:02:18Z</updated>
<author>
<name>Zekun Shen</name>
</author>
<published>2021-10-29T20:19:23Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=bd2b5268910cdd77a6b4376c4eee390d89f8e246'/>
<id>urn:sha1:bd2b5268910cdd77a6b4376c4eee390d89f8e246</id>
<content type='text'>
[ 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 &gt; 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 &lt;brendandg@nyu.edu&gt;
Signed-off-by: Zekun Shen &lt;bruceshenzk@gmail.com&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/YXxXS4wgu2OsmlVv@10-18-43-117.dynapool.wireless.nyu.edu
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>rsi: Fix use-after-free in rsi_rx_done_handler()</title>
<updated>2022-01-27T11:02:18Z</updated>
<author>
<name>Zekun Shen</name>
</author>
<published>2021-10-29T19:49:03Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=5b0c55818d1514756e624911704b808b1a37485b'/>
<id>urn:sha1:5b0c55818d1514756e624911704b808b1a37485b</id>
<content type='text'>
[ Upstream commit b07e3c6ebc0c20c772c0f54042e430acec2945c3 ]

When freeing rx_cb-&gt;rx_skb, the pointer is not set to NULL,
a later rsi_rx_done_handler call will try to read the freed
address.
This bug will very likley lead to double free, although
detected early as use-after-free bug.

The bug is triggerable with a compromised/malfunctional usb
device. After applying the patch, the same input no longer
triggers the use-after-free.

Attached is the kasan report from fuzzing.

BUG: KASAN: use-after-free in rsi_rx_done_handler+0x354/0x430 [rsi_usb]
Read of size 4 at addr ffff8880188e5930 by task modprobe/231
Call Trace:
 &lt;IRQ&gt;
 dump_stack+0x76/0xa0
 print_address_description.constprop.0+0x16/0x200
 ? rsi_rx_done_handler+0x354/0x430 [rsi_usb]
 ? rsi_rx_done_handler+0x354/0x430 [rsi_usb]
 __kasan_report.cold+0x37/0x7c
 ? dma_direct_unmap_page+0x90/0x110
 ? rsi_rx_done_handler+0x354/0x430 [rsi_usb]
 kasan_report+0xe/0x20
 rsi_rx_done_handler+0x354/0x430 [rsi_usb]
 __usb_hcd_giveback_urb+0x1e4/0x380
 usb_giveback_urb_bh+0x241/0x4f0
 ? __usb_hcd_giveback_urb+0x380/0x380
 ? apic_timer_interrupt+0xa/0x20
 tasklet_action_common.isra.0+0x135/0x330
 __do_softirq+0x18c/0x634
 ? handle_irq_event+0xcd/0x157
 ? handle_edge_irq+0x1eb/0x7b0
 irq_exit+0x114/0x140
 do_IRQ+0x91/0x1e0
 common_interrupt+0xf/0xf
 &lt;/IRQ&gt;

Reported-by: Brendan Dolan-Gavitt &lt;brendandg@nyu.edu&gt;
Signed-off-by: Zekun Shen &lt;bruceshenzk@gmail.com&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/YXxQL/vIiYcZUu/j@10-18-43-117.dynapool.wireless.nyu.edu
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>rsi: fix control-message timeout</title>
<updated>2021-10-28T13:26:18Z</updated>
<author>
<name>Johan Hovold</name>
</author>
<published>2021-10-25T12:05:22Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=541fd20c3ce5b0bc39f0c6a52414b6b92416831c'/>
<id>urn:sha1:541fd20c3ce5b0bc39f0c6a52414b6b92416831c</id>
<content type='text'>
USB control-message timeouts are specified in milliseconds and should
specifically not vary with CONFIG_HZ.

Use the common control-message timeout define for the five-second
timeout.

Fixes: dad0d04fa7ba ("rsi: Add RS9113 wireless driver")
Cc: stable@vger.kernel.org      # 3.15
Signed-off-by: Johan Hovold &lt;johan@kernel.org&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/20211025120522.6045-5-johan@kernel.org
</content>
</entry>
<entry>
<title>rsi: stop thread firstly in rsi_91x_init() error handling</title>
<updated>2021-10-20T08:39:43Z</updated>
<author>
<name>Ziyang Xuan</name>
</author>
<published>2021-10-15T04:03:35Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=515e7184bdf0a3ebf1757cc77fb046b4fe282189'/>
<id>urn:sha1:515e7184bdf0a3ebf1757cc77fb046b4fe282189</id>
<content type='text'>
When fail to init coex module, free 'common' and 'adapter' directly, but
common-&gt;tx_thread which will access 'common' and 'adapter' is running at
the same time. That will trigger the UAF bug.

==================================================================
BUG: KASAN: use-after-free in rsi_tx_scheduler_thread+0x50f/0x520 [rsi_91x]
Read of size 8 at addr ffff8880076dc000 by task Tx-Thread/124777
CPU: 0 PID: 124777 Comm: Tx-Thread Not tainted 5.15.0-rc5+ #19
Call Trace:
 dump_stack_lvl+0xe2/0x152
 print_address_description.constprop.0+0x21/0x140
 ? rsi_tx_scheduler_thread+0x50f/0x520
 kasan_report.cold+0x7f/0x11b
 ? rsi_tx_scheduler_thread+0x50f/0x520
 rsi_tx_scheduler_thread+0x50f/0x520
...

Freed by task 111873:
 kasan_save_stack+0x1b/0x40
 kasan_set_track+0x1c/0x30
 kasan_set_free_info+0x20/0x30
 __kasan_slab_free+0x109/0x140
 kfree+0x117/0x4c0
 rsi_91x_init+0x741/0x8a0 [rsi_91x]
 rsi_probe+0x9f/0x1750 [rsi_usb]

Stop thread before free 'common' and 'adapter' to fix it.

Fixes: 2108df3c4b18 ("rsi: add coex support")
Signed-off-by: Ziyang Xuan &lt;william.xuanziyang@huawei.com&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/20211015040335.1021546-1-william.xuanziyang@huawei.com
</content>
</entry>
<entry>
<title>rsi: Fix module dev_oper_mode parameter description</title>
<updated>2021-09-21T15:03:48Z</updated>
<author>
<name>Marek Vasut</name>
</author>
<published>2021-09-16T14:42:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=31f97cf9f0c31143a2a6fcc89c4a1286ce20157e'/>
<id>urn:sha1:31f97cf9f0c31143a2a6fcc89c4a1286ce20157e</id>
<content type='text'>
The module parameters are missing dev_oper_mode 12, BT classic alone,
add it. Moreover, the parameters encode newlines, which ends up being
printed malformed e.g. by modinfo, so fix that too.

However, the module parameter string is duplicated in both USB and SDIO
modules and the dev_oper_mode mode enumeration in those module parameters
is a duplicate of macros used by the driver. Furthermore, the enumeration
is confusing.

So, deduplicate the module parameter string and use __stringify() to
encode the correct mode enumeration values into the module parameter
string. Finally, replace 'Wi-Fi' with 'Wi-Fi alone' and 'BT' with
'BT classic alone' to clarify what those modes really mean.

Fixes: 898b255339310 ("rsi: add module parameter operating mode")
Signed-off-by: Marek Vasut &lt;marex@denx.de&gt;
Cc: Amitkumar Karwar &lt;amit.karwar@redpinesignals.com&gt;
Cc: Angus Ainslie &lt;angus@akkea.ca&gt;
Cc: David S. Miller &lt;davem@davemloft.net&gt;
Cc: Jakub Kicinski &lt;kuba@kernel.org&gt;
Cc: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Cc: Karun Eagalapati &lt;karun256@gmail.com&gt;
Cc: Martin Fuzzey &lt;martin.fuzzey@flowbird.group&gt;
Cc: Martin Kepplinger &lt;martink@posteo.de&gt;
Cc: Prameela Rani Garnepudi &lt;prameela.j04cs@gmail.com&gt;
Cc: Sebastian Krzyszkowiak &lt;sebastian.krzyszkowiak@puri.sm&gt;
Cc: Siva Rebbagondla &lt;siva8118@gmail.com&gt;
Cc: netdev@vger.kernel.org
Cc: &lt;stable@vger.kernel.org&gt; # 4.17+
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/20210916144245.10181-1-marex@denx.de
</content>
</entry>
<entry>
<title>rsi: fix rate mask set leading to P2P failure</title>
<updated>2021-09-21T05:42:37Z</updated>
<author>
<name>Martin Fuzzey</name>
</author>
<published>2021-08-30T15:26:46Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=b515d097053a71d624e0c5840b42cd4caa653941'/>
<id>urn:sha1:b515d097053a71d624e0c5840b42cd4caa653941</id>
<content type='text'>
P2P client mode was only working the first time.
On subsequent connection attempts the group was successfully created but
no data was sent (no transmitted data packets were seen with a sniffer).

The reason for this was that the hardware was being configured in fixed
rate mode with rate RSI_RATE_1 (1Mbps) which is not valid in the 5GHz band.

In P2P mode wpa_supplicant uses NL80211_CMD_SET_TX_BITRATE_MASK to disallow
the 11b rates in the 2.4GHz band which updated common-&gt;fixedrate_mask.

rsi_set_min_rate() then used the fixedrate_mask to calculate the minimum
allowed rate, or 0xffff = auto if none was found.
However that calculation did not account for the different rate sets
allowed in the different bands leading to the error.

Fixing set_min_rate() would result in 6Mb/s being used all the time
which is not what we want either.

The reason the problem did not occur on the first connection is that
rsi_mac80211_set_rate_mask() only updated the fixedrate_mask for
the *current* band. When it was called that was still 2.4GHz as the
switch is done later. So the when set_min_rate() was subsequently
called after the switch to 5GHz it still had a mask of zero, leading
to defaulting to auto mode.

Fix this by differentiating the case of a single rate being
requested, in which case the hardware will be used in fixed rate
mode with just that rate, and multiple rates being requested,
in which case we remain in auto mode but the firmware rate selection
algorithm is configured with a restricted set of rates.

Fixes: dad0d04fa7ba ("rsi: Add RS9113 wireless driver")
Signed-off-by: Martin Fuzzey &lt;martin.fuzzey@flowbird.group&gt;
CC: stable@vger.kernel.org
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/1630337206-12410-4-git-send-email-martin.fuzzey@flowbird.group
</content>
</entry>
<entry>
<title>rsi: fix key enabled check causing unwanted encryption for vap_id &gt; 0</title>
<updated>2021-09-21T05:42:37Z</updated>
<author>
<name>Martin Fuzzey</name>
</author>
<published>2021-08-30T15:26:45Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=99ac6018821253ec67f466086afb63fc18ea48e2'/>
<id>urn:sha1:99ac6018821253ec67f466086afb63fc18ea48e2</id>
<content type='text'>
My previous patch checked if encryption should be enabled by directly
checking info-&gt;control.hw_key (like the downstream driver).
However that missed that the control and driver_info members of
struct ieee80211_tx_info are union fields.

Due to this when rsi_core_xmit() updates fields in "tx_params"
(driver_info) it can overwrite the control.hw_key, causing the result
of the later test to be incorrect.

With the current structure layout the first byte of control.hw_key is
overlayed with the vap_id so, since we only test if control.hw_key is
NULL / non NULL, a non zero vap_id will incorrectly enable encryption.

In basic STA and AP modes the vap_id is always zero so it works but in
P2P client mode a second VIF is created causing vap_id to be non zero
and hence encryption to be enabled before keys have been set.

Fix this by extracting the key presence flag to a new field in the driver
private tx_params structure and populating it first.

Fixes: 314538041b56 ("rsi: fix AP mode with WPA failure due to encrypted EAPOL")
Signed-off-by: Martin Fuzzey &lt;martin.fuzzey@flowbird.group&gt;
CC: stable@vger.kernel.org
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/1630337206-12410-3-git-send-email-martin.fuzzey@flowbird.group
</content>
</entry>
<entry>
<title>rsi: fix occasional initialisation failure with BT coex</title>
<updated>2021-09-21T05:42:36Z</updated>
<author>
<name>Martin Fuzzey</name>
</author>
<published>2021-08-30T15:26:44Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9b14ed6e11b72dd4806535449ca6c6962cb2369d'/>
<id>urn:sha1:9b14ed6e11b72dd4806535449ca6c6962cb2369d</id>
<content type='text'>
When BT coexistence is enabled (eg oper mode 13, which is the default)
the initialisation on startup sometimes silently fails.

In a normal initialisation we see
	usb 1-1.3: Product: Wireless USB Network Module
	usb 1-1.3: Manufacturer: Redpine Signals, Inc.
	usb 1-1.3: SerialNumber: 000000000001
	rsi_91x: rsi_probe: Initialized os intf ops
	rsi_91x: rsi_load_9116_firmware: Loading chunk 0
	rsi_91x: rsi_load_9116_firmware: Loading chunk 1
	rsi_91x: rsi_load_9116_firmware: Loading chunk 2
	rsi_91x: Max Stations Allowed = 1

But sometimes the last log is missing and the wlan net device is
not created.

Running a userspace loop that resets the hardware via a GPIO shows the
problem occurring ~5/100 resets.

The problem does not occur in oper mode 1 (wifi only).

Adding logs shows that the initialisation state machine requests a MAC
reset via rsi_send_reset_mac() but the firmware does not reply, leading
to the initialisation sequence being incomplete.

Fix this by delaying attaching the BT adapter until the wifi
initialisation has completed.

With this applied I have done &gt; 300 reset loops with no errors.

Fixes: 716b840c7641 ("rsi: handle BT traffic in driver")
Signed-off-by: Martin Fuzzey &lt;martin.fuzzey@flowbird.group&gt;
CC: stable@vger.kernel.org
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/1630337206-12410-2-git-send-email-martin.fuzzey@flowbird.group
</content>
</entry>
<entry>
<title>rsi: make array fsm_state static const, makes object smaller</title>
<updated>2021-08-29T08:32:01Z</updated>
<author>
<name>Colin Ian King</name>
</author>
<published>2021-08-19T12:50:18Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=f4c813641897cfb43b3b99edd8c8851a1c98c70f'/>
<id>urn:sha1:f4c813641897cfb43b3b99edd8c8851a1c98c70f</id>
<content type='text'>
Don't populate the array fsm_state on the stack but instead it
static const. Makes the object code smaller by 154 bytes:

Before:
   text	   data	    bss	    dec	    hex	filename
   9213	   3904	      0	  13117	   333d	.../wireless/rsi/rsi_91x_debugfs.o

After:
   text	   data	    bss	    dec	    hex	filename
   8995	   3968	      0	  12963	   32a3	.../wireless/rsi/rsi_91x_debugfs.o

(gcc version 10.3.0)

Signed-off-by: Colin Ian King &lt;colin.king@canonical.com&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/20210819125018.8577-1-colin.king@canonical.com
</content>
</entry>
<entry>
<title>rsi: fix an error code in rsi_probe()</title>
<updated>2021-08-21T17:27:48Z</updated>
<author>
<name>Dan Carpenter</name>
</author>
<published>2021-08-16T18:39:47Z</published>
<link rel='alternate' type='text/html' href='https://git.0xinfinity.dev/distro/kernel.git/commit/?id=9adcdf6758d7c4c9bdaf22d78eb9fcae260ed113'/>
<id>urn:sha1:9adcdf6758d7c4c9bdaf22d78eb9fcae260ed113</id>
<content type='text'>
Return -ENODEV instead of success for unsupported devices.

Fixes: 54fdb318c111 ("rsi: add new device model for 9116")
Signed-off-by: Dan Carpenter &lt;dan.carpenter@oracle.com&gt;
Signed-off-by: Kalle Valo &lt;kvalo@codeaurora.org&gt;
Link: https://lore.kernel.org/r/20210816183947.GA2119@kili
</content>
</entry>
</feed>
