All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] mwl8k: fix possible race condition in info->control.sta use
@ 2012-07-11  5:32 Thomas Huehn
  2012-07-11  8:44 ` Christian Lamparter
  0 siblings, 1 reply; 3+ messages in thread
From: Thomas Huehn @ 2012-07-11  5:32 UTC (permalink / raw)
  To: linville; +Cc: linux-wireless, buytenh, nbd, thomas

info->control.sta may only be dereferenced during the drv_tx call otherwise
could lead to use-after-free bugs

Reported-by: Felix Fietkau <nbd@nbd.name>
Signed-off-by: Thomas Huehn <thomas@net.t-labs.tu-berlin.de>
---
fix wrog indentation. thx to David Miller
---
 drivers/net/wireless/mwl8k.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
index df6c6f1..eec5cd1 100644
--- a/drivers/net/wireless/mwl8k.c
+++ b/drivers/net/wireless/mwl8k.c
@@ -1667,7 +1667,8 @@ mwl8k_txq_reclaim(struct ieee80211_hw *hw,
 
 		info = IEEE80211_SKB_CB(skb);
 		if (ieee80211_is_data(wh->frame_control)) {
-			sta = info->control.sta;
+			sta = ieee80211_find_sta_by_ifaddr(hw, wh->addr1,
+							   wh->addr2);
 			if (sta) {
 				sta_info = MWL8K_STA(sta);
 				BUG_ON(sta_info == NULL);
-- 
1.7.11.1


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

* Re: [PATCH v2] mwl8k: fix possible race condition in info->control.sta use
  2012-07-11  5:32 [PATCH v2] mwl8k: fix possible race condition in info->control.sta use Thomas Huehn
@ 2012-07-11  8:44 ` Christian Lamparter
  2012-07-11 11:15   ` Thomas Huehn
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Lamparter @ 2012-07-11  8:44 UTC (permalink / raw)
  To: Thomas Huehn; +Cc: linville, linux-wireless, buytenh, nbd

On Wed, Jul 11, 2012 at 7:32 AM, Thomas Huehn
<thomas@net.t-labs.tu-berlin.de> wrote:
> info->control.sta may only be dereferenced during the drv_tx call otherwise
> could lead to use-after-free bugs

Don"t forget many ieee80211_sta_* functions have to be called under RCU
lock and the resulting pointer is only valid under RCU lock as well.

>
> diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
> index df6c6f1..eec5cd1 100644
> --- a/drivers/net/wireless/mwl8k.c
> +++ b/drivers/net/wireless/mwl8k.c
> @@ -1667,7 +1667,8 @@ mwl8k_txq_reclaim(struct ieee80211_hw *hw,
>
>                 info = IEEE80211_SKB_CB(skb);
>                 if (ieee80211_is_data(wh->frame_control)) {

+                         rcu_read_lock();

> -                       sta = info->control.sta;
> +                       sta = ieee80211_find_sta_by_ifaddr(hw, wh->addr1,
> +                                                          wh->addr2);
>                         if (sta) {
>                                 sta_info = MWL8K_STA(sta);
>                                 BUG_ON(sta_info == NULL);
>                                 [...]
>                         }

+                         rcu_read_unlock();

Regards,
      Chr

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

* Re: [PATCH v2] mwl8k: fix possible race condition in info->control.sta use
  2012-07-11  8:44 ` Christian Lamparter
@ 2012-07-11 11:15   ` Thomas Huehn
  0 siblings, 0 replies; 3+ messages in thread
From: Thomas Huehn @ 2012-07-11 11:15 UTC (permalink / raw)
  To: Christian Lamparter; +Cc: linville, linux-wireless, buytenh, nbd

Hi Christian,

You have a very valid point here.
I will send a v3.

Greetings Thomas

Christian Lamparter schrieb:

> On Wed, Jul 11, 2012 at 7:32 AM, Thomas Huehn
> <thomas@net.t-labs.tu-berlin.de> wrote:
>> info->control.sta may only be dereferenced during the drv_tx call otherwise
>> could lead to use-after-free bugs
> 
> Don"t forget many ieee80211_sta_* functions have to be called under RCU
> lock and the resulting pointer is only valid under RCU lock as well.
> 
>> diff --git a/drivers/net/wireless/mwl8k.c b/drivers/net/wireless/mwl8k.c
>> index df6c6f1..eec5cd1 100644
>> --- a/drivers/net/wireless/mwl8k.c
>> +++ b/drivers/net/wireless/mwl8k.c
>> @@ -1667,7 +1667,8 @@ mwl8k_txq_reclaim(struct ieee80211_hw *hw,
>>
>>                 info = IEEE80211_SKB_CB(skb);
>>                 if (ieee80211_is_data(wh->frame_control)) {
> 
> +                         rcu_read_lock();
> 
>> -                       sta = info->control.sta;
>> +                       sta = ieee80211_find_sta_by_ifaddr(hw, wh->addr1,
>> +                                                          wh->addr2);
>>                         if (sta) {
>>                                 sta_info = MWL8K_STA(sta);
>>                                 BUG_ON(sta_info == NULL);
>>                                 [...]
>>                         }
> 
> +                         rcu_read_unlock();
> 
> Regards,
>       Chr
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html


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

end of thread, other threads:[~2012-07-11 11:15 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-07-11  5:32 [PATCH v2] mwl8k: fix possible race condition in info->control.sta use Thomas Huehn
2012-07-11  8:44 ` Christian Lamparter
2012-07-11 11:15   ` Thomas Huehn

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.