This is a note to let you know that I've just added the patch titled staging: rtl8723bs: prevent ->Ssid overflow in rtw_wx_set_scan() to the 4.19-stable tree which can be found at: http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary The filename of the patch is: staging-rtl8723bs-prevent-ssid-overflow-in-rtw_wx_set_scan.patch and it can be found in the queue-4.19 subdirectory. If you, or anyone else, feels it should not be added to the stable tree, please let <stable@xxxxxxxxxxxxxxx> know about it. >From efremov@xxxxxxxxx Thu May 26 14:03:14 2022 From: "Denis Efremov (Oracle)" <efremov@xxxxxxxxx> Date: Mon, 23 May 2022 21:39:43 +0400 Subject: staging: rtl8723bs: prevent ->Ssid overflow in rtw_wx_set_scan() To: gregkh@xxxxxxxxxxxxxxxxxxx Cc: "Denis Efremov (Oracle)" <efremov@xxxxxxxxx>, Larry.Finger@xxxxxxxxxxxx, phil@xxxxxxxxxxxxxxxx, dan.carpenter@xxxxxxxxxx, straube.linux@xxxxxxxxx, linux-staging@xxxxxxxxxxxxxxx, linux-kernel@xxxxxxxxxxxxxxx, kernel-janitors@xxxxxxxxxxxxxxx, stable <stable@xxxxxxxxxxxxxxx> Message-ID: <20220523173943.12486-1-efremov@xxxxxxxxx> From: "Denis Efremov (Oracle)" <efremov@xxxxxxxxx> This code has a check to prevent read overflow but it needs another check to prevent writing beyond the end of the ->Ssid[] array. Fixes: 554c0a3abf21 ("staging: Add rtl8723bs sdio wifi driver") Cc: stable <stable@xxxxxxxxxxxxxxx> Signed-off-by: Denis Efremov (Oracle) <efremov@xxxxxxxxx> Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx> --- drivers/staging/rtl8723bs/os_dep/ioctl_linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) --- a/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c +++ b/drivers/staging/rtl8723bs/os_dep/ioctl_linux.c @@ -1359,9 +1359,11 @@ static int rtw_wx_set_scan(struct net_de sec_len = *(pos++); len-= 1; - if (sec_len>0 && sec_len<=len) { + if (sec_len > 0 && + sec_len <= len && + sec_len <= 32) { ssid[ssid_index].SsidLength = sec_len; - memcpy(ssid[ssid_index].Ssid, pos, ssid[ssid_index].SsidLength); + memcpy(ssid[ssid_index].Ssid, pos, sec_len); /* DBG_871X("%s COMBO_SCAN with specific ssid:%s, %d\n", __func__ */ /* , ssid[ssid_index].Ssid, ssid[ssid_index].SsidLength); */ ssid_index++; Patches currently in stable-queue which might be from efremov@xxxxxxxxx are queue-4.19/staging-rtl8723bs-prevent-ssid-overflow-in-rtw_wx_set_scan.patch