Re: [PATCH] wifi: nl80211: Avoid address calculations via out of bounds array indexing

From: Johannes Berg
Date: Tue May 07 2024 - 06:49:24 EST


On Thu, 2024-04-25 at 11:13 -0700, Nathan Chancellor wrote:
> On Wed, Apr 24, 2024 at 03:01:01PM -0700, Kees Cook wrote:
> > Before request->channels[] can be used, request->n_channels must be set.
> > Additionally, address calculations for memory after the "channels" array
> > need to be calculated from the allocation base ("request") rather than
> > via the first "out of bounds" index of "channels", otherwise run-time
> > bounds checking will throw a warning.
> >
> > Reported-by: Nathan Chancellor <nathan@xxxxxxxxxx>
> > Fixes: e3eac9f32ec0 ("wifi: cfg80211: Annotate struct cfg80211_scan_request with __counted_by")
> > Signed-off-by: Kees Cook <keescook@xxxxxxxxxxxx>
>
> Tested-by: Nathan Chancellor <nathan@xxxxxxxxxx>
>

How do you get this tested? We have the same, and more, bugs in
cfg80211_scan_6ghz() which I'm fixing right now, but no idea how to
actually get the checks done?

johannes