[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <aefe4a2a-7adb-49b0-9d8a-32d129ad918d@embeddedor.com>
Date: Mon, 25 Nov 2024 10:48:41 -0600
From: "Gustavo A. R. Silva" <gustavo@...eddedor.com>
To: Haoyu Li <lihaoyu499@...il.com>, Johannes Berg <johannes@...solutions.net>
Cc: Kees Cook <kees@...nel.org>, "Gustavo A . R . Silva"
<gustavoars@...nel.org>, linux-wireless@...r.kernel.org,
linux-kernel@...r.kernel.org, linux-hardening@...r.kernel.org
Subject: Re: [PATCH] net: mac80211: cfg: Initialize cnt before accessing elem
On 23/11/24 11:08, Haoyu Li wrote:
> With the new __counted_by annocation in cfg80211_rnr_elems, the "cnt"
> struct member must be set before accessing the "elem" array. Failing to
> do so will trigger a runtime warning when enabling CONFIG_UBSAN_BOUNDS
> and CONFIG_FORTIFY_SOURCE.
>
Nice catch. :)
> Fixes: 7b6d7087031b ("wifi: cfg80211: Annotate struct cfg80211_rnr_elems with __counted_by")
This should be Cc'd to stable:
Cc: stable@...r.kernel.org
> Signed-off-by: Haoyu Li <lihaoyu499@...il.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@...nel.org>
Thanks
-Gustavo
> ---
> net/mac80211/cfg.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
> index 61a824ec33da..6936b1303e81 100644
> --- a/net/mac80211/cfg.c
> +++ b/net/mac80211/cfg.c
> @@ -1105,13 +1105,13 @@ ieee80211_copy_rnr_beacon(u8 *pos, struct cfg80211_rnr_elems *dst,
> {
> int i, offset = 0;
>
> + dst->cnt = src->cnt;
> for (i = 0; i < src->cnt; i++) {
> memcpy(pos + offset, src->elem[i].data, src->elem[i].len);
> dst->elem[i].len = src->elem[i].len;
> dst->elem[i].data = pos + offset;
> offset += dst->elem[i].len;
> }
> - dst->cnt = src->cnt;
>
> return offset;
> }
Powered by blists - more mailing lists