Patch "wifi: nl80211: Avoid address calculations via out of bounds array indexing" has been added to the 6.6-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: nl80211: Avoid address calculations via out of bounds array indexing

to the 6.6-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-nl80211-avoid-address-calculations-via-out-of-b.patch
and it can be found in the queue-6.6 subdirectory.

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



commit c573f5e85e67cd086e0c1687fba3bcce87d12fb4
Author: Kees Cook <keescook@xxxxxxxxxxxx>
Date:   Wed Apr 24 15:01:01 2024 -0700

    wifi: nl80211: Avoid address calculations via out of bounds array indexing
    
    [ Upstream commit 838c7b8f1f278404d9d684c34a8cb26dc41aaaa1 ]
    
    Before request->channels[] can be used, request->n_channels must be set.
    Additionally, address calculations for memory after the "channels" array
    need to be calculated from the allocation base ("request") rather than
    via the first "out of bounds" index of "channels", otherwise run-time
    bounds checking will throw a warning.
    
    Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by")
    Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
    Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
    Link: https://msgid.link/20240424220057.work.819-kees@xxxxxxxxxx
    Signed-off-by: Johannes Berg <johannes.berg@xxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index c4f08f7eb741d..8f8f077e6cd40 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -9153,6 +9153,7 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 	struct wiphy *wiphy;
 	int err, tmp, n_ssids = 0, n_channels, i;
 	size_t ie_len, size;
+	size_t ssids_offset, ie_offset;
 
 	wiphy = &rdev->wiphy;
 
@@ -9198,21 +9199,20 @@ static int nl80211_trigger_scan(struct sk_buff *skb, struct genl_info *info)
 		return -EINVAL;
 
 	size = struct_size(request, channels, n_channels);
+	ssids_offset = size;
 	size = size_add(size, array_size(sizeof(*request->ssids), n_ssids));
+	ie_offset = size;
 	size = size_add(size, ie_len);
 	request = kzalloc(size, GFP_KERNEL);
 	if (!request)
 		return -ENOMEM;
+	request->n_channels = n_channels;
 
 	if (n_ssids)
-		request->ssids = (void *)&request->channels[n_channels];
+		request->ssids = (void *)request + ssids_offset;
 	request->n_ssids = n_ssids;
-	if (ie_len) {
-		if (n_ssids)
-			request->ie = (void *)(request->ssids + n_ssids);
-		else
-			request->ie = (void *)(request->channels + n_channels);
-	}
+	if (ie_len)
+		request->ie = (void *)request + ie_offset;
 
 	i = 0;
 	if (scan_freqs) {




[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