Patch "wifi: rndis_wlan: Prevent buffer overflow in rndis_query_oid" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    wifi: rndis_wlan: Prevent buffer overflow in rndis_query_oid

to the 5.10-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:
     wifi-rndis_wlan-prevent-buffer-overflow-in-rndis_que.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 66681253cf245cd2af43b4896974c82583916c61
Author: Szymon Heidrich <szymon.heidrich@xxxxxxxxx>
Date:   Wed Jan 11 18:50:31 2023 +0100

    wifi: rndis_wlan: Prevent buffer overflow in rndis_query_oid
    
    [ Upstream commit b870e73a56c4cccbec33224233eaf295839f228c ]
    
    Since resplen and respoffs are signed integers sufficiently
    large values of unsigned int len and offset members of RNDIS
    response will result in negative values of prior variables.
    This may be utilized to bypass implemented security checks
    to either extract memory contents by manipulating offset or
    overflow the data buffer via memcpy by manipulating both
    offset and len.
    
    Additionally assure that sum of resplen and respoffs does not
    overflow so buffer boundaries are kept.
    
    Fixes: 80f8c5b434f9 ("rndis_wlan: copy only useful data from rndis_command respond")
    Signed-off-by: Szymon Heidrich <szymon.heidrich@xxxxxxxxx>
    Reviewed-by: Alexander Duyck <alexanderduyck@xxxxxx>
    Signed-off-by: Kalle Valo <kvalo@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/20230111175031.7049-1-szymon.heidrich@xxxxxxxxx
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c
index 75b5d545b49e..dc076d844868 100644
--- a/drivers/net/wireless/rndis_wlan.c
+++ b/drivers/net/wireless/rndis_wlan.c
@@ -694,8 +694,8 @@ static int rndis_query_oid(struct usbnet *dev, u32 oid, void *data, int *len)
 		struct rndis_query	*get;
 		struct rndis_query_c	*get_c;
 	} u;
-	int ret, buflen;
-	int resplen, respoffs, copylen;
+	int ret;
+	size_t buflen, resplen, respoffs, copylen;
 
 	buflen = *len + sizeof(*u.get);
 	if (buflen < CONTROL_BUFFER_SIZE)
@@ -730,22 +730,15 @@ static int rndis_query_oid(struct usbnet *dev, u32 oid, void *data, int *len)
 
 		if (respoffs > buflen) {
 			/* Device returned data offset outside buffer, error. */
-			netdev_dbg(dev->net, "%s(%s): received invalid "
-				"data offset: %d > %d\n", __func__,
-				oid_to_string(oid), respoffs, buflen);
+			netdev_dbg(dev->net,
+				   "%s(%s): received invalid data offset: %zu > %zu\n",
+				   __func__, oid_to_string(oid), respoffs, buflen);
 
 			ret = -EINVAL;
 			goto exit_unlock;
 		}
 
-		if ((resplen + respoffs) > buflen) {
-			/* Device would have returned more data if buffer would
-			 * have been big enough. Copy just the bits that we got.
-			 */
-			copylen = buflen - respoffs;
-		} else {
-			copylen = resplen;
-		}
+		copylen = min(resplen, buflen - respoffs);
 
 		if (copylen > *len)
 			copylen = *len;



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux