linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2] mac80211: mlme: check for null after calling kmemdup
@ 2022-01-05  1:33 Jiasheng Jiang
  2022-01-05  7:49 ` Johannes Berg
  0 siblings, 1 reply; 2+ messages in thread
From: Jiasheng Jiang @ 2022-01-05  1:33 UTC (permalink / raw)
  To: johannes, davem, kuba
  Cc: linux-wireless, netdev, linux-kernel, Jiasheng Jiang

As the possible failure of the alloc, the ifmgd->assoc_req_ies might be
NULL pointer returned from kmemdup().
Therefore it might be better to free the skb and return in order to fail
the association, like ieee80211_assoc_success().

Fixes: 4d9ec73d2b78 ("cfg80211: Report Association Request frame IEs in association events")
Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
---
v2: Change to fail the association if kmemdup returns NULL.
---
 net/mac80211/mlme.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
index 9bed6464c5bd..b5dfdf953286 100644
--- a/net/mac80211/mlme.c
+++ b/net/mac80211/mlme.c
@@ -1058,6 +1058,11 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
 	pos = skb_tail_pointer(skb);
 	kfree(ifmgd->assoc_req_ies);
 	ifmgd->assoc_req_ies = kmemdup(ie_start, pos - ie_start, GFP_ATOMIC);
+	if (!ifmgd->assoc_req_ies) {
+		dev_kfree_skb(skb);
+		return;
+	}
+
 	ifmgd->assoc_req_ies_len = pos - ie_start;
 
 	drv_mgd_prepare_tx(local, sdata, 0);
-- 
2.25.1


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

* Re: [PATCH v2] mac80211: mlme: check for null after calling kmemdup
  2022-01-05  1:33 [PATCH v2] mac80211: mlme: check for null after calling kmemdup Jiasheng Jiang
@ 2022-01-05  7:49 ` Johannes Berg
  0 siblings, 0 replies; 2+ messages in thread
From: Johannes Berg @ 2022-01-05  7:49 UTC (permalink / raw)
  To: Jiasheng Jiang, davem, kuba; +Cc: linux-wireless, netdev, linux-kernel

On Wed, 2022-01-05 at 09:33 +0800, Jiasheng Jiang wrote:
> As the possible failure of the alloc, the ifmgd->assoc_req_ies might be
> NULL pointer returned from kmemdup().
> Therefore it might be better to free the skb and return in order to fail
> the association, like ieee80211_assoc_success().
> 
> Fixes: 4d9ec73d2b78 ("cfg80211: Report Association Request frame IEs in association events")
> Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn>
> ---
> v2: Change to fail the association if kmemdup returns NULL.
> ---
>  net/mac80211/mlme.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/net/mac80211/mlme.c b/net/mac80211/mlme.c
> index 9bed6464c5bd..b5dfdf953286 100644
> --- a/net/mac80211/mlme.c
> +++ b/net/mac80211/mlme.c
> @@ -1058,6 +1058,11 @@ static void ieee80211_send_assoc(struct ieee80211_sub_if_data *sdata)
>  	pos = skb_tail_pointer(skb);
>  	kfree(ifmgd->assoc_req_ies);
>  	ifmgd->assoc_req_ies = kmemdup(ie_start, pos - ie_start, GFP_ATOMIC);
> +	if (!ifmgd->assoc_req_ies) {
> +		dev_kfree_skb(skb);
> +		return;
> +	}
> 

That doesn't fail, that just doesn't send the frame and will then time
out later, not very useful?

johannes

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

end of thread, other threads:[~2022-01-05  7:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-01-05  1:33 [PATCH v2] mac80211: mlme: check for null after calling kmemdup Jiasheng Jiang
2022-01-05  7:49 ` Johannes Berg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).