All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-06  7:14 Daniel J Blueman
  2017-03-06 13:00   ` Arend Van Spriel
  0 siblings, 1 reply; 8+ messages in thread
From: Daniel J Blueman @ 2017-03-06  7:14 UTC (permalink / raw)
  To: Hante Meuleman, Arend Van Spriel, Pieter-Paul Giesberts
  Cc: Netdev, David Miller

KASAN reported 'struct wireless_dev wdev' was read after being freed.
Fix by freeing after the access.

Signed-off-by: Daniel J Blueman <daniel@quora.org>

diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
index de19c7c..aa0f470 100644
--- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
+++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
@@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
struct wireless_dev *wdev)
                else
                        err = 0;
        }
-       brcmf_remove_interface(vif->ifp, true);

-       brcmf_cfg80211_arm_vif_event(cfg, NULL);
        if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
                p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;

+       brcmf_remove_interface(vif->ifp, true);
+       brcmf_cfg80211_arm_vif_event(cfg, NULL);
+
        return err;
 }
-- 
Daniel J Blueman

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-06 13:00   ` Arend Van Spriel
  0 siblings, 0 replies; 8+ messages in thread
From: Arend Van Spriel @ 2017-03-06 13:00 UTC (permalink / raw)
  To: Daniel J Blueman, Hante Meuleman, Pieter-Paul Giesberts
  Cc: Netdev, David Miller, linux-wireless

+ linux-wireless

On 6-3-2017 8:14, Daniel J Blueman wrote:
> KASAN reported 'struct wireless_dev wdev' was read after being freed.
> Fix by freeing after the access.

I would rather like to see the KASAN report, because something is off
here. This function is called with wdev as a parameter so how can it be
accessed after free here? brcmf_remove_interface() does not free the
wdev nor the brcmf_cfg80211_vif instance which contains the wdev.

Regards,
Arend

> Signed-off-by: Daniel J Blueman <daniel@quora.org>
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> index de19c7c..aa0f470 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
> struct wireless_dev *wdev)
>                 else
>                         err = 0;
>         }
> -       brcmf_remove_interface(vif->ifp, true);
> 
> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
> 
> +       brcmf_remove_interface(vif->ifp, true);
> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
> +
>         return err;
>  }
> 

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-06 13:00   ` Arend Van Spriel
  0 siblings, 0 replies; 8+ messages in thread
From: Arend Van Spriel @ 2017-03-06 13:00 UTC (permalink / raw)
  To: Daniel J Blueman, Hante Meuleman, Pieter-Paul Giesberts
  Cc: Netdev, David Miller, linux-wireless

+ linux-wireless

On 6-3-2017 8:14, Daniel J Blueman wrote:
> KASAN reported 'struct wireless_dev wdev' was read after being freed.
> Fix by freeing after the access.

I would rather like to see the KASAN report, because something is off
here. This function is called with wdev as a parameter so how can it be
accessed after free here? brcmf_remove_interface() does not free the
wdev nor the brcmf_cfg80211_vif instance which contains the wdev.

Regards,
Arend

> Signed-off-by: Daniel J Blueman <daniel-JCXMqzvhRcvYtjvyW6yDsg@public.gmane.org>
> 
> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> index de19c7c..aa0f470 100644
> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
> struct wireless_dev *wdev)
>                 else
>                         err = 0;
>         }
> -       brcmf_remove_interface(vif->ifp, true);
> 
> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
> 
> +       brcmf_remove_interface(vif->ifp, true);
> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
> +
>         return err;
>  }
> 

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-06 14:50     ` Daniel J Blueman
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel J Blueman @ 2017-03-06 14:50 UTC (permalink / raw)
  To: Arend Van Spriel
  Cc: Hante Meuleman, Pieter-Paul Giesberts, Netdev, David Miller,
	linux-wireless

On 6 March 2017 at 21:00, Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:
> + linux-wireless
>
> On 6-3-2017 8:14, Daniel J Blueman wrote:
>> KASAN reported 'struct wireless_dev wdev' was read after being freed.
>> Fix by freeing after the access.
>
> I would rather like to see the KASAN report, because something is off
> here. This function is called with wdev as a parameter so how can it be
> accessed after free here? brcmf_remove_interface() does not free the
> wdev nor the brcmf_cfg80211_vif instance which contains the wdev.
>
> Regards,
> Arend
>
>> Signed-off-by: Daniel J Blueman <daniel@quora.org>
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> index de19c7c..aa0f470 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
>> struct wireless_dev *wdev)
>>                 else
>>                         err = 0;
>>         }
>> -       brcmf_remove_interface(vif->ifp, true);
>>
>> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
>>
>> +       brcmf_remove_interface(vif->ifp, true);
>> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>> +
>>         return err;
>>  }

Sure, https://quora.org/kernel/brcmfmac/dmesg.txt

vmlinux, cfg80211.o, brcmfmac.o and config are in the same path; this
is against v4.9.13 stock.

Thanks,
  Daniel
-- 
Daniel J Blueman

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-06 14:50     ` Daniel J Blueman
  0 siblings, 0 replies; 8+ messages in thread
From: Daniel J Blueman @ 2017-03-06 14:50 UTC (permalink / raw)
  To: Arend Van Spriel
  Cc: Hante Meuleman, Pieter-Paul Giesberts, Netdev, David Miller,
	linux-wireless

On 6 March 2017 at 21:00, Arend Van Spriel <arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> wrote:
> + linux-wireless
>
> On 6-3-2017 8:14, Daniel J Blueman wrote:
>> KASAN reported 'struct wireless_dev wdev' was read after being freed.
>> Fix by freeing after the access.
>
> I would rather like to see the KASAN report, because something is off
> here. This function is called with wdev as a parameter so how can it be
> accessed after free here? brcmf_remove_interface() does not free the
> wdev nor the brcmf_cfg80211_vif instance which contains the wdev.
>
> Regards,
> Arend
>
>> Signed-off-by: Daniel J Blueman <daniel-JCXMqzvhRcvYtjvyW6yDsg@public.gmane.org>
>>
>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> index de19c7c..aa0f470 100644
>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
>> struct wireless_dev *wdev)
>>                 else
>>                         err = 0;
>>         }
>> -       brcmf_remove_interface(vif->ifp, true);
>>
>> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
>>
>> +       brcmf_remove_interface(vif->ifp, true);
>> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>> +
>>         return err;
>>  }

Sure, https://quora.org/kernel/brcmfmac/dmesg.txt

vmlinux, cfg80211.o, brcmfmac.o and config are in the same path; this
is against v4.9.13 stock.

Thanks,
  Daniel
-- 
Daniel J Blueman

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-13  9:33       ` Arend Van Spriel
  0 siblings, 0 replies; 8+ messages in thread
From: Arend Van Spriel @ 2017-03-13  9:33 UTC (permalink / raw)
  To: Daniel J Blueman
  Cc: Hante Meuleman, Pieter-Paul Giesberts, Netdev, David Miller,
	linux-wireless

On 6-3-2017 15:50, Daniel J Blueman wrote:
> On 6 March 2017 at 21:00, Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:
>> + linux-wireless
>>
>> On 6-3-2017 8:14, Daniel J Blueman wrote:
>>> KASAN reported 'struct wireless_dev wdev' was read after being freed.
>>> Fix by freeing after the access.
>>
>> I would rather like to see the KASAN report, because something is off
>> here. This function is called with wdev as a parameter so how can it be
>> accessed after free here? brcmf_remove_interface() does not free the
>> wdev nor the brcmf_cfg80211_vif instance which contains the wdev.
>>
>> Regards,
>> Arend
>>
>>> Signed-off-by: Daniel J Blueman <daniel@quora.org>
>>>
>>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> index de19c7c..aa0f470 100644
>>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
>>> struct wireless_dev *wdev)
>>>                 else
>>>                         err = 0;
>>>         }
>>> -       brcmf_remove_interface(vif->ifp, true);
>>>
>>> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>>>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
>>>
>>> +       brcmf_remove_interface(vif->ifp, true);
>>> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>> +
>>>         return err;
>>>  }
> 
> Sure, https://quora.org/kernel/brcmfmac/dmesg.txt

So this dmesg looks to be about a separate issue during resume, which
you sent an email about earlier [1] which is about using wiphy struct
after free. However, back to this I further checked the code and it
seems the vif is indeed freed through the netdev destructor callback
upon calling brcmf_remove_inteface(). However, I would prefer to store
vif->wdev.iftype in a local variable and avoid changing the order of the
calls in the code.

Regards,
Arend

[1] http://marc.info/?l=linux-netdev&m=148878437808750&w=2

> vmlinux, cfg80211.o, brcmfmac.o and config are in the same path; this
> is against v4.9.13 stock.

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
@ 2017-03-13  9:33       ` Arend Van Spriel
  0 siblings, 0 replies; 8+ messages in thread
From: Arend Van Spriel @ 2017-03-13  9:33 UTC (permalink / raw)
  To: Daniel J Blueman
  Cc: Hante Meuleman, Pieter-Paul Giesberts, Netdev, David Miller,
	linux-wireless

On 6-3-2017 15:50, Daniel J Blueman wrote:
> On 6 March 2017 at 21:00, Arend Van Spriel <arend.vanspriel-dY08KVG/lbpWk0Htik3J/w@public.gmane.org> wrote:
>> + linux-wireless
>>
>> On 6-3-2017 8:14, Daniel J Blueman wrote:
>>> KASAN reported 'struct wireless_dev wdev' was read after being freed.
>>> Fix by freeing after the access.
>>
>> I would rather like to see the KASAN report, because something is off
>> here. This function is called with wdev as a parameter so how can it be
>> accessed after free here? brcmf_remove_interface() does not free the
>> wdev nor the brcmf_cfg80211_vif instance which contains the wdev.
>>
>> Regards,
>> Arend
>>
>>> Signed-off-by: Daniel J Blueman <daniel-JCXMqzvhRcvYtjvyW6yDsg@public.gmane.org>
>>>
>>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> index de19c7c..aa0f470 100644
>>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
>>> struct wireless_dev *wdev)
>>>                 else
>>>                         err = 0;
>>>         }
>>> -       brcmf_remove_interface(vif->ifp, true);
>>>
>>> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>>>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
>>>
>>> +       brcmf_remove_interface(vif->ifp, true);
>>> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>> +
>>>         return err;
>>>  }
> 
> Sure, https://quora.org/kernel/brcmfmac/dmesg.txt

So this dmesg looks to be about a separate issue during resume, which
you sent an email about earlier [1] which is about using wiphy struct
after free. However, back to this I further checked the code and it
seems the vif is indeed freed through the netdev destructor callback
upon calling brcmf_remove_inteface(). However, I would prefer to store
vif->wdev.iftype in a local variable and avoid changing the order of the
calls in the code.

Regards,
Arend

[1] http://marc.info/?l=linux-netdev&m=148878437808750&w=2

> vmlinux, cfg80211.o, brcmfmac.o and config are in the same path; this
> is against v4.9.13 stock.

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

* Re: [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume
  2017-03-13  9:33       ` Arend Van Spriel
  (?)
@ 2017-03-13  9:41       ` Arend Van Spriel
  -1 siblings, 0 replies; 8+ messages in thread
From: Arend Van Spriel @ 2017-03-13  9:41 UTC (permalink / raw)
  To: Daniel J Blueman
  Cc: Hante Meuleman, Pieter-Paul Giesberts, Netdev, David Miller,
	linux-wireless

On 13-3-2017 10:33, Arend Van Spriel wrote:
> On 6-3-2017 15:50, Daniel J Blueman wrote:
>> On 6 March 2017 at 21:00, Arend Van Spriel <arend.vanspriel@broadcom.com> wrote:
>>> + linux-wireless
>>>
>>> On 6-3-2017 8:14, Daniel J Blueman wrote:
>>>> KASAN reported 'struct wireless_dev wdev' was read after being freed.
>>>> Fix by freeing after the access.
>>>
>>> I would rather like to see the KASAN report, because something is off
>>> here. This function is called with wdev as a parameter so how can it be
>>> accessed after free here? brcmf_remove_interface() does not free the
>>> wdev nor the brcmf_cfg80211_vif instance which contains the wdev.
>>>
>>> Regards,
>>> Arend
>>>
>>>> Signed-off-by: Daniel J Blueman <daniel@quora.org>
>>>>
>>>> diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>>> b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>>> index de19c7c..aa0f470 100644
>>>> --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>>> +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
>>>> @@ -2288,12 +2288,13 @@ int brcmf_p2p_del_vif(struct wiphy *wiphy,
>>>> struct wireless_dev *wdev)
>>>>                 else
>>>>                         err = 0;
>>>>         }
>>>> -       brcmf_remove_interface(vif->ifp, true);
>>>>
>>>> -       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>>>         if (vif->wdev.iftype != NL80211_IFTYPE_P2P_DEVICE)
>>>>                 p2p->bss_idx[P2PAPI_BSSCFG_CONNECTION].vif = NULL;
>>>>
>>>> +       brcmf_remove_interface(vif->ifp, true);
>>>> +       brcmf_cfg80211_arm_vif_event(cfg, NULL);
>>>> +
>>>>         return err;
>>>>  }
>>
>> Sure, https://quora.org/kernel/brcmfmac/dmesg.txt
> 
> So this dmesg looks to be about a separate issue during resume, which
> you sent an email about earlier [1] which is about using wiphy struct
> after free. However, back to this I further checked the code and it
> seems the vif is indeed freed through the netdev destructor callback
> upon calling brcmf_remove_inteface(). However, I would prefer to store
> vif->wdev.iftype in a local variable and avoid changing the order of the
> calls in the code.

Forgot to mention some things about the commit message. Please drop the
the kernel version from the subject. You should create the patch against
the wireless-drivers tree and indicate the patch is for 4.11, ie.
"[PATCH for-4.11] brcmfmac: fix use-after-free of wireless_dev
instance". Also add as much useful information in the commit message as
possible like the proper KASAN report or at least mention that
brcmf_remove_interface() does an unregister_netdev() which results in
freeing the wireless_dev through netdev destructor callback.

Regards,
Arend

> Regards,
> Arend
> 
> [1] http://marc.info/?l=linux-netdev&m=148878437808750&w=2
> 
>> vmlinux, cfg80211.o, brcmfmac.o and config are in the same path; this
>> is against v4.9.13 stock.
> 

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

end of thread, other threads:[~2017-03-13  9:42 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-03-06  7:14 [PATCH] 4.9.13 brcmfmac: fix use-after-free on resume Daniel J Blueman
2017-03-06 13:00 ` Arend Van Spriel
2017-03-06 13:00   ` Arend Van Spriel
2017-03-06 14:50   ` Daniel J Blueman
2017-03-06 14:50     ` Daniel J Blueman
2017-03-13  9:33     ` Arend Van Spriel
2017-03-13  9:33       ` Arend Van Spriel
2017-03-13  9:41       ` Arend Van Spriel

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.