From: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
To: Haoyu Li <lihaoyu499@gmail.com>,
Johannes Berg <johannes@sipsolutions.net>
Cc: Kees Cook <kees@kernel.org>,
"Gustavo A . R . Silva" <gustavoars@kernel.org>,
linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-hardening@vger.kernel.org
Subject: Re: [PATCH] net: mac80211: cfg: Initialize cnt before accessing elem
Date: Mon, 25 Nov 2024 10:48:41 -0600 [thread overview]
Message-ID: <aefe4a2a-7adb-49b0-9d8a-32d129ad918d@embeddedor.com> (raw)
In-Reply-To: <20241123170848.309264-1-lihaoyu499@gmail.com>
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@vger.kernel.org
> Signed-off-by: Haoyu Li <lihaoyu499@gmail.com>
Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.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;
> }
prev parent reply other threads:[~2024-11-25 16:50 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-23 17:08 [PATCH] net: mac80211: cfg: Initialize cnt before accessing elem Haoyu Li
2024-11-25 16:48 ` Gustavo A. R. Silva [this message]
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=aefe4a2a-7adb-49b0-9d8a-32d129ad918d@embeddedor.com \
--to=gustavo@embeddedor.com \
--cc=gustavoars@kernel.org \
--cc=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=lihaoyu499@gmail.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@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