netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeongjun Park <aha310510@gmail.com>
To: johannes@sipsolutions.net
Cc: linux-wireless@vger.kernel.org, netdev@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: [PATCH net] wifi: cfg80211: Fix out-of-bounds in cfg80211_wext_siwscan
Date: Sun, 23 Jun 2024 17:49:39 +0900	[thread overview]
Message-ID: <20240623084939.6889-1-aha310510@gmail.com> (raw)

In the process of searching for matching hardware channels, wreq and 
wreq->num_channels are checked to see if they are NULL. However, 
if the value of wreq->num_channels is greater than IW_MAX_FREQUENCIES,
an out-of-bounds vulnerability occurs.

Therefore, you must also add code to check whether the value of 
wreq->num_channels is within the range.

Reguards.

Signed-by-off: Jeongjun Park <aha310510@gmail.com>
---
 net/wireless/scan.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/net/wireless/scan.c b/net/wireless/scan.c
index 0222ede0feb6..f253dee041d1 100644
--- a/net/wireless/scan.c
+++ b/net/wireless/scan.c
@@ -3460,6 +3460,10 @@ int cfg80211_wext_siwscan(struct net_device *dev,
 			if (wreq && wreq->num_channels) {
 				int k;
 				int wiphy_freq = wiphy->bands[band]->channels[j].center_freq;
+
+				if (wreq->num_channels > IW_MAX_FREQUENCIES)
+					wreq->num_channels = IW_MAX_FREQUENCIES;
+
 				for (k = 0; k < wreq->num_channels; k++) {
 					struct iw_freq *freq =
 						&wreq->channel_list[k];
-- 
2.34.1

             reply	other threads:[~2024-06-23  8:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-23  8:49 Jeongjun Park [this message]
2024-06-25 11:54 ` [PATCH net] wifi: cfg80211: Fix out-of-bounds in cfg80211_wext_siwscan Johannes Berg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240623084939.6889-1-aha310510@gmail.com \
    --to=aha310510@gmail.com \
    --cc=johannes@sipsolutions.net \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).