lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1476889685-7367-29-git-send-email-insafonov@gmail.com>
Date:   Wed, 19 Oct 2016 22:07:57 +0700
From:   Ivan Safonov <insafonov@...il.com>
To:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Bhaktipriya Shridhar <bhaktipriya96@...il.com>,
        Andy Shevchenko <andriy.shevchenko@...ux.intel.com>,
        Geliang Tang <geliangtang@....com>, devel@...verdev.osuosl.org,
        linux-kernel@...r.kernel.org
Cc:     insafonov@...il.com
Subject: [PATCH 29/37] staging:r8188eu: take out stripping of iv and icv space from wlanhdr_to_ethhdr function

Prepare to replacing wlanhdr_to_ethhdr by ieee80211_data_to_8023.
This stripping procedure placed into new strip_iv_icv function.
Also strip_iv_icv used inside unprotect_frame.

Signed-off-by: Ivan Safonov <insafonov@...il.com>
---
 drivers/staging/rtl8188eu/core/rtw_recv.c    | 27 +++++++++++++++++++--------
 drivers/staging/rtl8188eu/include/rtw_recv.h |  3 ++-
 drivers/staging/rtl8188eu/os_dep/mon.c       |  4 +---
 3 files changed, 22 insertions(+), 12 deletions(-)

diff --git a/drivers/staging/rtl8188eu/core/rtw_recv.c b/drivers/staging/rtl8188eu/core/rtw_recv.c
index c07a3f5..630d9eb 100644
--- a/drivers/staging/rtl8188eu/core/rtw_recv.c
+++ b/drivers/staging/rtl8188eu/core/rtw_recv.c
@@ -1276,12 +1276,8 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
 	u8 *ptr = precvframe->pkt->data;
 	struct rx_pkt_attrib *pattrib = &precvframe->attrib;
 
-	if (pattrib->encrypt)
-		skb_trim(precvframe->pkt,
-			 precvframe->pkt->len - pattrib->icv_len);
-
-	psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen + pattrib->iv_len);
-	psnap_type = ptr+pattrib->hdrlen + pattrib->iv_len+SNAP_SIZE;
+	psnap = (struct ieee80211_snap_hdr *)(ptr+pattrib->hdrlen);
+	psnap_type = ptr+pattrib->hdrlen + SNAP_SIZE;
 	/* convert hdr + possible LLC headers into Ethernet header */
 	if ((!memcmp(psnap, rtw_rfc1042_header, SNAP_SIZE) &&
 	     (!memcmp(psnap_type, SNAP_ETH_TYPE_IPX, 2) == false) &&
@@ -1294,11 +1290,11 @@ static int wlanhdr_to_ethhdr(struct recv_frame *precvframe)
 		bsnaphdr = false;
 	}
 
-	rmv_len = pattrib->hdrlen + pattrib->iv_len + (bsnaphdr ? SNAP_SIZE : 0);
+	rmv_len = pattrib->hdrlen + (bsnaphdr ? SNAP_SIZE : 0);
 	len = precvframe->pkt->len - rmv_len;
 
 	RT_TRACE(_module_rtl871x_recv_c_, _drv_info_,
-		 ("\n===pattrib->hdrlen: %x,  pattrib->iv_len:%x===\n\n", pattrib->hdrlen,  pattrib->iv_len));
+		 ("\n===pattrib->hdrlen: %x===\n\n", pattrib->hdrlen));
 
 	memcpy(&be_tmp, ptr+rmv_len, 2);
 	eth_type = ntohs(be_tmp); /* pattrib->ether_type */
@@ -1733,6 +1729,13 @@ static int recv_indicatepkts_in_order(struct adapter *padapter, struct recv_reor
 	return bPktInBuf;
 }
 
+void strip_iv_icv(struct sk_buff *skb, uint header_len,
+		  uint iv_len, uint icv_len) {
+	memmove(skb->data + iv_len, skb->data, header_len);
+	skb_pull(skb, iv_len);
+	skb_trim(skb, skb->len - icv_len);
+}
+
 static int recv_indicatepkt_reorder(struct adapter *padapter,
 				    struct recv_frame *prframe)
 {
@@ -1743,6 +1746,10 @@ static int recv_indicatepkt_reorder(struct adapter *padapter,
 
 	if (!pattrib->amsdu) {
 		/* s1. */
+		strip_iv_icv(prframe->pkt, prframe->attrib.hdrlen,
+			     prframe->attrib.iv_len,
+			     prframe->attrib.encrypt ? prframe->attrib.icv_len : 0);
+
 		wlanhdr_to_ethhdr(prframe);
 
 		if ((pattrib->qos != 1) || (pattrib->eth_type == 0x0806) ||
@@ -1861,6 +1868,10 @@ static int process_recv_indicatepkts(struct adapter *padapter,
 			}
 		}
 	} else { /* B/G mode */
+		strip_iv_icv(prframe->pkt, prframe->attrib.hdrlen,
+			     prframe->attrib.iv_len,
+			     prframe->attrib.encrypt ? prframe->attrib.icv_len : 0);
+
 		retval = wlanhdr_to_ethhdr(prframe);
 		if (retval != _SUCCESS) {
 			RT_TRACE(_module_rtl871x_recv_c_, _drv_err_, ("wlanhdr_to_ethhdr: drop pkt\n"));
diff --git a/drivers/staging/rtl8188eu/include/rtw_recv.h b/drivers/staging/rtl8188eu/include/rtw_recv.h
index cacf35c..748c014e 100644
--- a/drivers/staging/rtl8188eu/include/rtw_recv.h
+++ b/drivers/staging/rtl8188eu/include/rtw_recv.h
@@ -270,5 +270,6 @@ struct sta_info;
 void _rtw_init_sta_recv_priv(struct sta_recv_priv *psta_recvpriv);
 
 void  mgt_dispatcher(struct adapter *padapter, struct recv_frame *precv_frame);
-
+void strip_iv_icv(struct sk_buff *skb, uint header_len,
+		  uint iv_len, uint icv_len);
 #endif
diff --git a/drivers/staging/rtl8188eu/os_dep/mon.c b/drivers/staging/rtl8188eu/os_dep/mon.c
index 9b3f3ec..b1fd49d 100644
--- a/drivers/staging/rtl8188eu/os_dep/mon.c
+++ b/drivers/staging/rtl8188eu/os_dep/mon.c
@@ -40,9 +40,7 @@ static void unprotect_frame(struct sk_buff *skb, int iv_len, int icv_len)
 
 	hdr->frame_control &= ~cpu_to_le16(IEEE80211_FCTL_PROTECTED);
 
-	memmove(skb->data + iv_len, skb->data, hdr_len);
-	skb_pull(skb, iv_len);
-	skb_trim(skb, skb->len - icv_len);
+	strip_iv_icv(skb, hdr_len, iv_len, icv_len);
 }
 
 static void mon_recv_decrypted(struct net_device *dev, const u8 *data,
-- 
2.7.3

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ