Vulnerability: The ieee80211_radiotap_iterator_init function in net/wireless/radiotap.c in the Linux kernel before 3.11.7 does not check whether a frame contains any data outside of the header, which might allow attackers to cause a denial of service (buffer over-read) via a crafted header.
Vulnerability ID: CVE-2013-7027
CWE: CWE-119
Severity score: 6.9
Project: https://github.com/torvalds/linux
Published: 2013-12-09
File: net/wireless/radiotap.c
Commit message: wireless: radiotap: fix parsing buffer overrun

When parsing an invalid radiotap header, the parser can overrun
the buffer that is passed in because it doesn't correctly check
 1) the minimum radiotap header size
 2) the space for extended bitmaps

The first issue doesn't affect any in-kernel user as they all
check the minimum size before calling the radiotap function.
The second issue could potentially affect the kernel if an skb
is passed in that consists only of the radiotap header with a
lot of extended bitmaps that extend past the SKB. In that case
a read-only buffer overrun by at most 4 bytes is possible.

Fix this by adding the appropriate checks to the parser.

Cc: stable@vger.kernel.org
Reported-by: Evan Huus <eapache@gmail.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Commit author: Johannes Berg

Vulnerable version (before fix):
 int ieee80211_radiotap_iterator_init( 	struct ieee80211_radiotap_header *radiotap_header, 	int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns) { 	/* Linux only supports version 0 radiotap format */ 	if (radiotap_header->it_version) 		return -EINVAL; int ieee80211_radiotap_iterator_init( 			 */  			if ((unsigned long)iterator->_arg - 			    (unsigned long)iterator->_rtheader > 			    (unsigned long)iterator->_max_length) 				return -EINVAL; 		}

Fixed version (after fix):
 int ieee80211_radiotap_iterator_init( 	struct ieee80211_radiotap_header *radiotap_header, 	int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns) { 	/* check the radiotap header can actually be present */ 	if (max_length < sizeof(struct ieee80211_radiotap_header)) 		return -EINVAL;  	/* Linux only supports version 0 radiotap format */ 	if (radiotap_header->it_version) 		return -EINVAL; int ieee80211_radiotap_iterator_init( 			 */  			if ((unsigned long)iterator->_arg - 			    (unsigned long)iterator->_rtheader + 			    sizeof(uint32_t) > 			    (unsigned long)iterator->_max_length) 				return -EINVAL; 		}

Patch:
patch: @@ -97,6 +97,10 @@ int ieee80211_radiotap_iterator_init(
 	struct ieee80211_radiotap_header *radiotap_header,
 	int max_length, const struct ieee80211_radiotap_vendor_namespaces *vns)
 {
+	/* check the radiotap header can actually be present */
+	if (max_length < sizeof(struct ieee80211_radiotap_header))
+		return -EINVAL;
+
 	/* Linux only supports version 0 radiotap format */
 	if (radiotap_header->it_version)
 		return -EINVAL;
@@ -131,7 +135,8 @@ int ieee80211_radiotap_iterator_init(
 			 */
 
 			if ((unsigned long)iterator->_arg -
-			    (unsigned long)iterator->_rtheader >
+			    (unsigned long)iterator->_rtheader +
+			    sizeof(uint32_t) >
 			    (unsigned long)iterator->_max_length)
 				return -EINVAL;
 		}
path: net/wireless/radiotap.c