OSDN Git Service

rtw88: fix beaconing mode rsvd_page memory violation issue
authorYan-Hsuan Chuang <yhchuang@realtek.com>
Wed, 2 Oct 2019 06:35:25 +0000 (14:35 +0800)
committerKalle Valo <kvalo@codeaurora.org>
Fri, 4 Oct 2019 13:45:00 +0000 (16:45 +0300)
commitc3594559f49c601d410dee4b767c3536a5535bfd
treea3cc8b0207809876778c6be6bfa2a5a0c85eb052
parent1131ad7fe57541b78db92d1332c69158e13762dc
rtw88: fix beaconing mode rsvd_page memory violation issue

When downloading the reserved page, the first page always contains
a beacon for the firmware to reference. For non-beaconing modes such
as station mode, also put a blank skb with length=1.

And for the beaconing modes, driver will get a real beacon with a
length approximate to the page size. But as the beacon is always put
at the first page, it does not need a tx_desc, because the TX path
will generate one when TXing the reserved page to the hardware. So we
could allocate a buffer with a size smaller than the reserved page,
when using memcpy() to copy the content of reserved page to the buffer,
the over-sized reserved page will violate the kernel memory.

To fix it, add the tx_desc before memcpy() the reserved packets to
the buffer, then we can get SKBs with correct length when counting
the pages in total. And for page 0, count the extra tx_desc_sz that
the TX path will generate. This way, the first beacon that allocated
without tx_desc can be counted with the extra tx_desc_sz to get
actual pages it requires.

Fixes: e3037485c68e ("rtw88: new Realtek 802.11ac driver")
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
drivers/net/wireless/realtek/rtw88/fw.c