From: Ajay Singh <ajay.kathat@microchip.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Ganesh Krishna <ganesh.krishna@microchip.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-wireless@vger.kernel.org, devel@driverdev.osuosl.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access
Date: Mon, 30 Apr 2018 14:41:16 +0000 [thread overview]
Message-ID: <20180430195916.596a93eb@ajaysk-VirtualBox> (raw)
In-Reply-To: <20180430125040.GA19050@embeddedor.com>
Reviewed-by: Ajay Singh <ajay.kathat@microchip.com>
On Mon, 30 Apr 2018 07:50:40 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> If i < slot_id is initially true then it will remain true. Also,
> as i is being decremented it will end up accessing memory out of
> bounds.
>
> Fix this by incrementing *i* instead of decrementing it.
Nice catch!
Thanks for submitting the changes.
>
> Addresses-Coverity-ID: 1468454 ("Infinite loop")
> Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free
> kmalloc memory on failure cases")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>
> BTW... at first sight it seems to me that variables slot_id
> and i should be of type unsigned instead of signed.
Yes, 'slot_id' & 'i' can be changed to unsigned int.
>
> drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index
> 3ca0c97..67104e8 100644 ---
> a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -608,7
> +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request
> *request, out_free:
>
> - for (i = 0; i < slot_id ; i--)
> + for (i = 0; i < slot_id; i++)
> kfree(ntwk->net_info[i].ssid);
>
> kfree(ntwk->net_info);
Regards,
Ajay
WARNING: multiple messages have this Message-ID (diff)
From: Ajay Singh <ajay.kathat@microchip.com>
To: "Gustavo A. R. Silva" <gustavo@embeddedor.com>
Cc: Ganesh Krishna <ganesh.krishna@microchip.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
<linux-wireless@vger.kernel.org>, <devel@driverdev.osuosl.org>,
<linux-kernel@vger.kernel.org>, <kernel-janitors@vger.kernel.org>
Subject: Re: [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access
Date: Mon, 30 Apr 2018 19:59:16 +0530 [thread overview]
Message-ID: <20180430195916.596a93eb@ajaysk-VirtualBox> (raw)
In-Reply-To: <20180430125040.GA19050@embeddedor.com>
Reviewed-by: Ajay Singh <ajay.kathat@microchip.com>
On Mon, 30 Apr 2018 07:50:40 -0500
"Gustavo A. R. Silva" <gustavo@embeddedor.com> wrote:
> If i < slot_id is initially true then it will remain true. Also,
> as i is being decremented it will end up accessing memory out of
> bounds.
>
> Fix this by incrementing *i* instead of decrementing it.
Nice catch!
Thanks for submitting the changes.
>
> Addresses-Coverity-ID: 1468454 ("Infinite loop")
> Fixes: faa657641081 ("staging: wilc1000: refactor scan() to free
> kmalloc memory on failure cases")
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
>
> BTW... at first sight it seems to me that variables slot_id
> and i should be of type unsigned instead of signed.
Yes, 'slot_id' & 'i' can be changed to unsigned int.
>
> drivers/staging/wilc1000/wilc_wfi_cfgoperations.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c index
> 3ca0c97..67104e8 100644 ---
> a/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c +++
> b/drivers/staging/wilc1000/wilc_wfi_cfgoperations.c @@ -608,7
> +608,7 @@ wilc_wfi_cfg_alloc_fill_ssid(struct cfg80211_scan_request
> *request, out_free:
>
> - for (i = 0; i < slot_id ; i--)
> + for (i = 0; i < slot_id; i++)
> kfree(ntwk->net_info[i].ssid);
>
> kfree(ntwk->net_info);
Regards,
Ajay
next prev parent reply other threads:[~2018-04-30 14:41 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-04-30 12:50 [PATCH] staging: wilc1000: fix infinite loop and out-of-bounds access Gustavo A. R. Silva
2018-04-30 12:50 ` Gustavo A. R. Silva
2018-04-30 12:50 ` Gustavo A. R. Silva
2018-04-30 14:29 ` Ajay Singh [this message]
2018-04-30 14:41 ` Ajay Singh
2018-04-30 15:23 ` Dan Carpenter
2018-04-30 15:23 ` Dan Carpenter
2018-04-30 15:23 ` Dan Carpenter
2018-05-02 5:47 ` Ajay Singh
2018-05-02 5:59 ` Ajay Singh
2018-05-02 5:47 ` Ajay Singh
2018-05-02 8:39 ` Dan Carpenter
2018-05-02 8:39 ` Dan Carpenter
2018-05-02 8:39 ` Dan Carpenter
2018-05-02 9:42 ` Ajay Singh
2018-05-02 9:54 ` Ajay Singh
2018-05-02 9:42 ` Ajay Singh
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=20180430195916.596a93eb@ajaysk-VirtualBox \
--to=ajay.kathat@microchip.com \
--cc=devel@driverdev.osuosl.org \
--cc=ganesh.krishna@microchip.com \
--cc=gregkh@linuxfoundation.org \
--cc=gustavo@embeddedor.com \
--cc=kernel-janitors@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.