All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jes.Sorensen@redhat.com
To: linux-wireless@vger.kernel.org
Cc: kvalo@codeaurora.org, Larry.Finger@lwfinger.net,
	Jes Sorensen <Jes.Sorensen@redhat.com>
Subject: [PATCH 1/7] rtl8xxxu: Fix memory leak in handling rxdesc16 packets
Date: Fri, 18 Nov 2016 16:44:22 -0500	[thread overview]
Message-ID: <1479505468-29383-2-git-send-email-Jes.Sorensen@redhat.com> (raw)
In-Reply-To: <1479505468-29383-1-git-send-email-Jes.Sorensen@redhat.com>

From: Jes Sorensen <Jes.Sorensen@redhat.com>

A device running without RX package aggregation could return more data
in the USB packet than the actual network packet. In this case the
could would clone the skb but then determine that that there was no
packet to handle and exit without freeing the cloned skb first.

This has so far only been observed with 8188eu devices, but could
affect others.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
---
 drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
index b2d7f6e..a96ff17 100644
--- a/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
+++ b/drivers/net/wireless/realtek/rtl8xxxu/rtl8xxxu_core.c
@@ -5197,7 +5197,12 @@ int rtl8xxxu_parse_rxdesc16(struct rtl8xxxu_priv *priv, struct sk_buff *skb)
 		pkt_offset = roundup(pkt_len + drvinfo_sz + desc_shift +
 				     sizeof(struct rtl8xxxu_rxdesc16), 128);
 
-		if (pkt_cnt > 1)
+		/*
+		 * Only clone the skb if there's enough data at the end to
+		 * at least cover the rx descriptor
+		 */
+		if (pkt_cnt > 1 &&
+		    urb_len > (pkt_offset + sizeof(struct rtl8xxxu_rxdesc16)))
 			next_skb = skb_clone(skb, GFP_ATOMIC);
 
 		rx_status = IEEE80211_SKB_RXCB(skb);
-- 
2.7.4

  reply	other threads:[~2016-11-18 21:44 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-11-18 21:44 [PATCH 0/7] rtl8xxxu: Pending patches Jes.Sorensen
2016-11-18 21:44 ` Jes.Sorensen [this message]
2016-11-25  9:51   ` [1/7] rtl8xxxu: Fix memory leak in handling rxdesc16 packets Kalle Valo
2016-11-18 21:44 ` [PATCH 2/7] rtl8xxxu: Fix big-endian problem reporting mactime Jes.Sorensen
2016-11-18 21:44 ` [PATCH 3/7] rtl8xxxu: Fix rtl8723bu driver reload issue Jes.Sorensen
2016-11-18 21:44 ` [PATCH 4/7] rtl8xxxu: Fix rtl8192eu " Jes.Sorensen
2016-11-18 21:44 ` [PATCH 5/7] rtl8xxxu: Obtain RTS rates from mac80211 Jes.Sorensen
2016-11-18 21:44 ` [PATCH 6/7] rtl8xxxu: Pass tx_info to fill_txdesc in order to have access to retry count Jes.Sorensen
2016-11-18 21:44 ` [PATCH 7/7] rtl8xxxu: Fix non static symbol warning Jes.Sorensen
2016-11-19  1:46 ` [PATCH 0/7] rtl8xxxu: Pending patches Barry Day
2016-11-19  2:00   ` Jes Sorensen
2016-11-19  2:38     ` Barry Day
2016-11-19 23:53       ` Jes Sorensen
2016-11-20  2:42         ` Barry Day
2016-11-21 16:59           ` Jes Sorensen
2016-11-22 12:26             ` Barry Day
2016-11-29  0:08               ` Jes Sorensen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1479505468-29383-2-git-send-email-Jes.Sorensen@redhat.com \
    --to=jes.sorensen@redhat.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=kvalo@codeaurora.org \
    --cc=linux-wireless@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.