All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
@ 2018-08-20  7:37 Johannes Berg
  2018-08-20 10:27 ` Stanislaw Gruszka
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2018-08-20  7:37 UTC (permalink / raw)
  To: linux-wireless; +Cc: Stanislaw Gruszka, Grzegorz Duszyński, Johannes Berg

From: Johannes Berg <johannes.berg@intel.com>

Pointer arithmetic already adjusts by the size of the struct,
so the sizeof() calculation is wrong. This is basically the
same as Colin King's patch for similar code in the iwlwifi
driver.

Fixes: 230ebaa189af ("cfg80211: read wmm rules from regulatory database")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
---
 net/wireless/reg.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/net/wireless/reg.c b/net/wireless/reg.c
index 4fc66a117b7d..283902974fbf 100644
--- a/net/wireless/reg.c
+++ b/net/wireless/reg.c
@@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain *src_regd)
 			continue;
 
 		regd->reg_rules[i].wmm_rule = d_wmm +
-			(src_regd->reg_rules[i].wmm_rule - s_wmm) /
-			sizeof(struct ieee80211_wmm_rule);
+			(src_regd->reg_rules[i].wmm_rule - s_wmm);
 	}
 	return regd;
 }
-- 
2.14.4

^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-20  7:37 [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule) Johannes Berg
@ 2018-08-20 10:27 ` Stanislaw Gruszka
  2018-08-21  6:23   ` Grzegorz Duszyński
  0 siblings, 1 reply; 8+ messages in thread
From: Stanislaw Gruszka @ 2018-08-20 10:27 UTC (permalink / raw)
  To: Johannes Berg; +Cc: linux-wireless, Grzegorz Duszy??ski, Johannes Berg

On Mon, Aug 20, 2018 at 09:37:05AM +0200, Johannes Berg wrote:
> From: Johannes Berg <johannes.berg@intel.com>
> 
> Pointer arithmetic already adjusts by the size of the struct,
> so the sizeof() calculation is wrong. This is basically the
> same as Colin King's patch for similar code in the iwlwifi
> driver.
> 
> Fixes: 230ebaa189af ("cfg80211: read wmm rules from regulatory database")
> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
> ---
>  net/wireless/reg.c | 3 +--
>  1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
> index 4fc66a117b7d..283902974fbf 100644
> --- a/net/wireless/reg.c
> +++ b/net/wireless/reg.c
> @@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain *src_regd)
>  			continue;
>  
>  		regd->reg_rules[i].wmm_rule = d_wmm +
> -			(src_regd->reg_rules[i].wmm_rule - s_wmm) /
> -			sizeof(struct ieee80211_wmm_rule);
> +			(src_regd->reg_rules[i].wmm_rule - s_wmm);
>  	}
>  	return regd;
>  }

As side note those pointer aritmetics related with rule->wmm_rule is
really involuted in various places in reg.c . Seems would be better to
just make wmm_rule part of iee80211_reg_rule structure like this:

struct ieee80211_reg_rule {
        struct ieee80211_freq_range freq_range;
        struct ieee80211_power_rule power_rule;
        struct ieee80211_wmm_rule wmm_rule;
        u32 flags;
        u32 dfs_cac_ms;
};

and use a flag to intdicate wmm_rule is valid. There should be no
big memory overhead sice there are only few reg_rules for the regdomain.
Or I'm wrong?

Regards
Stanislaw

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-20 10:27 ` Stanislaw Gruszka
@ 2018-08-21  6:23   ` Grzegorz Duszyński
  2018-08-21  7:42     ` Grzegorz Duszyński
  2018-08-21  9:03     ` Johannes Berg
  0 siblings, 2 replies; 8+ messages in thread
From: Grzegorz Duszyński @ 2018-08-21  6:23 UTC (permalink / raw)
  To: Stanislaw Gruszka, Johannes Berg; +Cc: linux-wireless, Johannes Berg

On 20.08.2018 12:27, Stanislaw Gruszka wrote:
> On Mon, Aug 20, 2018 at 09:37:05AM +0200, Johannes Berg wrote:
>> From: Johannes Berg <johannes.berg@intel.com>
>>
>> Pointer arithmetic already adjusts by the size of the struct,
>> so the sizeof() calculation is wrong. This is basically the
>> same as Colin King's patch for similar code in the iwlwifi
>> driver.
>>
>> Fixes: 230ebaa189af ("cfg80211: read wmm rules from regulatory database")
>> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>> ---
>>   net/wireless/reg.c | 3 +--
>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>
>> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
>> index 4fc66a117b7d..283902974fbf 100644
>> --- a/net/wireless/reg.c
>> +++ b/net/wireless/reg.c
>> @@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain *src_regd)
>>   			continue;
>>   
>>   		regd->reg_rules[i].wmm_rule = d_wmm +
>> -			(src_regd->reg_rules[i].wmm_rule - s_wmm) /
>> -			sizeof(struct ieee80211_wmm_rule);
>> +			(src_regd->reg_rules[i].wmm_rule - s_wmm);
>>   	}
>>   	return regd;
>>   }
> As side note those pointer aritmetics related with rule->wmm_rule is
> really involuted in various places in reg.c . Seems would be better to
> just make wmm_rule part of iee80211_reg_rule structure like this:
>
> struct ieee80211_reg_rule {
>          struct ieee80211_freq_range freq_range;
>          struct ieee80211_power_rule power_rule;
>          struct ieee80211_wmm_rule wmm_rule;
>          u32 flags;
>          u32 dfs_cac_ms;
> };
>
> and use a flag to intdicate wmm_rule is valid. There should be no
> big memory overhead sice there are only few reg_rules for the regdomain.
> Or I'm wrong?
>
> Regards
> Stanislaw

Thank you for the patch.

I've applied the patch, but it does not seem to help.
Spawning second instance of hostapd causes same error as before.

I don't follow why this issue would not occur with single NIC.
It's not like I am an expert in this field, but those rules should be 
applied to both interfaces, right?
Both interfaces use ath10k, that should imply same code path for setting 
rules.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-21  6:23   ` Grzegorz Duszyński
@ 2018-08-21  7:42     ` Grzegorz Duszyński
  2018-08-21  9:03     ` Johannes Berg
  1 sibling, 0 replies; 8+ messages in thread
From: Grzegorz Duszyński @ 2018-08-21  7:42 UTC (permalink / raw)
  To: Stanislaw Gruszka, Johannes Berg; +Cc: linux-wireless, Johannes Berg

On 21.08.2018 08:23, Grzegorz Duszyński wrote:
> On 20.08.2018 12:27, Stanislaw Gruszka wrote:
>> On Mon, Aug 20, 2018 at 09:37:05AM +0200, Johannes Berg wrote:
>>> From: Johannes Berg <johannes.berg@intel.com>
>>>
>>> Pointer arithmetic already adjusts by the size of the struct,
>>> so the sizeof() calculation is wrong. This is basically the
>>> same as Colin King's patch for similar code in the iwlwifi
>>> driver.
>>>
>>> Fixes: 230ebaa189af ("cfg80211: read wmm rules from regulatory 
>>> database")
>>> Signed-off-by: Johannes Berg <johannes.berg@intel.com>
>>> ---
>>>   net/wireless/reg.c | 3 +--
>>>   1 file changed, 1 insertion(+), 2 deletions(-)
>>>
>>> diff --git a/net/wireless/reg.c b/net/wireless/reg.c
>>> index 4fc66a117b7d..283902974fbf 100644
>>> --- a/net/wireless/reg.c
>>> +++ b/net/wireless/reg.c
>>> @@ -452,8 +452,7 @@ reg_copy_regd(const struct ieee80211_regdomain 
>>> *src_regd)
>>>               continue;
>>>             regd->reg_rules[i].wmm_rule = d_wmm +
>>> -            (src_regd->reg_rules[i].wmm_rule - s_wmm) /
>>> -            sizeof(struct ieee80211_wmm_rule);
>>> +            (src_regd->reg_rules[i].wmm_rule - s_wmm);
>>>       }
>>>       return regd;
>>>   }
>> As side note those pointer aritmetics related with rule->wmm_rule is
>> really involuted in various places in reg.c . Seems would be better to
>> just make wmm_rule part of iee80211_reg_rule structure like this:
>>
>> struct ieee80211_reg_rule {
>>          struct ieee80211_freq_range freq_range;
>>          struct ieee80211_power_rule power_rule;
>>          struct ieee80211_wmm_rule wmm_rule;
>>          u32 flags;
>>          u32 dfs_cac_ms;
>> };
>>
>> and use a flag to intdicate wmm_rule is valid. There should be no
>> big memory overhead sice there are only few reg_rules for the regdomain.
>> Or I'm wrong?
>>
>> Regards
>> Stanislaw
>
> Thank you for the patch.
>
> I've applied the patch, but it does not seem to help.
> Spawning second instance of hostapd causes same error as before.
>
> I don't follow why this issue would not occur with single NIC.
> It's not like I am an expert in this field, but those rules should be 
> applied to both interfaces, right?
> Both interfaces use ath10k, that should imply same code path for 
> setting rules.
>

Issue has also been experienced by other Arch user:
https://bbs.archlinux.org/viewtopic.php?pid=1803445#p1803445

User chr0mag also reports that LTS version of Arch kernel does not 
exhibit this issue.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-21  6:23   ` Grzegorz Duszyński
  2018-08-21  7:42     ` Grzegorz Duszyński
@ 2018-08-21  9:03     ` Johannes Berg
  2018-08-21  9:06       ` Grzegorz Duszyński
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2018-08-21  9:03 UTC (permalink / raw)
  To: Grzegorz Duszyński, Stanislaw Gruszka; +Cc: linux-wireless

On Tue, 2018-08-21 at 08:23 +0200, Grzegorz Duszyński wrote:
> 
> I've applied the patch, but it does not seem to help.
> Spawning second instance of hostapd causes same error as before.

Ok, it was worth a try.

> I don't follow why this issue would not occur with single NIC.
> It's not like I am an expert in this field, but those rules should be 
> applied to both interfaces, right?
> Both interfaces use ath10k, that should imply same code path for setting 
> rules.

Yeah that's why I thought maybe the copy code was involved ...

I guess we'll need to try to reproduce. Maybe it can be made to happen
with hwsim too?

johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-21  9:03     ` Johannes Berg
@ 2018-08-21  9:06       ` Grzegorz Duszyński
  2018-08-21  9:07         ` Johannes Berg
  0 siblings, 1 reply; 8+ messages in thread
From: Grzegorz Duszyński @ 2018-08-21  9:06 UTC (permalink / raw)
  To: Johannes Berg, Stanislaw Gruszka; +Cc: linux-wireless

On 21.08.2018 11:03, Johannes Berg wrote:
> On Tue, 2018-08-21 at 08:23 +0200, Grzegorz Duszyński wrote:
>> I've applied the patch, but it does not seem to help.
>> Spawning second instance of hostapd causes same error as before.
> Ok, it was worth a try.
>
>> I don't follow why this issue would not occur with single NIC.
>> It's not like I am an expert in this field, but those rules should be
>> applied to both interfaces, right?
>> Both interfaces use ath10k, that should imply same code path for setting
>> rules.
> Yeah that's why I thought maybe the copy code was involved ...
>
> I guess we'll need to try to reproduce. Maybe it can be made to happen
> with hwsim too?
>
> johannes

I can try to recreate the issue with hwsim, it will take me some time 
probably as I have no prior experience.

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-21  9:06       ` Grzegorz Duszyński
@ 2018-08-21  9:07         ` Johannes Berg
  2018-08-21  9:11           ` Grzegorz Duszyński
  0 siblings, 1 reply; 8+ messages in thread
From: Johannes Berg @ 2018-08-21  9:07 UTC (permalink / raw)
  To: Grzegorz Duszyński, Stanislaw Gruszka; +Cc: linux-wireless


> I can try to recreate the issue with hwsim, it will take me some time 
> probably as I have no prior experience.

No worries, I'm compiling it now. Do you have a special hostapd
configuration?

johannes

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule)
  2018-08-21  9:07         ` Johannes Berg
@ 2018-08-21  9:11           ` Grzegorz Duszyński
  0 siblings, 0 replies; 8+ messages in thread
From: Grzegorz Duszyński @ 2018-08-21  9:11 UTC (permalink / raw)
  To: Johannes Berg, Stanislaw Gruszka; +Cc: linux-wireless

On 21.08.2018 11:07, Johannes Berg wrote:
>> I can try to recreate the issue with hwsim, it will take me some time
>> probably as I have no prior experience.
> No worries, I'm compiling it now. Do you have a special hostapd
> configuration?
>
> johannes

I think they are pretty standard:

Compex wle900vx:
https://pastebin.com/pkThTvWH

Killer 1535 - didn't have a chance to finish this one
https://pastebin.com/eJ3t36ra

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2018-08-21 12:30 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-20  7:37 [PATCH] cfg80211: remove division by size of sizeof(struct ieee80211_wmm_rule) Johannes Berg
2018-08-20 10:27 ` Stanislaw Gruszka
2018-08-21  6:23   ` Grzegorz Duszyński
2018-08-21  7:42     ` Grzegorz Duszyński
2018-08-21  9:03     ` Johannes Berg
2018-08-21  9:06       ` Grzegorz Duszyński
2018-08-21  9:07         ` Johannes Berg
2018-08-21  9:11           ` Grzegorz Duszyński

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.