From: Kees Cook <kees@kernel.org>
To: Dmitry Antipov <dmantipov@yandex.ru>
Cc: Johannes Berg <johannes.berg@intel.com>,
linux-wireless@vger.kernel.org, linux-hardening@vger.kernel.org,
lvc-project@linuxtesting.org
Subject: Re: [PATCH] wifi: wireless: fix more UBSAN noise in cfg80211_conn_scan()
Date: Tue, 16 Jul 2024 11:21:40 -0700 [thread overview]
Message-ID: <202407161121.C00AC44@keescook> (raw)
In-Reply-To: <20240716174011.236849-1-dmantipov@yandex.ru>
On Tue, Jul 16, 2024 at 08:40:11PM +0300, Dmitry Antipov wrote:
> Looking at https://syzkaller.appspot.com/bug?extid=d5dc2801166df6d34774
> and trying to reproduce it with CONFIG_UBSAN enabled, I've noticed the
> following:
>
> UBSAN: array-index-out-of-bounds in net/wireless/sme.c:95:3
> index 0 is out of range for type 'struct ieee80211_channel *[]'
> CPU: 3 PID: 4993 Comm: repro Not tainted 6.10.0-01155-gd67978318827 #5
> Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS <...>
> Call Trace:
> <TASK>
> dump_stack_lvl+0x1c2/0x2a0
> ? __pfx_dump_stack_lvl+0x10/0x10
> ? __pfx__printk+0x10/0x10
> ? __local_bh_enable_ip+0x12e/0x1c0
> __ubsan_handle_out_of_bounds+0x127/0x150
> cfg80211_conn_scan+0xd8e/0xf30
> cfg80211_connect+0x1400/0x1c30
> nl80211_connect+0x1549/0x1a70
> ...<the rest is not too useful...>
>
> This is very similar to 92ecbb3ac6f3 ("wifi: mac80211: fix UBSAN noise
> in ieee80211_prep_hw_scan()"), so just fix it in the same way by setting
> 'request->n_channels' early to help '__counted_by()' work as expected.
> And the same 'kmalloc()' math adjustment is also applicable.
>
> Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
Nice catch! Yes, this looks correct.
Reviewed-by: Kees Cook <kees@kernel.org>
--
Kees Cook
next prev parent reply other threads:[~2024-07-16 18:21 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-07-16 17:40 [PATCH] wifi: wireless: fix more UBSAN noise in cfg80211_conn_scan() Dmitry Antipov
2024-07-16 18:21 ` Kees Cook [this message]
2024-08-27 8:12 ` 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=202407161121.C00AC44@keescook \
--to=kees@kernel.org \
--cc=dmantipov@yandex.ru \
--cc=johannes.berg@intel.com \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=lvc-project@linuxtesting.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).