From 34d392122447ccd3ea6c487c8bf33dce7036b2a4 Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Mon, 14 Jan 2013 01:49:31 +0000 Subject: [PATCH] vt6656: Fix inconsistent structure packing which leads to crash on amd64 svn path=/dists/sid/linux/; revision=19727 --- debian/changelog | 1 + ...6-Fix-inconsistent-structure-packing.patch | 226 ++++++++++++++++++ debian/patches/series | 1 + 3 files changed, 228 insertions(+) create mode 100644 debian/patches/bugfix/all/vt6656-Fix-inconsistent-structure-packing.patch diff --git a/debian/changelog b/debian/changelog index f80bfa065..f6c9694a6 100644 --- a/debian/changelog +++ b/debian/changelog @@ -66,6 +66,7 @@ linux (3.2.36-1) UNRELEASED; urgency=low hid-quanta, hid-samsung, hid-speedlink * radeon: Firmware is required for DRM and KMS on R600 onward, but not for KMS on earlier chips (Closes: #697229) + * vt6656: Fix inconsistent structure packing which leads to crash on amd64 [ Aurelien Jarno ] * [armhf/vexpress] Add kernel udebs. diff --git a/debian/patches/bugfix/all/vt6656-Fix-inconsistent-structure-packing.patch b/debian/patches/bugfix/all/vt6656-Fix-inconsistent-structure-packing.patch new file mode 100644 index 000000000..f2070ed7e --- /dev/null +++ b/debian/patches/bugfix/all/vt6656-Fix-inconsistent-structure-packing.patch @@ -0,0 +1,226 @@ +Subject: vt6656: Fix inconsistent structure packing +From: Ben Hutchings +Date: Mon, 14 Jan 2013 01:29:17 +0000 + +vt6656 has several headers that use the #pragma pack(1) directive to +enable structure packing, but never disable it. The layout of +structures defined in other headers can then depend on which order the +various headers are included in, breaking the One Definition Rule. + +In practice this resulted in crashes on x86_64 until the order of header +inclusion was changed for some files in commit 11d404cb56ecd ('staging: +vt6656: fix headers and add cfg80211.'). But we need a proper fix that +won't be affected by future changes to the order of inclusion. + +This removes the #pragma pack(1) directives and adds __packed to the +structure definitions for which packing appears to have been intended. + +Reported-and-tested-by: Malcolm Priestley +Signed-off-by: Ben Hutchings +Cc: stable@vger.kernel.org +--- +--- a/drivers/staging/vt6656/bssdb.h ++++ b/drivers/staging/vt6656/bssdb.h +@@ -92,7 +92,6 @@ typedef struct tagSRSNCapObject { + } SRSNCapObject, *PSRSNCapObject; + + // BSS info(AP) +-#pragma pack(1) + typedef struct tagKnownBSS { + // BSS info + BOOL bActive; +--- a/drivers/staging/vt6656/int.h ++++ b/drivers/staging/vt6656/int.h +@@ -34,7 +34,6 @@ + #include "device.h" + + /*--------------------- Export Definitions -------------------------*/ +-#pragma pack(1) + typedef struct tagSINTData { + BYTE byTSR0; + BYTE byPkt0; +--- a/drivers/staging/vt6656/iocmd.h ++++ b/drivers/staging/vt6656/iocmd.h +@@ -95,13 +95,12 @@ typedef enum tagWZONETYPE { + // Ioctl interface structure + // Command structure + // +-#pragma pack(1) + typedef struct tagSCmdRequest { + u8 name[16]; + void *data; + u16 wResult; + u16 wCmdCode; +-} SCmdRequest, *PSCmdRequest; ++} __packed SCmdRequest, *PSCmdRequest; + + // + // Scan +@@ -111,7 +110,7 @@ typedef struct tagSCmdScan { + + u8 ssid[SSID_MAXLEN + 2]; + +-} SCmdScan, *PSCmdScan; ++} __packed SCmdScan, *PSCmdScan; + + // + // BSS Join +@@ -126,7 +125,7 @@ typedef struct tagSCmdBSSJoin { + BOOL bPSEnable; + BOOL bShareKeyAuth; + +-} SCmdBSSJoin, *PSCmdBSSJoin; ++} __packed SCmdBSSJoin, *PSCmdBSSJoin; + + // + // Zonetype Setting +@@ -137,7 +136,7 @@ typedef struct tagSCmdZoneTypeSet { + BOOL bWrite; + WZONETYPE ZoneType; + +-} SCmdZoneTypeSet, *PSCmdZoneTypeSet; ++} __packed SCmdZoneTypeSet, *PSCmdZoneTypeSet; + + typedef struct tagSWPAResult { + char ifname[100]; +@@ -145,7 +144,7 @@ typedef struct tagSWPAResult { + u8 key_mgmt; + u8 eap_type; + BOOL authenticated; +-} SWPAResult, *PSWPAResult; ++} __packed SWPAResult, *PSWPAResult; + + typedef struct tagSCmdStartAP { + +@@ -157,7 +156,7 @@ typedef struct tagSCmdStartAP { + BOOL bShareKeyAuth; + u8 byBasicRate; + +-} SCmdStartAP, *PSCmdStartAP; ++} __packed SCmdStartAP, *PSCmdStartAP; + + typedef struct tagSCmdSetWEP { + +@@ -167,7 +166,7 @@ typedef struct tagSCmdSetWEP { + BOOL bWepKeyAvailable[WEP_NKEYS]; + u32 auWepKeyLength[WEP_NKEYS]; + +-} SCmdSetWEP, *PSCmdSetWEP; ++} __packed SCmdSetWEP, *PSCmdSetWEP; + + typedef struct tagSBSSIDItem { + +@@ -180,14 +179,14 @@ typedef struct tagSBSSIDItem { + BOOL bWEPOn; + u32 uRSSI; + +-} SBSSIDItem; ++} __packed SBSSIDItem; + + + typedef struct tagSBSSIDList { + + u32 uItem; + SBSSIDItem sBSSIDList[0]; +-} SBSSIDList, *PSBSSIDList; ++} __packed SBSSIDList, *PSBSSIDList; + + + typedef struct tagSNodeItem { +@@ -208,7 +207,7 @@ typedef struct tagSNodeItem { + u32 uTxAttempts; + u16 wFailureRatio; + +-} SNodeItem; ++} __packed SNodeItem; + + + typedef struct tagSNodeList { +@@ -216,7 +215,7 @@ typedef struct tagSNodeList { + u32 uItem; + SNodeItem sNodeList[0]; + +-} SNodeList, *PSNodeList; ++} __packed SNodeList, *PSNodeList; + + + typedef struct tagSCmdLinkStatus { +@@ -229,7 +228,7 @@ typedef struct tagSCmdLinkStatus { + u32 uChannel; + u32 uLinkRate; + +-} SCmdLinkStatus, *PSCmdLinkStatus; ++} __packed SCmdLinkStatus, *PSCmdLinkStatus; + + // + // 802.11 counter +@@ -247,7 +246,7 @@ typedef struct tagSDot11MIBCount { + u32 ReceivedFragmentCount; + u32 MulticastReceivedFrameCount; + u32 FCSErrorCount; +-} SDot11MIBCount, *PSDot11MIBCount; ++} __packed SDot11MIBCount, *PSDot11MIBCount; + + + +@@ -355,13 +354,13 @@ typedef struct tagSStatMIBCount { + u32 ullTxBroadcastBytes[2]; + u32 ullTxMulticastBytes[2]; + u32 ullTxDirectedBytes[2]; +-} SStatMIBCount, *PSStatMIBCount; ++} __packed SStatMIBCount, *PSStatMIBCount; + + typedef struct tagSCmdValue { + + u32 dwValue; + +-} SCmdValue, *PSCmdValue; ++} __packed SCmdValue, *PSCmdValue; + + // + // hostapd & viawget ioctl related +@@ -431,7 +430,7 @@ struct viawget_hostapd_param { + u8 ssid[32]; + } scan_req; + } u; +-}; ++} __packed; + + /*--------------------- Export Classes ----------------------------*/ + +--- a/drivers/staging/vt6656/iowpa.h ++++ b/drivers/staging/vt6656/iowpa.h +@@ -67,12 +67,11 @@ enum { + + + +-#pragma pack(1) + typedef struct viawget_wpa_header { + u8 type; + u16 req_ie_len; + u16 resp_ie_len; +-} viawget_wpa_header; ++} __packed viawget_wpa_header; + + struct viawget_wpa_param { + u32 cmd; +@@ -113,9 +112,8 @@ struct viawget_wpa_param { + u8 *buf; + } scan_results; + } u; +-}; ++} __packed; + +-#pragma pack(1) + struct viawget_scan_result { + u8 bssid[6]; + u8 ssid[32]; +@@ -130,7 +128,7 @@ struct viawget_scan_result { + int noise; + int level; + int maxrate; +-}; ++} __packed; + + /*--------------------- Export Classes ----------------------------*/ + diff --git a/debian/patches/series b/debian/patches/series index e8f93652f..73b5905a2 100644 --- a/debian/patches/series +++ b/debian/patches/series @@ -463,3 +463,4 @@ features/all/iguanair/0009-media-rc-do-not-wake-up-rc-thread-unless-there-is-so. features/all/iguanair/0010-media-iguanair-do-not-modify-transmit-buffer.patch features/all/iguanair/0011-media-iguanair-cannot-send-data-from-the-stack.patch features/all/rt2800-add-chipset-revision-RT5390R-support.patch +bugfix/all/vt6656-Fix-inconsistent-structure-packing.patch