public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Jerome Pouiller <Jerome.Pouiller@silabs.com>
To: Dan Carpenter <dan.carpenter@oracle.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"devel@driverdev.osuosl.org" <devel@driverdev.osuosl.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"kernel-janitors@vger.kernel.org"
	<kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] staging: wfx: check ssidlen and prevent an array overflow
Date: Fri, 24 Apr 2020 11:39:38 +0000	[thread overview]
Message-ID: <2664933.6YeKyBzJok@pc-42> (raw)
In-Reply-To: <20200424104235.GA416402@mwanda>

On Friday 24 April 2020 12:42:35 CEST Dan Carpenter wrote:
> 
> We need to cap "ssidlen" to prevent a memcpy() overflow.
> 
> Fixes: 40115bbc40e2 ("staging: wfx: implement the rest of mac80211 API")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> ---
>  drivers/staging/wfx/sta.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
> index c73dbb3a0de8c..3bff0f1e3d9ba 100644
> --- a/drivers/staging/wfx/sta.c
> +++ b/drivers/staging/wfx/sta.c
> @@ -479,7 +479,9 @@ static void wfx_do_join(struct wfx_vif *wvif)
>                 ssidie = ieee80211_bss_get_ie(bss, WLAN_EID_SSID);
>         if (ssidie) {
>                 ssidlen = ssidie[1];
> -               memcpy(ssid, &ssidie[2], ssidie[1]);
> +               if (ssidlen > IEEE80211_MAX_SSID_LEN)
> +                       ssidlen = IEEE80211_MAX_SSID_LEN;
I'd have a little preference for sizeof(ssid) instead of
IEEE80211_MAX_SSID_LEN, but ok.

> +               memcpy(ssid, &ssidie[2], ssidlen);
>         }
>         rcu_read_unlock();
> 
> --
> 2.26.1
> 

Reviewed-by: Jérôme Pouiller <jerome.pouiller@silabs.com>

-- 
Jérôme Pouiller


      reply	other threads:[~2020-04-24 11:39 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-24 10:42 [PATCH] staging: wfx: check ssidlen and prevent an array overflow Dan Carpenter
2020-04-24 11:39 ` Jerome Pouiller [this message]

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=2664933.6YeKyBzJok@pc-42 \
    --to=jerome.pouiller@silabs.com \
    --cc=dan.carpenter@oracle.com \
    --cc=devel@driverdev.osuosl.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@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