From: Arend van Spriel <arend.vanspriel@broadcom.com>
To: Kalle Valo <kvalo@kernel.org>,
"Gustavo A. R. Silva" <gustavoars@kernel.org>
Cc: Nathan Chancellor <nathan@kernel.org>,
linux-wireless@vger.kernel.org, brcm80211@lists.linux.dev,
brcm80211-dev-list.pdl@broadcom.com,
linux-kernel@vger.kernel.org, linux-hardening@vger.kernel.org
Subject: Re: [PATCH][next] wifi: brcmfmac: fweh: Fix boot crash on Raspberry Pi 4
Date: Tue, 27 Feb 2024 12:12:57 +0100 [thread overview]
Message-ID: <356ec25f-b5e0-4b1b-bd0a-0d6cb9ae3c0c@broadcom.com> (raw)
In-Reply-To: <170902559101.3280425.2706190192200235643.kvalo@kernel.org>
[-- Attachment #1: Type: text/plain, Size: 1948 bytes --]
On 2/27/2024 10:19 AM, Kalle Valo wrote:
> "Gustavo A. R. Silva" <gustavoars@kernel.org> wrote:
>
>> Fix boot crash on Raspberry Pi by moving the update to `event->datalen`
>> before data is copied into flexible-array member `data` via `memcpy()`.
>>
>> Flexible-array member `data` was annotated with `__counted_by(datalen)`
>> in commit 62d19b358088 ("wifi: brcmfmac: fweh: Add __counted_by for
>> struct brcmf_fweh_queue_item and use struct_size()"). The intention of
>> this is to gain visibility into the size of `data` at run-time through
>> its _counter_ (in this case `datalen`), and with this have its accesses
>> bounds-checked at run-time via CONFIG_FORTIFY_SOURCE and
>> CONFIG_UBSAN_BOUNDS.
>>
>> To effectively accomplish the above, we shall update the counter
>> (`datalen`), before the first access to the flexible array (`data`),
>> which was also done in the mentioned commit.
>>
>> However, commit edec42821911 ("wifi: brcmfmac: allow per-vendor event
>> handling") inadvertently caused a buffer overflow, detected by
>> FORTIFY_SOURCE. It moved the `event->datalen = datalen;` update to after
>> the first `data` access, at which point `event->datalen` was not yet
>> updated from zero (after calling `kzalloc()`), leading to the overflow
>> issue.
>>
>> This fix repositions the `event->datalen = datalen;` update before
>> accessing `data`, restoring the intended buffer overflow protection. :)
>>
>> Fixes: edec42821911 ("wifi: brcmfmac: allow per-vendor event handling")
>> Reported-by: Nathan Chancellor <nathan@kernel.org>
>> Closes: https://gist.github.com/nathanchance/e22f681f3bfc467f15cdf6605021aaa6
>> Tested-by: Nathan Chancellor <nathan@kernel.org>
>> Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
>> Reviewed-by: Kees Cook <keescook@chromium.org>
>
> Arend, ack?
Figured Kees Cook was the trumping authority here, but here it is:
Acked-by: Arend van Spriel <arend.vanspriel@broadcom.com>
Gr. AvS
[-- Attachment #2: S/MIME Cryptographic Signature --]
[-- Type: application/pkcs7-signature, Size: 4219 bytes --]
next prev parent reply other threads:[~2024-02-27 11:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-02-16 19:27 Gustavo A. R. Silva
2024-02-16 21:42 ` Kees Cook
2024-02-27 9:19 ` Kalle Valo
2024-02-27 11:12 ` Arend van Spriel [this message]
2024-02-27 14:43 ` Kalle Valo
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=356ec25f-b5e0-4b1b-bd0a-0d6cb9ae3c0c@broadcom.com \
--to=arend.vanspriel@broadcom.com \
--cc=brcm80211-dev-list.pdl@broadcom.com \
--cc=brcm80211@lists.linux.dev \
--cc=gustavoars@kernel.org \
--cc=kvalo@kernel.org \
--cc=linux-hardening@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nathan@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
all inboxes | Powered by JetHome®