Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1207266 > unrolled thread
| Started by | Adrien Schildknecht <adrien+dev@schischi.me> |
|---|---|
| First post | 2015-08-14 02:40 +0200 |
| Last post | 2015-08-14 11:10 +0200 |
| Articles | 5 — 3 participants |
Back to article view | Back to linux.kernel
[PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels Adrien Schildknecht <adrien+dev@schischi.me> - 2015-08-14 02:40 +0200
Re: [PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels "Grumbach, Emmanuel" <emmanuel.grumbach@intel.com> - 2015-08-14 06:40 +0200
Re: [PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels Adrien Schildknecht <adrien+dev@schischi.me> - 2015-08-14 09:10 +0200
Re: [PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels Kalle Valo <kvalo@codeaurora.org> - 2015-08-14 09:20 +0200
[PATCH v2] iwlwifi: out-of-bounds access in iwl_init_sband_channels Adrien Schildknecht <adrien+dev@schischi.me> - 2015-08-14 11:10 +0200
| From | Adrien Schildknecht <adrien+dev@schischi.me> |
|---|---|
| Date | 2015-08-14 02:40 +0200 |
| Subject | [PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels |
| Message-ID | <pXbcl-2JF-7@gated-at.bofh.it> |
Both loops of this function compare data from the 'chan' array and then
check if the index is valid.
The 2 conditions should be inverted to avoid an out-of-bounds access.
Signed-off-by: Adrien Schildknecht <adrien+dev@schischi.me>
---
drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
index 21302b6..acc3d18 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
@@ -713,12 +713,12 @@ int iwl_init_sband_channels(struct iwl_nvm_data *data,
struct ieee80211_channel *chan = &data->channels[0];
int n = 0, idx = 0;
- while (chan->band != band && idx < n_channels)
+ while (idx < n_channels && chan->band != band)
chan = &data->channels[++idx];
sband->channels = &data->channels[idx];
- while (chan->band == band && idx < n_channels) {
+ while (idx < n_channels && chan->band == band) {
chan = &data->channels[++idx];
n++;
}
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [next] | [standalone]
| From | "Grumbach, Emmanuel" <emmanuel.grumbach@intel.com> |
|---|---|
| Date | 2015-08-14 06:40 +0200 |
| Message-ID | <pXeWC-8cx-5@gated-at.bofh.it> |
| In reply to | #1207266 |
Hi,
On 08/14/2015 03:36 AM, Adrien Schildknecht wrote:
> Both loops of this function compare data from the 'chan' array and then
> check if the index is valid.
>
> The 2 conditions should be inverted to avoid an out-of-bounds access.
>
Was that found by a static analyzer or any other automated tool, or was
that the result of your very careful review?
> Signed-off-by: Adrien Schildknecht <adrien+dev@schischi.me>
> ---
> drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
> index 21302b6..acc3d18 100644
> --- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
> +++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
> @@ -713,12 +713,12 @@ int iwl_init_sband_channels(struct iwl_nvm_data *data,
> struct ieee80211_channel *chan = &data->channels[0];
> int n = 0, idx = 0;
>
> - while (chan->band != band && idx < n_channels)
> + while (idx < n_channels && chan->band != band)
> chan = &data->channels[++idx];
>
> sband->channels = &data->channels[idx];
>
> - while (chan->band == band && idx < n_channels) {
> + while (idx < n_channels && chan->band == band) {
> chan = &data->channels[++idx];
> n++;
> }
>
Looks fine - I'll pick it up.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Adrien Schildknecht <adrien+dev@schischi.me> |
|---|---|
| Date | 2015-08-14 09:10 +0200 |
| Subject | Re: [PATCH] iwlwifi: out-of-bounds access in iwl_init_sband_channels |
| Message-ID | <pXhhM-3ku-3@gated-at.bofh.it> |
| In reply to | #1207328 |
Hi, > On 08/14/2015 03:36 AM, Adrien Schildknecht wrote: > > Both loops of this function compare data from the 'chan' array and > > then check if the index is valid. > > > > The 2 conditions should be inverted to avoid an out-of-bounds > > access. > > > > Was that found by a static analyzer or any other automated tool, or > was that the result of your very careful review? The error has been reported by KASan: ================================================================== BUG: KASan: out of bounds access in iwl_init_sband_channels+0x207/0x260 [iwlwifi] at addr ffff8800c2d0aac8 Read of size 4 by task modprobe/329 ================================================================== -- Adrien Schildknecht -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Kalle Valo <kvalo@codeaurora.org> |
|---|---|
| Date | 2015-08-14 09:20 +0200 |
| Message-ID | <pXhrr-3w7-7@gated-at.bofh.it> |
| In reply to | #1207366 |
Adrien Schildknecht <adrien+dev@schischi.me> writes: > Hi, > >> On 08/14/2015 03:36 AM, Adrien Schildknecht wrote: >> > Both loops of this function compare data from the 'chan' array and >> > then check if the index is valid. >> > >> > The 2 conditions should be inverted to avoid an out-of-bounds >> > access. >> > >> >> Was that found by a static analyzer or any other automated tool, or >> was that the result of your very careful review? > > The error has been reported by KASan: > ================================================================== > BUG: KASan: out of bounds access in iwl_init_sband_channels+0x207/0x260 [iwlwifi] at addr ffff8800c2d0aac8 > Read of size 4 by task modprobe/329 > ================================================================== Always try to add information like this to the commit log, it's very useful. -- Kalle Valo -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [next] | [standalone]
| From | Adrien Schildknecht <adrien+dev@schischi.me> |
|---|---|
| Date | 2015-08-14 11:10 +0200 |
| Subject | [PATCH v2] iwlwifi: out-of-bounds access in iwl_init_sband_channels |
| Message-ID | <pXj9U-618-3@gated-at.bofh.it> |
| In reply to | #1207371 |
KASan error report:
==================================================================
BUG: KASan: out of bounds access in iwl_init_sband_channels+0x207/0x260 [iwlwifi] at addr ffff8800c2d0aac8
Read of size 4 by task modprobe/329
==================================================================
Both loops of this function compare data from the 'chan' array and then
check if the index is valid.
The 2 conditions should be inverted to avoid an out-of-bounds access.
Signed-off-by: Adrien Schildknecht <adrien+dev@schischi.me>
---
drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
index 21302b6..acc3d18 100644
--- a/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
+++ b/drivers/net/wireless/iwlwifi/iwl-eeprom-parse.c
@@ -713,12 +713,12 @@ int iwl_init_sband_channels(struct iwl_nvm_data *data,
struct ieee80211_channel *chan = &data->channels[0];
int n = 0, idx = 0;
- while (chan->band != band && idx < n_channels)
+ while (idx < n_channels && chan->band != band)
chan = &data->channels[++idx];
sband->channels = &data->channels[idx];
- while (chan->band == band && idx < n_channels) {
+ while (idx < n_channels && chan->band == band) {
chan = &data->channels[++idx];
n++;
}
--
2.5.0
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web