All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] staging: rtl8712: prevent buffer overrun in recvbuf2recvframe
@ 2015-05-19  5:47 Haggai Eran
  2015-05-19 15:51 ` Larry Finger
       [not found] ` <CAJ=9Czay5pbi6p+n8SxXaJsWG4JR2p_vteKYbLxvoxLVtPQPaQ@mail.gmail.com>
  0 siblings, 2 replies; 8+ messages in thread
From: Haggai Eran @ 2015-05-19  5:47 UTC (permalink / raw)
  To: Larry Finger; +Cc: linux-wireless, Haggai Eran

With an RTL8191SU USB adaptor, sometimes the hints for a fragmented
packet are set, but the packet length is too large. Truncate the packet
to prevent memory corruption.

Signed-off-by: Haggai Eran <haggai.eran@gmail.com>
---

Hi,

I think this solves the issue for me. I'll test it more thoroughly later. I
still don't know why a fragmented packet has such a large pkt_len value though. 

Thanks,
Haggai

 drivers/staging/rtl8712/rtl8712_recv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/rtl8712/rtl8712_recv.c b/drivers/staging/rtl8712/rtl8712_recv.c
index cd8b444..d7ea9c1 100644
--- a/drivers/staging/rtl8712/rtl8712_recv.c
+++ b/drivers/staging/rtl8712/rtl8712_recv.c
@@ -1055,8 +1055,12 @@ static int recvbuf2recvframe(struct _adapter *padapter, struct sk_buff *pskb)
 		pkt_offset = (u16)round_up(tmp_len, 128);
 		/* for first fragment packet, driver need allocate 1536 +
 		 * drvinfo_sz + RXDESC_SIZE to defrag packet. */
-		if ((mf == 1) && (frag == 0))
+		if ((mf == 1) && (frag == 0)) {
 			alloc_sz = 1658;/*1658+6=1664, 1664 is 128 alignment.*/
+            if (tmp_len > alloc_sz) {
+                tmp_len = alloc_sz;
+            }
+        }
 		else
 			alloc_sz = tmp_len;
 		/* 2 is for IP header 4 bytes alignment in QoS packet case.
-- 
1.9.1


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

end of thread, other threads:[~2015-05-23 18:09 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-05-19  5:47 [PATCH] staging: rtl8712: prevent buffer overrun in recvbuf2recvframe Haggai Eran
2015-05-19 15:51 ` Larry Finger
2015-05-19 17:23   ` Haggai Eran
     [not found] ` <CAJ=9Czay5pbi6p+n8SxXaJsWG4JR2p_vteKYbLxvoxLVtPQPaQ@mail.gmail.com>
2015-05-20 16:39   ` Larry Finger
2015-05-20 19:20     ` Haggai Eran
2015-05-23 17:24       ` Haggai Eran
2015-05-23 17:48         ` Larry Finger
2015-05-23 18:09           ` Haggai Eran

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.