From: Johannes Berg <johannes@sipsolutions.net>
To: Kees Cook <kees@kernel.org>
Cc: linux-wireless@vger.kernel.org, Haoyu Li <lihaoyu499@gmail.com>
Subject: Re: [PATCH wireless] wifi: cfg80211: remove scan request n_channels counted_by
Date: Fri, 18 Jul 2025 10:26:37 +0200 [thread overview]
Message-ID: <7b840730a87a30d19989aa027ae0e752879746ed.camel@sipsolutions.net> (raw)
In-Reply-To: <202507171651.8E89C32F4@keescook>
On Thu, 2025-07-17 at 17:05 -0700, Kees Cook wrote:
> > But I'm also not completely sure I've convinced myself that all the
> > above discussion about allocated vs. used is really the _entire_
> > explanation for it being such a spectacular failure here.
>
> I think it's a big part of it -- having the counted member change after
> initial assignment is even frowned upon by the compiler folks, but is
> technically supported.
Right. So since I wrote the above, I've come to think that while it'd
almost certainly fix this issue, the num_channels had another side
effect of validating the *read* side in cases like this. While we may
allocate 25 channels, if we're only using 2 then reading the 10th would
be a bug since it's not been initialized (OK, it's probably NULL, but
still not filled to a valid value.)
So in some way, you almost want to be able to separate the two and write
__counted_by(write=n_alloc, read=n_used), but I guess I don't see
compilers supporting that any time.
I guess the only other way around it would be to re-allocate it all the
time, but that's also annoying in other ways (possibly context, copying
other large things in it, etc.)
> Anyway, sorry again for the wasting of time of yours (and others) that I
> caused with this -- I really wasn't expecting it to go that way, and it
> hasn't been anywhere near as troublesome in other areas of the kernel,
> so it took me by surprise. I have tried to chase down and fix the glitches
> when I became aware of them, FWIW.
Sure, I know, and thanks for that.
> I'll see if I can write up some patches for comments like you suggest
> above with good "proof" attached to them. :)
Thanks, help re-reviewing these is much appreciated.
johannes
next prev parent reply other threads:[~2025-07-18 8:27 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-07-14 12:21 [PATCH wireless] wifi: cfg80211: remove scan request n_channels counted_by Johannes Berg
2025-07-15 5:04 ` Kees Cook
2025-07-15 8:24 ` Johannes Berg
2025-07-18 0:05 ` Kees Cook
2025-07-18 8:26 ` Johannes Berg [this message]
2025-07-21 18:36 ` Review of __counted_by in wireless (was Re: [PATCH wireless] wifi: cfg80211: remove scan request n_channels counted_by) Kees Cook
2025-07-21 18:52 ` 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=7b840730a87a30d19989aa027ae0e752879746ed.camel@sipsolutions.net \
--to=johannes@sipsolutions.net \
--cc=kees@kernel.org \
--cc=lihaoyu499@gmail.com \
--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;
as well as URLs for NNTP newsgroup(s).