linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Cernekee <cernekee@chromium.org>
To: arend.vanspriel@broadcom.com, franky.lin@broadcom.com
Cc: brcm80211-dev-list.pdl@broadcom.com,
	linux-wireless@vger.kernel.org, mnissler@chromium.org
Subject: [PATCH V2 3/3] brcmfmac: Add check for short event packets
Date: Sat,  9 Sep 2017 12:30:20 -0700	[thread overview]
Message-ID: <20170909193020.19061-3-cernekee@chromium.org> (raw)
In-Reply-To: <20170909193020.19061-1-cernekee@chromium.org>

The length of the data in the received skb is currently passed into
brcmf_fweh_process_event() as packet_len, but this value is not checked.
event_packet should be followed by DATALEN bytes of additional event
data.  Ensure that the received packet actually contains at least
DATALEN bytes of additional data, to avoid copying uninitialized memory
into event->data.

Suggested-by: Mattias Nissler <mnissler@chromium.org>
Signed-off-by: Kevin Cernekee <cernekee@chromium.org>
Reviewed-by: Arend van Spriel <arend.vanspriel@broadcom.com>
---
 drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)


V1->V2: No change.


diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
index 27e661fa356f..28361bb865f3 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/fweh.c
@@ -424,7 +424,8 @@ void brcmf_fweh_process_event(struct brcmf_pub *drvr,
 	if (code != BRCMF_E_IF && !fweh->evt_handler[code])
 		return;
 
-	if (datalen > BRCMF_DCMD_MAXLEN)
+	if (datalen > BRCMF_DCMD_MAXLEN ||
+	    datalen + sizeof(*event_packet) < packet_len)
 		return;
 
 	if (in_interrupt())
-- 
2.14.1.581.gf28d330327-goog

  parent reply	other threads:[~2017-09-09 19:30 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-09 19:30 [PATCH V2 1/3] brcmfmac: Avoid possible out-of-bounds read Kevin Cernekee
2017-09-09 19:30 ` [PATCH V2 2/3] brcmfmac: Delete redundant length check Kevin Cernekee
2017-09-09 19:30 ` Kevin Cernekee [this message]
2017-09-12  7:45   ` [V2,3/3] brcmfmac: Add check for short event packets Kalle Valo
2017-09-10 18:50 ` [PATCH V2 1/3] brcmfmac: Avoid possible out-of-bounds read Arend van Spriel
2017-09-12  5:48   ` Kalle Valo
2017-09-12  7:36     ` Arend van Spriel
2017-09-12  7:47       ` Kalle Valo
2017-09-12  7:59         ` Arend van Spriel
2017-09-12  8:05           ` Kalle Valo
2017-09-12  8:18             ` Arend van Spriel
2017-09-12 12:33               ` Greg KH
2017-09-13  4:20                 ` 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=20170909193020.19061-3-cernekee@chromium.org \
    --to=cernekee@chromium.org \
    --cc=arend.vanspriel@broadcom.com \
    --cc=brcm80211-dev-list.pdl@broadcom.com \
    --cc=franky.lin@broadcom.com \
    --cc=linux-wireless@vger.kernel.org \
    --cc=mnissler@chromium.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).