Linux Hardening
 help / color / mirror / Atom feed
* [PATCH 1/2] wifi: cfg80211: annotate struct cfg80211_mgmt_registration with __counted_by()
@ 2024-12-10 14:39 Dmitry Antipov
  2024-12-10 14:39 ` [PATCH 2/2] wifi: cfg80211: simplify cfg80211_mlme_register_mgmt() Dmitry Antipov
  2024-12-10 16:42 ` [PATCH 1/2] wifi: cfg80211: annotate struct cfg80211_mgmt_registration with __counted_by() Johannes Berg
  0 siblings, 2 replies; 5+ messages in thread
From: Dmitry Antipov @ 2024-12-10 14:39 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Kees Cook, Gustavo A . R . Silva, linux-hardening, linux-wireless,
	Dmitry Antipov

Add the '__counted_by()' compiler attribute to the flexible array member
'match[]' to improve access bounds-checking via CONFIG_UBSAN_BOUNDS and
CONFIG_FORTIFY_SOURCE, adjust 'cfg80211_mlme_register_mgmt()' accordingly.

Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
---
 net/wireless/mlme.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/net/wireless/mlme.c b/net/wireless/mlme.c
index 9d577523462d..4790136758d5 100644
--- a/net/wireless/mlme.c
+++ b/net/wireless/mlme.c
@@ -575,7 +575,7 @@ struct cfg80211_mgmt_registration {
 
 	bool multicast_rx;
 
-	u8 match[];
+	u8 match[] __counted_by(match_len);
 };
 
 static void cfg80211_mgmt_registrations_update(struct wireless_dev *wdev)
@@ -710,8 +710,8 @@ int cfg80211_mlme_register_mgmt(struct wireless_dev *wdev, u32 snd_portid,
 	if (update_multicast) {
 		kfree(nreg);
 	} else {
-		memcpy(nreg->match, match_data, match_len);
 		nreg->match_len = match_len;
+		memcpy(nreg->match, match_data, match_len);
 		nreg->nlportid = snd_portid;
 		nreg->frame_type = cpu_to_le16(frame_type);
 		nreg->wdev = wdev;
-- 
2.47.1


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

end of thread, other threads:[~2024-12-31  4:59 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-12-10 14:39 [PATCH 1/2] wifi: cfg80211: annotate struct cfg80211_mgmt_registration with __counted_by() Dmitry Antipov
2024-12-10 14:39 ` [PATCH 2/2] wifi: cfg80211: simplify cfg80211_mlme_register_mgmt() Dmitry Antipov
2024-12-12  8:28   ` Johannes Berg
2024-12-31  4:59   ` kernel test robot
2024-12-10 16:42 ` [PATCH 1/2] wifi: cfg80211: annotate struct cfg80211_mgmt_registration with __counted_by() Johannes Berg

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