Linux Hardening
 help / color / mirror / Atom feed
* [PATCH] net: wireless: sme: Initialize n_channels before accessing channels in cfg80211_conn_scan
@ 2024-12-03 15:20 Haoyu Li
  2024-12-03 15:25 ` Johannes Berg
  0 siblings, 1 reply; 4+ messages in thread
From: Haoyu Li @ 2024-12-03 15:20 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Kees Cook, Gustavo A . R . Silva, Jeff Johnson, linux-wireless,
	linux-kernel, linux-hardening, stable, Haoyu Li

With the new __counted_by annocation in cfg80211_scan_request struct,
the "n_channels" struct member must be set before accessing the
"channels" array. Failing to do so will trigger a runtime warning
when enabling CONFIG_UBSAN_BOUNDS and CONFIG_FORTIFY_SOURCE.

Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by")

Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
---
 net/wireless/sme.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/net/wireless/sme.c b/net/wireless/sme.c
index 431da30817a6..268171600087 100644
--- a/net/wireless/sme.c
+++ b/net/wireless/sme.c
@@ -83,6 +83,7 @@ static int cfg80211_conn_scan(struct wireless_dev *wdev)
 	if (!request)
 		return -ENOMEM;
 
+	request->n_channels = n_channels;
 	if (wdev->conn->params.channel) {
 		enum nl80211_band band = wdev->conn->params.channel->band;
 		struct ieee80211_supported_band *sband =
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-12-03 16:45 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-03 15:20 [PATCH] net: wireless: sme: Initialize n_channels before accessing channels in cfg80211_conn_scan Haoyu Li
2024-12-03 15:25 ` Johannes Berg
2024-12-03 16:20   ` Gustavo A. R. Silva
2024-12-03 16:45     ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox