]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: cfg80211: fix two more possible UBSAN-detected off-by-one errors
authorDmitry Antipov <dmantipov@yandex.ru>
Mon, 9 Sep 2024 09:08:06 +0000 (12:08 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Mon, 9 Sep 2024 09:43:21 +0000 (11:43 +0200)
Although not reproduced in practice, these two cases may be
considered by UBSAN as off-by-one errors. So fix them in the
same way as in commit a26a5107bc52 ("wifi: cfg80211: fix UBSAN
noise in cfg80211_wext_siwscan()").

Fixes: 807f8a8c3004 ("cfg80211/nl80211: add support for scheduled scans")
Fixes: 5ba63533bbf6 ("cfg80211: fix alignment problem in scan request")
Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Link: https://patch.msgid.link/20240909090806.1091956-1-dmantipov@yandex.ru
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
net/wireless/nl80211.c
net/wireless/sme.c

index 8bad3c6db39d9050ab9a6d865cedea619aceb48e..9ab777e0bd4d3493619ed73b279a80a84ce476e2 100644 (file)
@@ -9778,7 +9778,8 @@ nl80211_parse_sched_scan(struct wiphy *wiphy, struct wireless_dev *wdev,
                return ERR_PTR(-ENOMEM);
 
        if (n_ssids)
-               request->ssids = (void *)&request->channels[n_channels];
+               request->ssids = (void *)request +
+                       struct_size(request, channels, n_channels);
        request->n_ssids = n_ssids;
        if (ie_len) {
                if (n_ssids)
index d9d7bf8bb5c1acde38f1263da3a371d4788c8641..431da30817a6f6321238fd94f834d3c64127c50c 100644 (file)
@@ -115,7 +115,8 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
                n_channels = i;
        }
        request->n_channels = n_channels;
-       request->ssids = (void *)&request->channels[n_channels];
+       request->ssids = (void *)request +
+               struct_size(request, channels, n_channels);
        request->n_ssids = 1;
 
        memcpy(request->ssids[0].ssid, wdev->conn->params.ssid,